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" ' + |
| 20 '&& chrome.runtime.sendMessage(' + |
| 21 '"mlmdejkkkhmhchpmepehbcncoalclded", "evil")'); |
| 22 didRun = true; |
| 23 } catch (e) { |
| 24 console.log('caught exception: ' + e); |
| 25 } |
| 26 return didRun && !haveId; |
| 27 } |
| 28 |
| 29 // Test the two frames (actual page and nonexistent page) that were included in |
| 30 // the original html document. |
| 31 var frame1Success = testFrame(document.getElementById('frame1').contentWindow); |
| 32 var frame2Success = testFrame(document.getElementById('frame2').contentWindow); |
| 33 |
| 34 // Now test two frames that get dynamically created and added to the DOM, again |
| 35 // one actual page and one nonexistent. |
| 36 var frame3 = document.createElement('iframe'); |
| 37 frame3.src = 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/public.html'; |
| 38 document.body.appendChild(frame3); |
| 39 var frame3Success = testFrame(frame3.contentWindow); |
| 40 |
| 41 var frame4 = document.createElement('iframe'); |
| 42 frame4.src = |
| 43 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/nonexistent.html'; |
| 44 document.body.appendChild(frame4); |
| 45 var frame4Success = testFrame(frame4.contentWindow); |
| 46 |
| 47 // Finally, test against two newly opened windows. |
| 48 var newWin1 = window.open( |
| 49 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/public.html'); |
| 50 var newWindow1Success = testFrame(newWin1); |
| 51 |
| 52 var newWin2 = window.open( |
| 53 'chrome-extension://ficgdghpakbhhkmdjamiedmcoobamkoo/nonexistent.html'); |
| 54 var newWindow2Success = testFrame(newWin2); |
| 55 |
| 56 function getResult() { |
| 57 if (!frame1Success) |
| 58 console.log("frame1Success is false!"); |
| 59 if (!frame2Success) |
| 60 console.log("frame2Success is false!"); |
| 61 if (!frame3Success) |
| 62 console.log("frame3Success is false!"); |
| 63 if (!frame4Success) |
| 64 console.log("frame4Success is false!"); |
| 65 if (!newWindow1Success) |
| 66 console.log("newWindow1Success is false!"); |
| 67 if (!newWindow2Success) |
| 68 console.log("newWindow2Success is false!"); |
| 69 |
| 70 window.domAutomationController.send( |
| 71 frame1Success && frame2Success && frame3Success && |
| 72 frame4Success && newWindow1Success && newWindow2Success); |
| 73 } |
| 74 |
| 75 </script> |
| 76 </body> |
| 77 </html> |
OLD | NEW |