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

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

Issue 709933002: Add frameId to MessageSender (extension messaging API) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test that tests for a non-negative frameId Created 6 years, 1 month 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/test.js
diff --git a/chrome/test/data/extensions/api_test/messaging/connect/test.js b/chrome/test/data/extensions/api_test/messaging/connect/test.js
index d76997fd34bccc78feb735d7c6a85a1ca5f24eed..6dff62ac951810c1e9f084c4cdbc437d77195af4 100644
--- a/chrome/test/data/extensions/api_test/messaging/connect/test.js
+++ b/chrome/test/data/extensions/api_test/messaging/connect/test.js
@@ -70,6 +70,7 @@ chrome.test.getConfig(function(config) {
listenOnce(chrome.runtime.onConnect, function(port) {
chrome.test.assertEq({
tab: testTab,
+ frameId: 0, // Main frame
url: testTab.url,
id: chrome.runtime.id
}, port.sender);
@@ -95,6 +96,7 @@ chrome.test.getConfig(function(config) {
function(request, sender, sendResponse) {
chrome.test.assertEq({
tab: testTab,
+ frameId: 0, // Main frame
url: testTab.url,
id: chrome.runtime.id
}, sender);
@@ -116,6 +118,29 @@ chrome.test.getConfig(function(config) {
chrome.test.log("sendMessageFromTab: sent first message to tab");
},
+ // Tests that a message from a child frame has a non-negative frameId.
+ function sendMessageFromFrameInTab() {
+ listenOnce(
+ chrome.runtime.onMessage,
+ function(request, sender, sendResponse) {
+ chrome.test.log("sendMessageFromFrameInTab: got frameId " +
not at google - send to devlin 2014/11/10 18:36:42 Remove logging before submitting.
robwu 2014/11/10 21:43:07 Other tests in this file also log this information
not at google - send to devlin 2014/11/11 00:24:03 Oh right, and I meant to respond to this. I agree
robwu 2014/11/11 00:34:26 So, what should this be? - Removed? - if (...) tes
not at google - send to devlin 2014/11/11 00:37:08 Like, chrome.test.assertTrue(sender.frameId >= 1,
robwu 2014/11/11 00:41:03 Done.
+ sender.frameId);
+ chrome.test.assertTrue(sender.frameId >= 1);
not at google - send to devlin 2014/11/10 18:36:42 Add comment like "frameId of 0 means the main fram
robwu 2014/11/10 21:43:07 Done.
+ delete sender.frameId;
+ chrome.test.assertEq({
+ tab: testTab,
+ url: request.frameUrl,
+ id: chrome.runtime.id
+ }, sender);
+ }
+ );
+
+ var port = chrome.tabs.connect(testTab.id);
+ port.postMessage({testSendMessageFromFrame: true});
+ port.disconnect();
+ chrome.test.log("sendMessageFromFrameInTab: send 1st message to tab");
not at google - send to devlin 2014/11/10 18:36:42 Remove logging before submitting.
robwu 2014/11/10 21:43:07 Same note as before: This file is full of chrome.t
+ },
+
// Tests error handling when sending a request from a content script to an
// invalid extension.
function sendMessageFromTabError() {

Powered by Google App Engine
This is Rietveld 408576698