Index: chrome/test/data/extensions/api_test/bindings/frames_before_navigation.html |
diff --git a/chrome/test/data/extensions/api_test/bindings/frames_before_navigation.html b/chrome/test/data/extensions/api_test/bindings/frames_before_navigation.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8528b1d7a27c26e50e83c44ae6e3ad56a2731226 |
--- /dev/null |
+++ b/chrome/test/data/extensions/api_test/bindings/frames_before_navigation.html |
@@ -0,0 +1,77 @@ |
+<!doctype html> |
+<html> |
+<body> |
+<iframe id="frame1" src="chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/public.html"></iframe> |
+<iframe id="frame2" src="chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/nonexistent.html"></iframe> |
+<script> |
+ |
+// We expect that chrome.runtime.id will not be set in this frame, and that |
+// either chrome.runtime.sendMessage is not defined or we're able to call it |
+// (but elsewhere in the browser_test that uses this page we check that the |
+// message was not actually sent, or at least didn't incorrectly seem to come |
+// from the extension ficgdghpakbhhkmdjamiedmcoobamkoo). |
+function testFrame(win) { |
+ var haveId = true; |
+ var didRun = false; |
+ try { |
+ haveId = win.eval('typeof chrome.runtime != "undefined" && ' + |
+ 'typeof chrome.runtime.id != "undefined"'); |
+ win.eval('typeof chrome.runtime != "undefined" ' + |
+ '&& chrome.runtime.sendMessage(' + |
+ '"mlmdejkkkhmhchpmepehbcncoalclded", "evil")'); |
+ didRun = true; |
+ } catch (e) { |
+ console.log('caught exception: ' + e); |
+ } |
+ return didRun && !haveId; |
+} |
+ |
+// Test the two frames (actual page and nonexistent page) that were included in |
+// the original html document. |
+var frame1Success = testFrame(document.getElementById('frame1').contentWindow); |
+var frame2Success = testFrame(document.getElementById('frame2').contentWindow); |
+ |
+// Now test two frames that get dynamically created and added to the DOM, again |
+// one actual page and one nonexistent. |
+var frame3 = document.createElement('iframe'); |
+frame3.src = 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/public.html'; |
+document.body.appendChild(frame3); |
+var frame3Success = testFrame(frame3.contentWindow); |
+ |
+var frame4 = document.createElement('iframe'); |
+frame4.src = |
+ 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/nonexistent.html'; |
+document.body.appendChild(frame4); |
+var frame4Success = testFrame(frame4.contentWindow); |
+ |
+// Finally, test against two newly opened windows. |
+var newWin1 = window.open( |
+ 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/public.html'); |
+var newWindow1Success = testFrame(newWin1); |
+ |
+var newWin2 = window.open( |
+ 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/nonexistent.html'); |
+var newWindow2Success = testFrame(newWin2); |
+ |
+function getResult() { |
+ if (!frame1Success) |
+ console.log("frame1Success is false!"); |
+ if (!frame2Success) |
+ console.log("frame2Success is false!"); |
+ if (!frame3Success) |
+ console.log("frame3Success is false!"); |
+ if (!frame4Success) |
+ console.log("frame4Success is false!"); |
+ if (!newWindow1Success) |
+ console.log("newWindow1Success is false!"); |
+ if (!newWindow2Success) |
+ console.log("newWindow2Success is false!"); |
+ |
+ window.domAutomationController.send( |
+ frame1Success && frame2Success && frame3Success && |
+ frame4Success && newWindow1Success && newWindow2Success); |
+} |
+ |
+</script> |
+</body> |
+</html> |