diff options
author | kaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-26 14:28:10 +0000 |
---|---|---|
committer | kaznacheev@chromium.org <kaznacheev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-26 14:28:10 +0000 |
commit | 2fefdb374d6e2979d7e3d673844d1e472fe7ffdb (patch) | |
tree | 5a5952bcef574f634c6f343ff55e328fe56589e2 /chrome/test | |
parent | 3ec4bcc58fbdff9a0f2b3fd6a2015ea89f172b31 (diff) | |
download | chromium_src-2fefdb374d6e2979d7e3d673844d1e472fe7ffdb.zip chromium_src-2fefdb374d6e2979d7e3d673844d1e472fe7ffdb.tar.gz chromium_src-2fefdb374d6e2979d7e3d673844d1e472fe7ffdb.tar.bz2 |
Allow chrome.debugger API to attach to extension background pages.
Since there is no way to provide a visual notification for the user this will be only possible when --remote-debugging-silent command line switch is present.
BUG=176962
Review URL: https://chromiumcodereview.appspot.com/12304021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184645 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
3 files changed, 65 insertions, 1 deletions
diff --git a/chrome/test/data/extensions/api_test/debugger/background.js b/chrome/test/data/extensions/api_test/debugger/background.js index b6b65f5..d68ed6b 100644 --- a/chrome/test/data/extensions/api_test/debugger/background.js +++ b/chrome/test/data/extensions/api_test/debugger/background.js @@ -98,6 +98,18 @@ chrome.test.runTests([ fail("Can not attach to the page with the \"chrome://\" scheme.")); chrome.tabs.remove(tab.id); }); - } + }, + function attachToMissing() { + var missingDebuggee = {tabId: -1}; + chrome.debugger.attach(missingDebuggee, protocolVersion, + fail("No tab with given id " + missingDebuggee.tabId + ".")); + }, + + function attachToExtensionWithNoSilentFlag() { + debuggeeExtension = {extensionId: "foo"}; + chrome.debugger.attach(debuggeeExtension, protocolVersion, + fail("Cannot attach to an extension unless " + + "'silent-debugger-extension-api' flag is enabled.")); + } ]); diff --git a/chrome/test/data/extensions/api_test/debugger_extension/background.js b/chrome/test/data/extensions/api_test/debugger_extension/background.js new file mode 100644 index 0000000..63101a8 --- /dev/null +++ b/chrome/test/data/extensions/api_test/debugger_extension/background.js @@ -0,0 +1,41 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var pass = chrome.test.callbackPass; +var fail = chrome.test.callbackFail; + +var debuggee; +var protocolVersion = "1.0"; + +chrome.test.runTests([ + + function attach() { + var extensionId = chrome.extension.getURL('').split('/')[2]; + debuggee = {extensionId: extensionId}; + chrome.debugger.attach(debuggee, protocolVersion, pass()); + }, + + function attachToMissing() { + var missingDebuggee = {extensionId: "foo"}; + chrome.debugger.attach(missingDebuggee, protocolVersion, + fail("No extension with given id " + + missingDebuggee.extensionId + ".")); + }, + + function attachAgain() { + chrome.debugger.attach(debuggee, protocolVersion, + fail("Another debugger is already attached to the extension with id: " + + debuggee.extensionId + ".")); + }, + + function detach() { + chrome.debugger.detach(debuggee, pass()); + }, + + function detachAgain() { + chrome.debugger.detach(debuggee, + fail("Debugger is not attached to the extension with id: " + + debuggee.extensionId + ".")); + } +]); diff --git a/chrome/test/data/extensions/api_test/debugger_extension/manifest.json b/chrome/test/data/extensions/api_test/debugger_extension/manifest.json new file mode 100644 index 0000000..402429d --- /dev/null +++ b/chrome/test/data/extensions/api_test/debugger_extension/manifest.json @@ -0,0 +1,11 @@ +{ + "name": "Extension Debugger", + "version": "1.0", + "manifest_version": 2, + "background": { + "scripts": ["background.js"] + }, + "permissions": [ + "debugger" + ] +} |