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

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

Issue 2540783005: DO NOT COMMIT: Experimentation with ports
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | extensions/renderer/messaging_bindings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/messaging/background_only/test.js
diff --git a/chrome/test/data/extensions/api_test/messaging/background_only/test.js b/chrome/test/data/extensions/api_test/messaging/background_only/test.js
index de7cd9e3491737d626953f01d67c1911a9e7614c..b6ed602305409104cec398214f186d03e4396789 100644
--- a/chrome/test/data/extensions/api_test/messaging/background_only/test.js
+++ b/chrome/test/data/extensions/api_test/messaging/background_only/test.js
@@ -42,4 +42,58 @@ chrome.test.runTests([
chrome.runtime.connect({ name: 'The Last Port'}).onDisconnect.addListener(
chrome.test.callbackFail(kPortErrorMessage));
},
+
+ // Regression test for crbug.com/597698
+ function sendMessageNoCallback() {
+ var f = document.createElement('iframe');
+ var onMessageInFrame = chrome.test.callbackPass(function(msg) {
+ f.remove();
+ chrome.test.assertEq('sendMessage without callback', msg);
+ });
+ f.onload = function() {
+ f.contentWindow.chrome.runtime.onMessage.addListener(onMessageInFrame);
+ chrome.runtime.sendMessage('sendMessage without callback');
+ };
+
+ // The exact file is not important, as long as it is an extension page, so
+ // that the extension APIs become available (about:blank would not work).
+ f.src = 'manifest.json';
+ document.body.appendChild(f);
+ },
+
+ // Regression test for crbug.com/597698
+ function connectAndDisconnect() {
+ var gotMessage = chrome.test.callbackAdded();
+ var gotDisconnect = chrome.test.callbackAdded();
+
+ var senderPort;
+ var f = document.createElement('iframe');
+ f.onload = function() {
+ f.contentWindow.chrome.runtime.onConnect.addListener(function(port) {
+ chrome.test.assertEq('port with active frame', port.name);
+ chrome.test.assertEq(null, senderPort, 'onConnect should be async');
+ var didCallOnMessage = false;
+ port.onMessage.addListener(function(msg) {
+ chrome.test.assertEq(false, didCallOnMessage);
+ didCallOnMessage = true;
+ chrome.test.assertEq('fire and forget', msg);
+ gotMessage();
+ });
+ port.onDisconnect.addListener(function() {
+ f.remove();
+ gotDisconnect();
+ });
+ });
+
+ senderPort = chrome.runtime.connect({ name: 'port with active frame' });
+ senderPort.postMessage('fire and forget');
+ senderPort.disconnect();
+ senderPort = null;
+ };
+
+ // The exact file is not important, as long as it is an extension page, so
+ // that the extension APIs become available (about:blank would not work).
+ f.src = 'manifest.json';
+ document.body.appendChild(f);
+ },
]);
« no previous file with comments | « no previous file | extensions/renderer/messaging_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698