Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/messaging/connect_crash/test.js |
| diff --git a/chrome/test/data/extensions/api_test/messaging/connect_crash/test.js b/chrome/test/data/extensions/api_test/messaging/connect_crash/test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1914783b5401ec6122fedd28ca3185f583e29ee3 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/messaging/connect_crash/test.js |
| @@ -0,0 +1,27 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +chrome.runtime.onConnect.addListener(function(port) { |
| + var is_ready_to_crash = false; |
| + var succeed1 = chrome.test.callbackAdded(); |
| + var succeed2 = chrome.test.callbackAdded(); |
| + |
| + port.onMessage.addListener(function(msg) { |
| + chrome.test.assertEq('is_ready_to_crash', msg); |
| + is_ready_to_crash = true; |
| + chrome.test.sendMessage('ready_to_crash'); |
| + // Now the browser test should kill the tab, and the port should be closed. |
| + }); |
| + port.onDisconnect.addListener(function() { |
| + console.log('port.onDisconnect was triggered.'); |
|
Devlin
2015/12/10 21:53:06
chrome.test.log
robwu
2015/12/11 00:53:47
Done.
|
| + chrome.test.assertTrue(is_ready_to_crash); |
| + succeed1(); |
| + }); |
| + |
| + chrome.tabs.sendMessage(port.sender.tab.id, 'Rob says hi', function() { |
| + console.log('tab.sendMessage\'s response callback was invoked'); |
| + chrome.test.assertNoLastError(); |
| + succeed2(); |
| + }); |
| +}); |