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

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

Issue 1413853005: Track all extension frames in ProcessManager, inspect extensionoptions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/messaging/connect_nobackground/test.js
diff --git a/chrome/test/data/extensions/api_test/messaging/connect_nobackground/test.js b/chrome/test/data/extensions/api_test/messaging/connect_nobackground/test.js
new file mode 100644
index 0000000000000000000000000000000000000000..e91504e4f0879c9ab0ae13a62854fea7ec6d5050
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/messaging/connect_nobackground/test.js
@@ -0,0 +1,34 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
Devlin 2015/10/30 01:21:44 ditto
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+chrome.runtime.onConnect.addListener(function(port) {
+ var succeed1 = chrome.test.callbackAdded();
+ var succeed2 = chrome.test.callbackAdded();
+ var succeed3 = chrome.test.callbackAdded();
+
+ port.onMessage.addListener(function(msg) {
+ console.log('port.onMessage was triggered.');
Devlin 2015/10/30 01:21:43 nit: try to avoid noisy logs in tests. My general
robwu 2015/10/30 10:15:49 We have chrome.test.log, which causes messages to
Devlin 2015/10/30 16:03:51 Huh - thought that always logged. Apparently not.
+ chrome.test.assertEq('Hello from content script', msg);
+ succeed1();
+ });
Devlin 2015/10/30 01:21:43 nit: newline
+ port.onDisconnect.addListener(function() {
+ console.log('port.onDisconnect was triggered.');
+ succeed2();
+ });
+
+ chrome.tabs.sendMessage(port.sender.tab.id, '', function(reply) {
+ console.log('tab.sendMessage\'s response callback was invoked');
+ chrome.test.assertEq('Reply here', reply);
+ succeed3();
+ });
+});
+
+chrome.test.getConfig(function(config) {
+ var url = 'http://localhost:' + config.testServer.port +
+ '/extensions/test_file.html?will_test_connect_and_sendMessage';
Devlin 2015/10/30 01:21:44 nit: 4-space indent
+ // Content script will try to connect and trigger onConnect.
+ chrome.tabs.create({
+ url: url
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698