Bug 795317: Test case r=jlebar

This commit is contained in:
Patrick Wang 2012-10-16 19:59:04 +08:00
parent b2b09feb78
commit a0de7d3984
5 changed files with 113 additions and 0 deletions

View File

@ -139,6 +139,9 @@ MOCHITEST_FILES = \
file_browserElement_AppFramePermission.html \
browserElement_AppFramePermission.js \
test_browserElement_inproc_AppFramePermission.html \
file_wyciwyg.html \
browserElement_ExposableURI.js \
test_browserElement_inproc_ExposableURI.html \
$(NULL)
# Disabled due to https://bugzilla.mozilla.org/show_bug.cgi?id=774100
@ -201,6 +204,7 @@ MOCHITEST_FILES += \
test_browserElement_oop_RemoveBrowserElement.html \
test_browserElement_oop_DOMRequestError.html \
test_browserElement_oop_AppFramePermission.html \
test_browserElement_oop_ExposableURI.html \
$(NULL)
endif #}
endif #}

View File

@ -0,0 +1,57 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 795317: Test that the browser element sanitizes its URIs by removing the
// "unexposable" parts before sending them in the locationchange event.
"use strict";
SimpleTest.waitForExplicitFinish();
var iframe;
function testPassword() {
function locationchange(e) {
var uri = e.detail;
is(uri, 'http://mochi.test:8888/tests/dom/browser-element/mochitest/file_empty.html',
"Username and password shouldn't be exposed in uri.");
SimpleTest.finish();
}
iframe.addEventListener('mozbrowserlocationchange', locationchange);
iframe.src = "http://iamuser:iampassword@mochi.test:8888/tests/dom/browser-element/mochitest/file_empty.html";
}
function testWyciwyg() {
var locationChangeCount = 0;
function locationchange(e) {
// locationChangeCount:
// 0 - the first load.
// 1 - after document.write().
if (locationChangeCount == 0) {
locationChangeCount ++;
} else if (locationChangeCount == 1) {
var uri = e.detail;
is(uri, 'http://mochi.test:8888/tests/dom/browser-element/mochitest/file_wyciwyg.html', "Scheme in string shouldn't be wyciwyg");
iframe.removeEventListener('mozbrowserlocationchange', locationchange);
SimpleTest.executeSoon(testPassword);
}
}
// file_wyciwyg.html calls document.write() to create a wyciwyg channel.
iframe.src = 'file_wyciwyg.html';
iframe.addEventListener('mozbrowserlocationchange', locationchange);
}
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
iframe = document.createElement('iframe');
iframe.mozbrowser = true;
document.body.appendChild(iframe);
testWyciwyg();
}
addEventListener('load', function() { SimpleTest.executeSoon(runTest); });

View File

@ -0,0 +1,14 @@
<html>
<head>
<title>test</title>
<script type="text/javascript">
addEventListener('load', function() {
window.setTimeout(function() {
document.write("test");
}, 0);
});
</script>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795317
-->
<head>
<title>Test for Bug 795317</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>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795317">Mozilla Bug 795317</a>
<script type="application/javascript;version1.7" src="browserElement_ExposableURI.js"></script>
</body>
</html>

View File

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795317
-->
<head>
<title>Test for Bug 795317</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>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=795317">Mozilla Bug 795317</a>
<script type="application/javascript;version1.7" src="browserElement_ExposableURI.js"></script>
</body>
</html>