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

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

Issue 1629013002: Allow a main interstitial frame to act as an ExtensionMessagePort opener (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extension-message-port-onDisconnect-580882
Patch Set: Remove trailing space 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
(Empty)
1 // Copyright 2016 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 var testPort = chrome.runtime.connect({
6 name: 'port from interstitial'
7 });
8
9 var currentTest;
10 testPort.onMessage.addListener(function(msg) {
11 console.assert(!currentTest, 'Should only run one test at a time');
12 currentTest = msg;
13
14 if (msg === 'testSendMessage') {
15 testSendMessage();
16 } else if (msg === 'testDisconnectByBackground') {
17 testDisconnectByBackground();
18 } else if (msg === 'testDisconnectByInterstitial') {
19 testDisconnectByInterstitial();
20 } else {
21 done('Unexpected test: ' + msg);
22 }
23 });
24
25 function done(test) {
26 console.assert(test === currentTest, 'test name should match current test');
27 currentTest = null;
28 testPort.postMessage(test);
29 }
30
31 function testSendMessage() {
32 chrome.runtime.sendMessage('First from interstitial', function(msg) {
33 chrome.runtime.sendMessage('interstitial received: ' + msg);
34 done('testSendMessage');
35 });
36 }
37
38 function testDisconnectByBackground() {
39 var port = chrome.runtime.connect({
40 name: 'disconnect by background'
41 });
42 port.onDisconnect.addListener(function() {
43 done('testDisconnectByBackground');
44 });
45 }
46
47 function testDisconnectByInterstitial() {
48 var port = chrome.runtime.connect({
49 name: 'disconnect by interstitial'
50 });
51 port.disconnect();
52 done('testDisconnectByInterstitial');
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698