| 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 listenOnce = chrome.test.listenOnce; | 5 var listenOnce = chrome.test.listenOnce; |
| 6 var listenForever = chrome.test.listenForever; | 6 var listenForever = chrome.test.listenForever; |
| 7 | 7 |
| 8 JSON.parse = function() { | 8 JSON.parse = function() { |
| 9 return "JSON.parse clobbered by extension."; | 9 return "JSON.parse clobbered by extension."; |
| 10 }; | 10 }; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // Now we have set up a frame and ensured that there is no onConnect | 268 // Now we have set up a frame and ensured that there is no onConnect |
| 269 // handler in the main frame. Run the actual test: | 269 // handler in the main frame. Run the actual test: |
| 270 var port = chrome.tabs.connect(testTab.id); | 270 var port = chrome.tabs.connect(testTab.id); |
| 271 listenOnce(port.onDisconnect, function() {}); | 271 listenOnce(port.onDisconnect, function() {}); |
| 272 port.postMessage({testConnectChildFrameAndNavigate: true}); | 272 port.postMessage({testConnectChildFrameAndNavigate: true}); |
| 273 }); | 273 }); |
| 274 chrome.tabs.connect(testTab.id) | 274 chrome.tabs.connect(testTab.id) |
| 275 .postMessage({testConnectChildFrameAndNavigateSetup: true}); | 275 .postMessage({testConnectChildFrameAndNavigateSetup: true}); |
| 276 }, | 276 }, |
| 277 | 277 |
| 278 // The previous test removed the onConnect listener. Add it back. |
| 279 function reloadTabForTest() { |
| 280 var doneListening = listenForever(chrome.tabs.onUpdated, |
| 281 function(tabId, info) { |
| 282 if (tabId === testTab.id && info.status == 'complete') { |
| 283 doneListening(); |
| 284 } |
| 285 }); |
| 286 chrome.tabs.reload(testTab.id); |
| 287 }, |
| 288 |
| 278 // Tests that we get the disconnect event when the tab context closes. | 289 // Tests that we get the disconnect event when the tab context closes. |
| 279 function disconnectOnClose() { | 290 function disconnectOnClose() { |
| 291 listenOnce(chrome.runtime.onConnect, function(portFromTab) { |
| 292 listenOnce(portFromTab.onDisconnect, function() { |
| 293 chrome.test.assertNoLastError(); |
| 294 }); |
| 295 portFromTab.postMessage('unloadTabContent'); |
| 296 }); |
| 297 |
| 280 var port = chrome.tabs.connect(testTab.id); | 298 var port = chrome.tabs.connect(testTab.id); |
| 281 port.postMessage({testDisconnectOnClose: true}); | 299 port.postMessage({testDisconnectOnClose: true}); |
| 282 listenOnce(port.onDisconnect, function() { | 300 listenOnce(port.onDisconnect, function() { |
| 283 testTab = null; // the tab is about:blank now. | 301 testTab = null; // the tab is about:blank now. |
| 284 }); | 302 }); |
| 285 }, | 303 }, |
| 286 | 304 |
| 287 // Tests that the sendRequest API is disabled. | 305 // Tests that the sendRequest API is disabled. |
| 288 function sendRequest() { | 306 function sendRequest() { |
| 289 var error; | 307 var error; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 'It\'s possible that may be triggered flakily, but this ' + | 407 'It\'s possible that may be triggered flakily, but this ' + |
| 390 'really is a real failure, not flaky sadness. Promise!'); | 408 'really is a real failure, not flaky sadness. Promise!'); |
| 391 }; | 409 }; |
| 392 var release = chrome.test.callbackAdded(); | 410 var release = chrome.test.callbackAdded(); |
| 393 event.addListener(failListener); | 411 event.addListener(failListener); |
| 394 return function() { | 412 return function() { |
| 395 event.removeListener(failListener); | 413 event.removeListener(failListener); |
| 396 release(); | 414 release(); |
| 397 }; | 415 }; |
| 398 } | 416 } |
| OLD | NEW |