Bug 780351 - Tests for ensuring that mozapp divides the window name namespace, but mozbrowser does not. r=smaug

This commit is contained in:
Justin Lebar 2012-08-13 15:19:09 -04:00
parent f6aa7b548f
commit d50beacc82
9 changed files with 172 additions and 0 deletions

View File

@ -33,6 +33,12 @@ MOCHITEST_FILES = \
test_browserElement_inproc_Titlechange.html \
browserElement_TopBarrier.js \
test_browserElement_inproc_TopBarrier.html \
browserElement_AppWindowNamespace.js \
test_browserElement_inproc_AppWindowNamespace.html \
file_browserElement_AppWindowNamespace.html \
browserElement_BrowserWindowNamespace.js \
test_browserElement_inproc_BrowserWindowNamespace.html \
file_browserElement_BrowserWindowNamespace.html \
browserElement_Iconchange.js \
test_browserElement_inproc_Iconchange.html \
browserElement_GetScreenshot.js \
@ -122,6 +128,8 @@ MOCHITEST_FILES += \
test_browserElement_oop_DataURI.html \
test_browserElement_oop_ErrorSecurity.html \
test_browserElement_oop_Titlechange.html \
test_browserElement_oop_AppWindowNamespace.html \
test_browserElement_oop_BrowserWindowNamespace.html \
test_browserElement_oop_TopBarrier.html \
test_browserElement_oop_Iconchange.html \
test_browserElement_oop_GetScreenshot.html \

View File

@ -0,0 +1,44 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 780351 - Test that mozapp divides the window name namespace.
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addToWhitelist();
var iframe1 = document.createElement('iframe');
iframe1.mozbrowser = true;
iframe1.setAttribute('mozapp', 'http://example.org/manifest.webapp');
// Two mozapp frames for different apps with the same code both do the same
// window.open("foo", "bar") call. We should get two mozbrowseropenwindow
// events.
iframe1.addEventListener('mozbrowseropenwindow', function(e) {
ok(true, "Got first mozbrowseropenwindow event.");
document.body.appendChild(e.detail.frameElement);
SimpleTest.executeSoon(function() {
var iframe2 = document.createElement('iframe');
iframe2.mozbrowser = true;
iframe2.setAttribute('mozapp', 'http://example.com/manifest.webapp');
iframe2.addEventListener('mozbrowseropenwindow', function(e) {
ok(true, "Got second mozbrowseropenwindow event.");
SimpleTest.finish();
});
document.body.appendChild(iframe2);
iframe2.src = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html';
});
});
document.body.appendChild(iframe1);
iframe1.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html';
}
runTest();

View File

@ -0,0 +1,54 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 780351 - Test that mozbrowser does /not/ divide the window name namespace.
// Multiple mozbrowsers inside the same app are like multiple browser tabs;
// they share a window name namespace.
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addToWhitelist();
var iframe1 = document.createElement('iframe');
iframe1.mozbrowser = true;
// Two mozbrowser frames with the same code both do the same
// window.open("foo", "bar") call. We should only get one
// mozbrowseropenwindow event.
iframe1.addEventListener('mozbrowseropenwindow', function(e) {
ok(true, "Got first mozbrowseropenwindow event.");
document.body.appendChild(e.detail.frameElement);
e.detail.frameElement.addEventListener('mozbrowserlocationchange', function(e) {
if (e.detail == "http://example.com/#2") {
ok(true, "Got locationchange to http://example.com/#2");
SimpleTest.finish();
}
else {
ok(true, "Got locationchange to " + e.detail);
}
});
SimpleTest.executeSoon(function() {
var iframe2 = document.createElement('iframe');
iframe2.mozbrowser = true;
iframe2.addEventListener('mozbrowseropenwindow', function(e) {
ok(false, "Got second mozbrowseropenwindow event.");
});
document.body.appendChild(iframe2);
iframe2.src = 'file_browserElement_BrowserWindowNamespace.html#2';
});
});
document.body.appendChild(iframe1);
iframe1.src = 'file_browserElement_BrowserWindowNamespace.html#1';
}
runTest();

View File

@ -0,0 +1,7 @@
<html>
<body>
<script>
window.open("http://example.com", "foo");
</script>
</body>
</html>

View File

@ -0,0 +1,7 @@
<html>
<body>
<script>
window.open("http://example.com/" + location.hash, "foo");
</script>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 780351</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_AppWindowNamespace.js">
</script>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 780351</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_BrowserWindowNamespace.js">
</script>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 780351</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_AppWindowNamespace.js">
</script>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bug 780351</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_BrowserWindowNamespace.js">
</script>
</body>
</html>