Index: chrome/test/data/extensions/api_test/debugger/background.js |
diff --git a/chrome/test/data/extensions/api_test/debugger/background.js b/chrome/test/data/extensions/api_test/debugger/background.js |
index d68ed6b02ea831aa9875cc418eda0f4bc38e94b0..3545d3dd5c657a3658668fea2d368aa788a889cc 100644 |
--- a/chrome/test/data/extensions/api_test/debugger/background.js |
+++ b/chrome/test/data/extensions/api_test/debugger/background.js |
@@ -9,6 +9,9 @@ var tabId; |
var debuggee; |
var protocolVersion = "1.0"; |
+var SILENT_FLAG_REQUIRED = "Cannot attach to this target unless " + |
+ "'silent-debugger-extension-api' flag is enabled."; |
+ |
chrome.test.runTests([ |
function attachMalformedVersion() { |
@@ -106,10 +109,41 @@ chrome.test.runTests([ |
fail("No tab with given id " + missingDebuggee.tabId + ".")); |
}, |
- function attachToExtensionWithNoSilentFlag() { |
- debuggeeExtension = {extensionId: "foo"}; |
+ function attachToOwnBackgroundPageWithNoSilentFlag() { |
+ var ownExtensionId = chrome.extension.getURL('').split('/')[2]; |
+ debuggeeExtension = {extensionId: ownExtensionId}; |
chrome.debugger.attach(debuggeeExtension, protocolVersion, |
- fail("Cannot attach to an extension unless " + |
- "'silent-debugger-extension-api' flag is enabled.")); |
+ fail(SILENT_FLAG_REQUIRED)); |
+ }, |
+ |
+ function createAndDiscoverTab() { |
+ chrome.test.listenOnce(chrome.tabs.onUpdated, function () { |
+ chrome.debugger.getTargets(function(targets) { |
+ var page = targets.filter( |
+ function(t) { |
+ return t.type == 'page' && t.title == 'Test page'; |
+ })[0]; |
+ if (page) { |
+ chrome.debugger.attach( |
+ {targetId: page.id}, protocolVersion, pass()); |
+ } else { |
+ chrome.test.fail("Cannot discover a newly created tab"); |
+ } |
+ }); |
+ }); |
+ chrome.tabs.create({url: "inspected.html"}); |
+ }, |
+ |
+ function discoverBackgroundPageWithNoSilentFlag() { |
+ chrome.debugger.getTargets(function(targets) { |
+ var target = targets.filter( |
+ function(target) { return target.type == 'background_page'})[0]; |
+ if (target) { |
+ chrome.debugger.attach({targetId: target.id}, protocolVersion, |
+ fail(SILENT_FLAG_REQUIRED)); |
+ } else { |
+ chrome.test.succeed(); |
+ } |
+ }); |
} |
]); |