OLD | NEW |
---|---|
(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 | |
9 // either chrome.runtime.sendMessage is not defined or we're able to call it | |
10 // (but elsewhere in the browser_test that uses this page we check that the | |
11 // message was not actually sent, or at least didn't incorrectly seem to come | |
12 // from the 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 (' + | |
Devlin
2016/07/21 22:20:34
still over 80 char?
asargent_no_longer_on_chrome
2016/07/22 17:36:51
Argh, sorry. Done.
| |
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> | |
OLD | NEW |