OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 JSON.parse = function() { | 5 JSON.parse = function() { |
6 return "JSON.parse clobbered by content script."; | 6 return "JSON.parse clobbered by content script."; |
7 }; | 7 }; |
8 | 8 |
9 JSON.stringify = function() { | 9 JSON.stringify = function() { |
10 return "JSON.stringify clobbered by content script."; | 10 return "JSON.stringify clobbered by content script."; |
(...skipping 22 matching lines...) Expand all Loading... |
33 testSendMessageFromFrame(); | 33 testSendMessageFromFrame(); |
34 } else if (msg.testSendMessageToFrame) { | 34 } else if (msg.testSendMessageToFrame) { |
35 port.postMessage('from_main'); | 35 port.postMessage('from_main'); |
36 } else if (msg.testDisconnect) { | 36 } else if (msg.testDisconnect) { |
37 port.disconnect(); | 37 port.disconnect(); |
38 } else if (msg.testConnectChildFrameAndNavigateSetup) { | 38 } else if (msg.testConnectChildFrameAndNavigateSetup) { |
39 chrome.runtime.onConnect.removeListener(onConnect); | 39 chrome.runtime.onConnect.removeListener(onConnect); |
40 chrome.test.assertFalse(chrome.runtime.onConnect.hasListeners()); | 40 chrome.test.assertFalse(chrome.runtime.onConnect.hasListeners()); |
41 testConnectChildFrameAndNavigateSetup(); | 41 testConnectChildFrameAndNavigateSetup(); |
42 } else if (msg.testDisconnectOnClose) { | 42 } else if (msg.testDisconnectOnClose) { |
43 window.location = "about:blank"; | 43 chrome.runtime.connect().onMessage.addListener(function(msg) { |
| 44 chrome.test.assertEq('unloadTabContent', msg); |
| 45 window.location = 'about:blank'; |
| 46 }); |
44 } else if (msg.testPortName) { | 47 } else if (msg.testPortName) { |
45 port.postMessage({portName:port.name}); | 48 port.postMessage({portName:port.name}); |
46 } else if (msg.testSendMessageFromTabError) { | 49 } else if (msg.testSendMessageFromTabError) { |
47 testSendMessageFromTabError(); | 50 testSendMessageFromTabError(); |
48 } else if (msg.testConnectFromTabError) { | 51 } else if (msg.testConnectFromTabError) { |
49 testConnectFromTabError(); | 52 testConnectFromTabError(); |
50 } | 53 } |
51 }); | 54 }); |
52 }); | 55 }); |
53 | 56 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 var success = (chrome.runtime.lastError ? true : false); | 115 var success = (chrome.runtime.lastError ? true : false); |
113 chrome.runtime.sendMessage({success: success}); | 116 chrome.runtime.sendMessage({success: success}); |
114 }); | 117 }); |
115 } | 118 } |
116 | 119 |
117 // For test sendMessage. | 120 // For test sendMessage. |
118 chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { | 121 chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { |
119 chrome.test.assertEq({id: chrome.runtime.id}, sender); | 122 chrome.test.assertEq({id: chrome.runtime.id}, sender); |
120 sendResponse({success: (request.step2 == 1)}); | 123 sendResponse({success: (request.step2 == 1)}); |
121 }); | 124 }); |
OLD | NEW |