Bug 766871 - Part 2: Tests for window.open from <iframe> inside <iframe mozbrowser>. r=bz

--HG--
extra : rebase_source : 2c5f56098a9351f255c2fff07335c0de524a29f8
This commit is contained in:
Justin Lebar 2012-06-23 11:05:12 -04:00
parent bbca3c71aa
commit c26da70420
5 changed files with 102 additions and 0 deletions

View File

@ -56,6 +56,9 @@ _TEST_FILES = \
test_browserElement_inproc_OpenWindow.html \ test_browserElement_inproc_OpenWindow.html \
file_browserElement_Open1.html \ file_browserElement_Open1.html \
file_browserElement_Open2.html \ file_browserElement_Open2.html \
browserElement_OpenWindowInFrame.js \
test_browserElement_inproc_OpenWindowInFrame.html \
file_browserElement_OpenWindowInFrame.html \
browserElement_OpenWindowRejected.js \ browserElement_OpenWindowRejected.js \
test_browserElement_inproc_OpenWindowRejected.html \ test_browserElement_inproc_OpenWindowRejected.html \
file_browserElement_OpenWindowRejected.html \ file_browserElement_OpenWindowRejected.html \
@ -84,6 +87,7 @@ _TEST_FILES += \
test_browserElement_oop_PromptConfirm.html \ test_browserElement_oop_PromptConfirm.html \
test_browserElement_oop_Close.html \ test_browserElement_oop_Close.html \
test_browserElement_oop_OpenWindow.html \ test_browserElement_oop_OpenWindow.html \
test_browserElement_oop_OpenWindowInFrame.html \
test_browserElement_oop_OpenWindowRejected.html \ test_browserElement_oop_OpenWindowRejected.html \
test_browserElement_oop_SecurityChange.html \ test_browserElement_oop_SecurityChange.html \
test_browserElement_oop_BackForward.html \ test_browserElement_oop_BackForward.html \

View File

@ -0,0 +1,66 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 766871 - Test that window.open works from an <iframe> within <iframe mozbrowser>.
//
// This is basically the same as browserElement_OpenWindow, except that instead
// of loading file_browserElement_Open1.html directly inside the <iframe
// mozbrowser>, we load file_browserElement_OpenWindowInFrame.html into the
// mozbrowser. OpenWindowInFrame loads file_browserElement_Open1.html inside
// an iframe.
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addToWhitelist();
var iframe = document.createElement('iframe');
iframe.mozbrowser = true;
var gotPopup = false;
iframe.addEventListener('mozbrowseropenwindow', function(e) {
is(gotPopup, false, 'Should get just one popup.');
gotPopup = true;
document.body.appendChild(e.detail.frameElement);
ok(/file_browserElement_Open2\.html$/.test(e.detail.url),
"Popup's URL (got " + e.detail.url + ")");
is(e.detail.name, "name");
is(e.detail.features, "features");
});
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
ok(gotPopup, 'Got mozbrowseropenwindow event before showmodalprompt event.');
if (e.detail.message.indexOf("success:") == 0) {
ok(true, e.detail.message);
}
else if (e.detail.message.indexOf("failure:") == 0) {
ok(false, e.detail.message);
}
else if (e.detail.message == "finish") {
SimpleTest.finish();
}
else {
ok(false, "Got invalid message: " + e.detail.message);
}
});
/**
* file_browserElement_OpenWindowInFrame.html loads
* file_browserElement_Open1.html in an iframe. Open1.html does
*
* window.open('file_browserElement_Open2.html', 'name', 'features')
*
* then adds an event listener to the opened window and waits for onload.
*
* Onload, we fire a few alerts saying "success:REASON" or "failure:REASON".
* Finally, we fire a "finish" alert, which ends the test.
*/
iframe.src = 'file_browserElement_OpenWindowInFrame.html';
document.body.appendChild(iframe);
}
runTest();

View File

@ -0,0 +1,6 @@
<html>
<body>
I'm file_browserElement_OpenInFrame.html.
<iframe src='file_browserElement_Open1.html'></iframe>
</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_OpenWindowInFrame.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_OpenWindowInFrame.js">
</script>
</body>
</html>