Bug 769182 - Tests for cross-origin window.open calls in <iframe mozbrowser>. r=bz

This commit is contained in:
Justin Lebar 2012-07-23 13:47:34 -04:00
parent 1abc43da9a
commit 4342dc7793
5 changed files with 90 additions and 0 deletions

View File

@ -81,6 +81,9 @@ MOCHITEST_FILES = \
browserElement_OpenWindowRejected.js \
test_browserElement_inproc_OpenWindowRejected.html \
file_browserElement_OpenWindowRejected.html \
browserElement_OpenWindowDifferentOrigin.js \
test_browserElement_inproc_OpenWindowDifferentOrigin.html \
file_browserElement_OpenWindowDifferentOrigin.html \
browserElement_SecurityChange.js \
test_browserElement_inproc_SecurityChange.html \
file_browserElement_SecurityChange.html \
@ -130,6 +133,7 @@ MOCHITEST_FILES += \
test_browserElement_oop_OpenWindow.html \
test_browserElement_oop_OpenWindowInFrame.html \
test_browserElement_oop_OpenWindowRejected.html \
test_browserElement_oop_OpenWindowDifferentOrigin.html \
test_browserElement_oop_SecurityChange.html \
test_browserElement_oop_BackForward.html \
test_browserElement_oop_Reload.html \

View File

@ -0,0 +1,42 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 769182 - window.open to a different origin should load the page.
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addToWhitelist();
var iframe = document.createElement('iframe');
iframe.mozbrowser = true;
iframe.addEventListener('mozbrowseropenwindow', function(e) {
ok(true, 'Got first window.open call');
e.detail.frameElement.addEventListener('mozbrowseropenwindow', function(e) {
ok(true, 'Got second window.open call');
document.body.appendChild(e.detail.frameElement);
});
e.detail.frameElement.addEventListener('mozbrowsershowmodalprompt', function(e) {
ok(true, 'Got alert from second window.');
SimpleTest.finish();
});
document.body.appendChild(e.detail.frameElement);
});
// DifferentOrigin.html?1 calls
//
// window.open('http://example.com/.../DifferentOrigin.html?2'),
//
// which calls alert().
iframe.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_OpenWindowDifferentOrigin.html?1';
document.body.appendChild(iframe);
}
runTest();

View File

@ -0,0 +1,18 @@
<html>
<body>
<div id='name'></div>
<script>
if (location.search == "?1") {
open("http://example.com/tests/dom/browser-element/mochitest/file_browserElement_OpenWindowDifferentOrigin.html?2");
}
else if (location.search == "?2") {
alert("finish");
}
document.getElementById('name').innerHTML = location.search;
</script>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7" src="browserElement_OpenWindowDifferentOrigin.js">
</script>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7" src="browserElement_OpenWindowDifferentOrigin.js">
</script>
</body>
</html>