OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 debuggee; | 8 var debuggee; |
9 var protocolVersion = "1.0"; | 9 var protocolVersion = "1.0"; |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 }, | 30 }, |
31 | 31 |
32 function detach() { | 32 function detach() { |
33 chrome.debugger.detach(debuggee, pass()); | 33 chrome.debugger.detach(debuggee, pass()); |
34 }, | 34 }, |
35 | 35 |
36 function detachAgain() { | 36 function detachAgain() { |
37 chrome.debugger.detach(debuggee, | 37 chrome.debugger.detach(debuggee, |
38 fail("Debugger is not attached to the background page with id: " + | 38 fail("Debugger is not attached to the background page with id: " + |
39 debuggee.extensionId + ".")); | 39 debuggee.extensionId + ".")); |
| 40 }, |
| 41 |
| 42 function discoverWorker() { |
| 43 chrome.test.listenOnce(chrome.tabs.onUpdated, function () { |
| 44 chrome.debugger.getTargets(function(targets) { |
| 45 var page = targets.filter( |
| 46 function(t) { return t.type == 'worker'; })[0]; |
| 47 if (page) { |
| 48 chrome.debugger.attach({targetId: page.id}, protocolVersion, pass()); |
| 49 } else { |
| 50 chrome.test.fail("Cannot discover a newly created worker"); |
| 51 } |
| 52 }); |
| 53 }); |
| 54 chrome.tabs.create({url: "worker.html"}); |
40 } | 55 } |
41 ]); | 56 ]); |
OLD | NEW |