blob: f4140e66725982c4fe786b97cf2c3f862ef1571f [file] [log] [blame]
<!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() {
window.domAutomationController.send(
frame1Success && frame2Success && frame3Success &&
frame4Success && newWindow1Success && newWindow2Success);
}
</script>
</body>
</html>