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..16b0355083fb25d44044be658d6f22df7420cd3e 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,43 @@ chrome.test.getConfig(function(config) { |
chrome.test.log("sendMessageFromTab: sent first message to tab"); |
}, |
+ // Tests that a message from a child frame has a correct frameId. |
+ function sendMessageFromFrameInTab() { |
+ listenOnce( |
+ chrome.runtime.onMessage, |
+ function(request, sender, sendResponse) { |
+ chrome.test.log("sendMessageFromFrameInTab: got frameId " + |
+ sender.frameId); |
+ // Child frames have a positive frameId. |
+ chrome.test.assertTrue(sender.frameId >= 1); |
+ delete sender.frameId; |
not at google - send to devlin
2014/11/11 00:03:04
Rather than deleting the frameId like this it woul
robwu
2014/11/11 00:34:26
I'll be checking frameId / URL below.
|
+ chrome.test.assertEq({ |
+ tab: testTab, |
+ url: request.frameUrl, |
+ id: chrome.runtime.id |
+ }, sender); |
+ |
+ // Now test whether the frameId that we got back makes sense... |
+ chrome.webNavigation.getAllFrames({ |
+ tabId: testTab.id |
+ }, chrome.test.callback(function(details) { |
+ var frames = details.filter(function(frame) { |
+ return frame.frameId === sender.frameId; |
not at google - send to devlin
2014/11/11 00:03:04
Hasn't sender.frameId been deleted at this point?
robwu
2014/11/11 00:34:26
Done.
|
+ }); |
+ // If |frames.length| is zero, then the frameId was bogus. |
+ // If it is higher than one, then the webNavigation API is broken. |
+ chrome.test.assertEq(frames.length, 1); |
+ chrome.test.assertEq(frames[0].url, request.frameUrl); |
+ })); |
+ } |
+ ); |
+ |
+ var port = chrome.tabs.connect(testTab.id); |
+ port.postMessage({testSendMessageFromFrame: true}); |
+ port.disconnect(); |
+ chrome.test.log("sendMessageFromFrameInTab: send 1st message to tab"); |
+ }, |
+ |
// Tests error handling when sending a request from a content script to an |
// invalid extension. |
function sendMessageFromTabError() { |