OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 port = chrome.runtime.connect(); | 5 var port = chrome.runtime.connect(); |
6 port.onDisconnect.addListener(function() { | 6 port.onDisconnect.addListener(function() { |
7 chrome.test.fail('onDisconnect should not be triggered because the ' + | 7 chrome.test.fail('onDisconnect should not be triggered because the ' + |
8 'background page exists and the tab should have been crashed'); | 8 'background page exists and the tab should have been crashed'); |
9 }); | 9 }); |
10 | 10 |
11 var ref; | 11 var ref; |
12 chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) { | 12 chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) { |
13 chrome.test.assertEq('Rob says hi', msg); | 13 chrome.test.assertEq('Rob says hi', msg); |
14 port.postMessage('is_ready_to_crash'); | 14 port.postMessage('is_ready_to_crash'); |
15 // Keep the callback around to avoid test flakiness due to GC. | 15 // Keep the callback around to avoid test flakiness due to GC. |
16 ref = sendResponse; | 16 ref = sendResponse; |
17 | 17 |
18 // TODO(robwu): Remove the following line once crbug.com/439780 is fixed. | |
19 // (the response callback is not automatically invoked when the tab crashes). | |
20 sendResponse(); | |
21 | |
22 // Keep the port open - do not send a response. | 18 // Keep the port open - do not send a response. |
23 return true; | 19 return true; |
24 }); | 20 }); |
OLD | NEW |