OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var pass = chrome.test.callbackPass; |
| 6 var fail = chrome.test.callbackFail; |
| 7 |
| 8 var tabId; |
| 9 var debuggee; |
| 10 var protocolVersion = "0.1"; |
| 11 |
| 12 chrome.test.runTests([ |
| 13 |
| 14 function attachMalformedVersion() { |
| 15 chrome.tabs.getSelected(null, function(tab) { |
| 16 chrome.experimental.debugger.attach({tabId: tab.id}, "malformed-version", |
| 17 fail("Requested protocol version is not supported: malformed-version."
)); |
| 18 }); |
| 19 }, |
| 20 |
| 21 function attachUnsupportedVersion() { |
| 22 chrome.tabs.getSelected(null, function(tab) { |
| 23 chrome.experimental.debugger.attach({tabId: tab.id}, "1.0", |
| 24 fail("Requested protocol version is not supported: 1.0.")); |
| 25 }); |
| 26 }, |
| 27 |
| 28 function attach() { |
| 29 chrome.tabs.getSelected(null, function(tab) { |
| 30 tabId = tab.id; |
| 31 debuggee = {tabId: tab.id}; |
| 32 chrome.experimental.debugger.attach(debuggee, protocolVersion, pass()); |
| 33 }); |
| 34 }, |
| 35 |
| 36 function attachAgain() { |
| 37 chrome.experimental.debugger.attach(debuggee, protocolVersion, |
| 38 fail("Another debugger is already attached to the tab with id: " + |
| 39 tabId + ".")); |
| 40 }, |
| 41 |
| 42 function sendCommand() { |
| 43 function onResponse() { |
| 44 if (chrome.extension.lastError && |
| 45 chrome.extension.lastError.message.indexOf("invalidMethod") != -1) |
| 46 chrome.test.succeed(); |
| 47 else |
| 48 chrome.test.fail(); |
| 49 } |
| 50 chrome.experimental.debugger.sendCommand(debuggee, |
| 51 "invalidMethod", |
| 52 null, |
| 53 onResponse); |
| 54 }, |
| 55 |
| 56 function detach() { |
| 57 chrome.experimental.debugger.detach(debuggee, pass()); |
| 58 }, |
| 59 |
| 60 function sendCommandAfterDetach() { |
| 61 chrome.experimental.debugger.sendCommand(debuggee, "Foo", null, |
| 62 fail("Debugger is not attached to the tab with id: " + tabId + ".")); |
| 63 }, |
| 64 |
| 65 function detachAgain() { |
| 66 chrome.experimental.debugger.detach(debuggee, |
| 67 fail("Debugger is not attached to the tab with id: " + tabId + ".")); |
| 68 }, |
| 69 |
| 70 function closeTab() { |
| 71 chrome.tabs.create({url:"inspected.html"}, function(tab) { |
| 72 function onDetach(debuggee) { |
| 73 chrome.test.assertEq(tab.id, debuggee.tabId); |
| 74 chrome.experimental.debugger.onDetach.removeListener(onDetach); |
| 75 chrome.test.succeed(); |
| 76 } |
| 77 |
| 78 var debuggee2 = {tabId: tab.id}; |
| 79 chrome.experimental.debugger.attach(debuggee2, protocolVersion, function()
{ |
| 80 chrome.experimental.debugger.onDetach.addListener(onDetach); |
| 81 chrome.tabs.remove(tab.id); |
| 82 }); |
| 83 }); |
| 84 } |
| 85 ]); |
OLD | NEW |