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

Side by Side 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: Rebased 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var pass = chrome.test.callbackPass; 5 var pass = chrome.test.callbackPass;
6 var fail = chrome.test.callbackFail; 6 var fail = chrome.test.callbackFail;
7 7
8 var tabId; 8 var tabId;
9 var debuggee; 9 var debuggee;
10 var protocolVersion = "1.0"; 10 var protocolVersion = "1.0";
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 var missingDebuggee = {tabId: -1}; 104 var missingDebuggee = {tabId: -1};
105 chrome.debugger.attach(missingDebuggee, protocolVersion, 105 chrome.debugger.attach(missingDebuggee, protocolVersion,
106 fail("No tab with given id " + missingDebuggee.tabId + ".")); 106 fail("No tab with given id " + missingDebuggee.tabId + "."));
107 }, 107 },
108 108
109 function attachToExtensionWithNoSilentFlag() { 109 function attachToExtensionWithNoSilentFlag() {
110 debuggeeExtension = {extensionId: "foo"}; 110 debuggeeExtension = {extensionId: "foo"};
111 chrome.debugger.attach(debuggeeExtension, protocolVersion, 111 chrome.debugger.attach(debuggeeExtension, protocolVersion,
112 fail("Cannot attach to an extension unless " + 112 fail("Cannot attach to an extension unless " +
113 "'silent-debugger-extension-api' flag is enabled.")); 113 "'silent-debugger-extension-api' flag is enabled."));
114 },
115
116 function createAndDiscoverTab() {
117 chrome.test.listenOnce(chrome.tabs.onUpdated, function () {
118 chrome.debugger.getTargets(function(targets) {
119 var page = targets.filter(
120 function(t) {
121 return t.type == 'page' && t.title == 'Test page';
122 })[0];
123 if (page) {
124 chrome.debugger.attach(
125 {targetId: page.id}, protocolVersion, pass());
126 } else {
127 chrome.test.fail("Cannot discover a newly created tab");
128 }
129 });
130 });
131 chrome.tabs.create({url: "inspected.html"});
132 },
133
134 function discoverExtensionWithNoSilentFlag() {
135 chrome.debugger.getTargets(function(targets) {
136 var target = targets.filter(
137 function(target) { return target.type == 'extension'})[0];
138 if (target) {
139 chrome.debugger.attach({targetId: target.id}, protocolVersion,
140 fail("Cannot attach to an extension unless " +
141 "'silent-debugger-extension-api' flag is enabled."));
142 } else {
143 chrome.test.succeed();
144 }
145 });
114 } 146 }
115 ]); 147 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698