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

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

Issue 1413543005: Use FrameTreeNode ID as frameId in extension APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/:/ / 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 succeed1 = chrome.test.callbackAdded(); 7 var succeed1 = chrome.test.callbackAdded();
7 var succeed2 = chrome.test.callbackAdded(); 8 var succeed2 = chrome.test.callbackAdded();
8 var succeed3 = chrome.test.callbackAdded();
9 9
10 port.onMessage.addListener(function(msg) { 10 port.onMessage.addListener(function(msg) {
11 chrome.test.log('port.onMessage was triggered.'); 11 chrome.test.assertEq('is_ready_to_crash', msg);
12 chrome.test.assertEq('Hello from content script', 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 chrome.test.log('port.onDisconnect was triggered.');
18 chrome.test.assertTrue(is_ready_to_crash);
13 succeed1(); 19 succeed1();
14 }); 20 });
15 21
16 port.onDisconnect.addListener(function() { 22 chrome.tabs.sendMessage(port.sender.tab.id, 'Rob says hi', function() {
17 chrome.test.log('port.onDisconnect was triggered.'); 23 chrome.test.log('tab.sendMessage\'s response callback was invoked');
24 chrome.test.assertNoLastError();
18 succeed2(); 25 succeed2();
19 }); 26 });
20
21 chrome.tabs.sendMessage(port.sender.tab.id, 'msg from tab', function(reply) {
22 chrome.test.log('tab.sendMessage\'s response callback was invoked');
23 chrome.test.assertEq('Reply here', reply);
24 succeed3();
25 });
26 }); 27 });
27
28 chrome.test.getConfig(function(config) {
29 var url = 'http://localhost:' + config.testServer.port +
30 '/extensions/test_file.html?will_test_connect_and_sendMessage';
31 // Content script will try to connect and trigger onConnect.
32 chrome.tabs.create({
33 url: url
34 });
35 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698