Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4803)

Unified Diff: chrome/test/data/extensions/api_test/debugger/background.js

Issue 12377047: Add chrome.debugger.getTargets method to discover available debug targets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@targets
Patch Set: Rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+ }
+ });
}
]);

Powered by Google App Engine
This is Rietveld 408576698