OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 chrome.runtime.onConnect.addListener(function(port) { |
| 6 var is_ready_to_crash = false; |
| 7 var succeed1 = chrome.test.callbackAdded(); |
| 8 var succeed2 = chrome.test.callbackAdded(); |
| 9 |
| 10 port.onMessage.addListener(function(msg) { |
| 11 chrome.test.assertEq('is_ready_to_crash', msg); |
| 12 is_ready_to_crash = true; |
| 13 chrome.test.sendMessage('ready_to_crash'); |
| 14 // Now the browser test should kill the tab, and the port should be closed. |
| 15 }); |
| 16 port.onDisconnect.addListener(function() { |
| 17 console.log('port.onDisconnect was triggered.'); |
| 18 chrome.test.assertTrue(is_ready_to_crash); |
| 19 succeed1(); |
| 20 }); |
| 21 |
| 22 chrome.tabs.sendMessage(port.sender.tab.id, 'Rob says hi', function() { |
| 23 console.log('tab.sendMessage\'s response callback was invoked'); |
| 24 chrome.test.assertNoLastError(); |
| 25 succeed2(); |
| 26 }); |
| 27 }); |
OLD | NEW |