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

Side by Side Diff: chrome/test/data/extensions/api_test/messaging/connect_crash/page.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 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 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698