3

Task: Debug other extensions using chrome debugger api.

Expected Output: http request logs made by other installed extensions.

Method: Running chrome webdriver with selenium in python setting flag chromeopts.add_argument('--silent-debugger-extension-api' ). Inside my extension, On event chrome.management.onInstalled using following code

chrome.debugger.attach({ extensionId: info.id }, version, onAttach.bind(null, info.id)); chrome.debugger.sendCommand({ extensionId: info.id }, "Network.enable"); chrome.debugger.onEvent.addListener(onEvent);

Error: Cannot access a chrome-extension:// URL of different extension

Xan
  • 74,770
  • 16
  • 179
  • 206
CryptoKitty
  • 654
  • 4
  • 20
  • Make sure the flag is actually active; it should be visible at `chrome://version/` – Xan Jun 25 '15 at 15:26
  • thanks @Xan.I can only see these flags _Command Line "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --flag-switches-begin --flag-switches-end_ guess you are right flag is not setting. Is chromeopts.add_argument('--silent-debugger-extension-api') not correct command? Any alternative way of setting it automatically? – CryptoKitty Jun 25 '15 at 15:31
  • Unfortunately, I have no experience with webdriver. But it's a reasonable suspicion. – Xan Jun 25 '15 at 15:32
  • [This question](http://stackoverflow.com/q/15165593/934239) may help. – Xan Jun 25 '15 at 15:37
  • 1
    I have manually enable the flag from chrome://flags but still got the same error. Is it a problem of chrome? is this function allowed even? – CryptoKitty Jun 25 '15 at 15:44
  • Again, as much as I know Chrome extension API, this is something I don't know. It's possible that this is not allowed, but docs are unclear. – Xan Jun 25 '15 at 15:45

1 Answers1

5

To debug the background page of another extension, you need to set two flags:

  • --silent-debugger-extension-api
    To allow debugging of background pages.
  • --extensions-on-chrome-urls
    To allow debugging of other extensions.
Rob W
  • 341,306
  • 83
  • 791
  • 678
  • What an excellent answer. Thank you for helping. Also can you tell me will this only store xhrhtmlrequest from background script? what about contentscript? – CryptoKitty Jun 25 '15 at 17:28
  • @muhammadharis Do not ask follow-up questions in comments. We're here to help if you ask a new one. – Xan Jun 25 '15 at 17:30
  • @RobW I've created a docs issue about it, I'd be great if you could triage it: https://code.google.com/p/chromium/issues/detail?id=504494 – Xan Jun 25 '15 at 19:53