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

Unified Diff: chrome/test/data/extensions/api_test/bindings/external_message_listener/background.js

Issue 2208483002: Fix extension bindings injection for iframes (reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed review comments, fixed lint Created 4 years, 4 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/bindings/external_message_listener/background.js
diff --git a/chrome/test/data/extensions/api_test/bindings/external_message_listener/background.js b/chrome/test/data/extensions/api_test/bindings/external_message_listener/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..b5dce1a7af70ffca58036d0f7f64c5721e83245f
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bindings/external_message_listener/background.js
@@ -0,0 +1,32 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var messagesReceived = [];
+
+// Have we received the real message from the sender extension?
+var receivedRealSenderMessage = false;
+
+// Has the c++ code in the browser test asked us for the total count of messages
+// we've received?
+var sendCountAfterSenderMessage = false;
+
+function getMessageCountAfterReceivingRealSenderMessage() {
+ if (receivedRealSenderMessage) {
+ window.domAutomationController.send(messagesReceived.length);
+ } else {
+ sendCountAfterSenderMessage = true;
+ }
+}
+
+chrome.runtime.onMessageExternal.addListener(function(msg, sender, respond) {
+ messagesReceived.push({msg:msg, sender:sender});
+ if (msg == 'from_sender') {
+ receivedRealSenderMessage = true;
+ if (sendCountAfterSenderMessage) {
+ window.domAutomationController.send(messagesReceived.length);
+ }
+ }
+});
+
+chrome.test.sendMessage('receiver_ready');

Powered by Google App Engine
This is Rietveld 408576698