OLD | NEW |
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"; |
11 | 11 |
| 12 var SILENT_FLAG_REQUIRED = "Cannot attach to this target unless " + |
| 13 "'silent-debugger-extension-api' flag is enabled."; |
| 14 |
12 chrome.test.runTests([ | 15 chrome.test.runTests([ |
13 | 16 |
14 function attachMalformedVersion() { | 17 function attachMalformedVersion() { |
15 chrome.tabs.getSelected(null, function(tab) { | 18 chrome.tabs.getSelected(null, function(tab) { |
16 chrome.debugger.attach({tabId: tab.id}, "malformed-version", | 19 chrome.debugger.attach({tabId: tab.id}, "malformed-version", |
17 fail("Requested protocol version is not supported: malformed-version."
)); | 20 fail("Requested protocol version is not supported: malformed-version."
)); |
18 }); | 21 }); |
19 }, | 22 }, |
20 | 23 |
21 function attachUnsupportedMinorVersion() { | 24 function attachUnsupportedMinorVersion() { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 chrome.tabs.remove(tab.id); | 102 chrome.tabs.remove(tab.id); |
100 }); | 103 }); |
101 }, | 104 }, |
102 | 105 |
103 function attachToMissing() { | 106 function attachToMissing() { |
104 var missingDebuggee = {tabId: -1}; | 107 var missingDebuggee = {tabId: -1}; |
105 chrome.debugger.attach(missingDebuggee, protocolVersion, | 108 chrome.debugger.attach(missingDebuggee, protocolVersion, |
106 fail("No tab with given id " + missingDebuggee.tabId + ".")); | 109 fail("No tab with given id " + missingDebuggee.tabId + ".")); |
107 }, | 110 }, |
108 | 111 |
109 function attachToExtensionWithNoSilentFlag() { | 112 function attachToOwnBackgroundPageWithNoSilentFlag() { |
110 debuggeeExtension = {extensionId: "foo"}; | 113 var ownExtensionId = chrome.extension.getURL('').split('/')[2]; |
| 114 debuggeeExtension = {extensionId: ownExtensionId}; |
111 chrome.debugger.attach(debuggeeExtension, protocolVersion, | 115 chrome.debugger.attach(debuggeeExtension, protocolVersion, |
112 fail("Cannot attach to an extension unless " + | 116 fail(SILENT_FLAG_REQUIRED)); |
113 "'silent-debugger-extension-api' flag is enabled.")); | |
114 } | 117 } |
115 ]); | 118 ]); |
OLD | NEW |