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

Unified Diff: chrome/test/data/extensions/api_test/bindings/frames_before_navigation.html

Issue 2151693002: Fix extension bindings injection for iframes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use security origin, augmented tests, fix nits Created 4 years, 5 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/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..9d0a1569e459b0e9c1a92f5e6347f4ef1a46e24a
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bindings/frames_before_navigation.html
@@ -0,0 +1,63 @@
+<!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
Devlin 2016/07/21 00:44:54 Are some of these lines over 80 char? Or is that
asargent_no_longer_on_chrome 2016/07/21 18:12:22 Oops, it actually went to 81 chars. Fixed.
+// 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() {
+ window.domAutomationController.send(
+ frame1Success && frame2Success && frame3Success &&
+ frame4Success && newWindow1Success && newWindow2Success);
+}
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698