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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <body>
4 <iframe id="frame1" src="chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/pub lic.html"></iframe>
5 <iframe id="frame2" src="chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/non existent.html"></iframe>
6 <script>
7
8 // We expect that chrome.runtime.id will not be set in this frame, and that eith er
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.
9 // chrome.runtime.sendMessage is not defined or we're able to call it (but
10 // elsewhere in the browser_test that uses this page we check that the message
11 // was not actually sent, or at least didn't incorrectly seem to come from the
12 // extension ficgdghpakbhhkmdjamiedmcoobamkoo).
13 function testFrame(win) {
14 var haveId = true;
15 var didRun = false;
16 try {
17 haveId = win.eval('typeof chrome.runtime != "undefined" && ' +
18 'typeof chrome.runtime.id != "undefined"');
19 win.eval('typeof chrome.runtime != "undefined" && chrome.runtime.sendMessage (' +
20 '"mlmdejkkkhmhchpmepehbcncoalclded", "evil")');
21 didRun = true;
22 } catch (e) {
23 console.log('caught exception: ' + e);
24 }
25 return didRun && !haveId;
26 }
27
28 // Test the two frames (actual page and nonexistent page) that were included in
29 // the original html document.
30 var frame1Success = testFrame(document.getElementById('frame1').contentWindow);
31 var frame2Success = testFrame(document.getElementById('frame2').contentWindow);
32
33 // Now test two frames that get dynamically created and added to the DOM, again
34 // one actual page and one nonexistent.
35 var frame3 = document.createElement('iframe');
36 frame3.src = 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/public.html';
37 document.body.appendChild(frame3);
38 var frame3Success = testFrame(frame3.contentWindow);
39
40 var frame4 = document.createElement('iframe');
41 frame4.src =
42 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/nonexistent.html';
43 document.body.appendChild(frame4);
44 var frame4Success = testFrame(frame4.contentWindow);
45
46 // Finally, test against two newly opened windows.
47 var newWin1 = window.open(
48 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/public.html');
49 var newWindow1Success = testFrame(newWin1);
50
51 var newWin2 = window.open(
52 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/nonexistent.html');
53 var newWindow2Success = testFrame(newWin2);
54
55 function getResult() {
56 window.domAutomationController.send(
57 frame1Success && frame2Success && frame3Success &&
58 frame4Success && newWindow1Success && newWindow2Success);
59 }
60
61 </script>
62 </body>
63 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698