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

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

Issue 2529213002: Delete TODO-comment about guest process/frame IDs in MessageService::OpenChannelImpl (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 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 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 kPortErrorMessage = 5 var kPortErrorMessage =
6 'Could not establish connection. Receiving end does not exist.'; 6 'Could not establish connection. Receiving end does not exist.';
7 7
8 // onMessage / onConnect in the same frame cannot be triggered by sendMessage or 8 // onMessage / onConnect in the same frame cannot be triggered by sendMessage or
9 // connect, so both attempts to send a message should fail with an error. 9 // connect, so both attempts to send a message should fail with an error.
10 10
(...skipping 24 matching lines...) Expand all
35 function connectAndDisconnect() { 35 function connectAndDisconnect() {
36 chrome.runtime.connect({ name: 'The First Port'}).disconnect(); 36 chrome.runtime.connect({ name: 'The First Port'}).disconnect();
37 // Like sendMessageExpectingNoAnswer; onConnect should not be triggered. 37 // Like sendMessageExpectingNoAnswer; onConnect should not be triggered.
38 setTimeout(chrome.test.callbackPass(), 100); 38 setTimeout(chrome.test.callbackPass(), 100);
39 }, 39 },
40 40
41 function connectExpectDisconnect() { 41 function connectExpectDisconnect() {
42 chrome.runtime.connect({ name: 'The Last Port'}).onDisconnect.addListener( 42 chrome.runtime.connect({ name: 'The Last Port'}).onDisconnect.addListener(
43 chrome.test.callbackFail(kPortErrorMessage)); 43 chrome.test.callbackFail(kPortErrorMessage));
44 }, 44 },
45
46 // Regression test for crbug.com/597698
47 function sendMessageNoCallback() {
48 var f = document.createElement('iframe');
49 var onMessageInFrame = chrome.test.callbackPass(function(msg) {
50 f.remove();
51 chrome.test.assertEq('sendMessage without callback', msg);
52 });
53 f.onload = function() {
54 f.contentWindow.chrome.runtime.onMessage.addListener(onMessageInFrame);
55 chrome.runtime.sendMessage('sendMessage without callback');
56 };
57
58 // The exact file is not important, as long as it is an extension page, so
59 // that the extension APIs become available (about:blank would not work).
60 f.src = 'manifest.json';
61 document.body.appendChild(f);
62 },
63
64 // Regression test for crbug.com/597698
65 function connectAndDisconnect() {
66 var gotMessage = chrome.test.callbackAdded();
67 var gotDisconnect = chrome.test.callbackAdded();
68
69 var senderPort;
70 var f = document.createElement('iframe');
71 f.onload = function() {
72 f.contentWindow.chrome.runtime.onConnect.addListener(function(port) {
73 chrome.test.assertEq('port with active frame', port.name);
74 chrome.test.assertEq(null, senderPort, 'onConnect should be async');
75 var didCallOnMessage = false;
76 port.onMessage.addListener(function(msg) {
77 chrome.test.assertEq(false, didCallOnMessage);
78 didCallOnMessage = true;
79 chrome.test.assertEq('fire and forget', msg);
80 gotMessage();
81 });
82 port.onDisconnect.addListener(function() {
83 f.remove();
84 gotDisconnect();
85 });
86 });
87
88 senderPort = chrome.runtime.connect({ name: 'port with active frame' });
89 senderPort.postMessage('fire and forget');
90 senderPort.disconnect();
91 senderPort = null;
92 };
93
94 // The exact file is not important, as long as it is an extension page, so
95 // that the extension APIs become available (about:blank would not work).
96 f.src = 'manifest.json';
97 document.body.appendChild(f);
98 },
45 ]); 99 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698