Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: chrome/test/data/extensions/api_test/messaging/connect_crash/test.js

Issue 1567423002: Ensure that sendMessage's callback is called. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify intent Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 chrome.runtime.onConnect.addListener(function(port) { 5 chrome.runtime.onConnect.addListener(function(port) {
6 var is_ready_to_crash = false; 6 var is_ready_to_crash = false;
7 var succeed1 = chrome.test.callbackAdded(); 7 var succeed1 = chrome.test.callbackAdded();
8 var succeed2 = chrome.test.callbackAdded(); 8 var succeed2 = chrome.test.callbackAdded();
9 9
10 port.onMessage.addListener(function(msg) { 10 port.onMessage.addListener(function(msg) {
11 chrome.test.assertEq('is_ready_to_crash', msg); 11 chrome.test.assertEq('is_ready_to_crash', msg);
12 is_ready_to_crash = true; 12 is_ready_to_crash = true;
13 chrome.test.sendMessage('ready_to_crash'); 13 chrome.test.sendMessage('ready_to_crash');
14 // Now the browser test should kill the tab, and the port should be closed. 14 // Now the browser test should kill the tab, and the port should be closed.
15 }); 15 });
16 port.onDisconnect.addListener(function() { 16 port.onDisconnect.addListener(function() {
17 chrome.test.log('port.onDisconnect was triggered.'); 17 chrome.test.log('port.onDisconnect was triggered.');
18 chrome.test.assertTrue(is_ready_to_crash); 18 chrome.test.assertTrue(is_ready_to_crash);
19 succeed1(); 19 succeed1();
20 }); 20 });
21 21
22 chrome.tabs.sendMessage(port.sender.tab.id, 'Rob says hi', function() { 22 chrome.tabs.sendMessage(port.sender.tab.id, 'Rob says hi', function() {
23 chrome.test.log('tab.sendMessage\'s response callback was invoked'); 23 chrome.test.log('tab.sendMessage\'s response callback was invoked');
24 chrome.test.assertNoLastError(); 24 chrome.test.assertLastError(
25 'The message port closed before a reponse was received.');
25 succeed2(); 26 succeed2();
26 }); 27 });
27 }); 28 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698