Adding tests for bug 351633

This commit is contained in:
bzbarsky@mit.edu 2007-04-01 20:04:58 -07:00
parent b956494e3b
commit 88d1c40dc1
13 changed files with 375 additions and 0 deletions

View File

@ -86,5 +86,10 @@ ifdef BUILD_DEBUG_GC
DEFINES += -DDEBUG_GC
endif
DIRS = $(NULL)
ifdef MOZ_MOCHITEST
DIRS += test
endif
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,61 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2007
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/src/jsurl/test
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = pass.html \
fail.html \
test_bug351633-1.html \
form-submit.html \
test_bug351633-2.html \
load-stopping-1a.html \
load-stopping-1b.html \
load-stopping-1c.html \
load-stopping-1d.html \
test_bug351633-3.html \
test_bug351633-4.html \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<body>
<script>
parent.passJSUrl = false;
parent.finishTest();
</script>
</body>
</html>

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<head>
<script>
function test() {
var form = document.getElementById("test");
form.action = "pass.html";
form.submit();
}
</script>
<body>
<form id="test" action="javascript:test()">
<input type="submit" value="Submit the form; you should PASS when done">
</form>
</body>

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<head>
<script>
// location = 'javascript: "Test"';
</script>
</head>
<body>
<script>parent.passJSUrl1 = true;</script>
</body>

View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<head>
</head>
<body>
<script>parent.passJSUrl2 = true</script>
</body>

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<head>
<script>
location = 'javascript:void("Test")';
</script>
</head>
<body>
<script>parent.passJSUrl3 = true</script>
</body>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<head>
<script>
function foo() {
return "aaa";
}
</script>
</head>
<body>
<img src="javascript: foo()">
<script>parent.passJSUrl4 = true</script>
</body>

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<body>
<script>
parent.passJSUrl = true;
parent.finishTest();
</script>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=351633
-->
<head>
<title>Test for Bug 351633: Form submission</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=351633">Mozilla Bug 351633</a>
<p id="display">
<iframe id="frame" src="form-submit.html"></iframe>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 351633 **/
var passJSUrl = false;
function finishTest() {
is(passJSUrl, true, "Unexpected result");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
function runTest() {
$("frame").contentDocument.getElementById("test").submit();
}
addLoadEvent(runTest);
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=351633
-->
<head>
<title>Test for Bug 351633</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=351633">Mozilla Bug 351633</a>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 351633 **/
var passJSUrl1 = false;
var passJSUrl2 = false;
var passJSUrl3 = false;
var passJSUrl4 = false;
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
is(passJSUrl1, true, "Should have stopped load before getting here");
is(passJSUrl2, true, "Should not have stopped load where we didn't set " +
"location");
is(passJSUrl3, true, "Should not have stopped load where javascript: URI " +
"didn't return text");
is(passJSUrl4, true, "Should not have stopped load where javascript: URI " +
"wasn't set on the document itself");
SimpleTest.finish();
});
</script>
</pre>
<p id="display">
<iframe src="load-stopping-1a.html"></iframe>
<iframe src="load-stopping-1b.html"></iframe>
<iframe src="load-stopping-1c.html"></iframe>
<iframe src="load-stopping-1d.html"></iframe>
</p>
<div id="content" style="display: none">
</div>
</body>
</html>

View File

@ -0,0 +1,108 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=351633
-->
<head>
<title>Test for Bug 351633</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=351633">Mozilla Bug 351633</a>
<pre id="test">
<script class="testbody" type="text/javascript">
var passJSUrl;
var passJSUrl2;
var finishTest;
/** Test for Bug 351633 **/
function runTests() {
$("testframe1").onload = test1;
// test2 will be called as finishTest
$("testframe3").onload = test3;
$("testframe4").onload = test4;
$("testframe5").onload = test5;
passJSUrl = false;
window.testframe1.location.href =
'javascript:"<script>parent.passJSUrl = true</' + 'script>"'
}
function test1() {
is(passJSUrl, true, "Script should have run in child");
passJSUrl = false;
passJSUrl2 = true;
finishTest = test2;
window.testframe2.location.href =
'javascript: location = "pass.html"; ' +
'"<script>parent.passJSUrl2 = false</' + 'script>"'
}
function test2() {
is(passJSUrl, true, "pass.html should have loaded");
is(passJSUrl2, true, "<script> should not have run");
passJSUrl = true;
passJSUrl2 = false;
finishTest = function() { };
window.testframe3.location.href = 'fail.html';
window.testframe3.location.href =
'javascript: "<script>parent.passJSUrl2 = true</' + 'script>"'
}
function test3() {
is(passJSUrl, true, "fail.html should not have finished loading");
is(passJSUrl2, true, "<script> should have run");
passJSUrl = false;
passJSUrl2 = true;
finishTest = function() { };
window.testframe4.location.href = 'pass.html';
window.testframe4.location.href =
'javascript:void("<script>parent.passJSUrl2 = false</' + 'script>")';
}
function test4() {
is(passJSUrl, true, "pass.html should have loaded again");
is(passJSUrl2, true, "<script> should not have run in void");
passJSUrl = false;
passJSUrl2 = true;
finishTest = function() { };
window.testframe5.location.href =
'javascript:void("<script>parent.passJSUrl2 = false</' + 'script>")';
window.testframe5.location.href = 'pass.html';
}
function test5() {
is(passJSUrl, true, "pass.html should have loaded yet again");
is(passJSUrl2, true, "javascript: load should have been canceled");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(runTests);
</script>
</pre>
<p id="display">
<iframe name="testframe1" id="testframe1"></iframe>
<iframe name="testframe2" id="testframe2"></iframe>
<iframe name="testframe3" id="testframe3"></iframe>
<iframe name="testframe4" id="testframe4"></iframe>
<iframe name="testframe5" id="testframe5"></iframe>
</p>
<div id="content" style="display: none">
</div>
</body>
</html>

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=351633
-->
<head>
<title>Test for Bug 351633</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=351633">Mozilla Bug 351633</a>
<p id="display">
<iframe name="x" id="x"></iframe>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 351633 **/
var str;
str = "a";
window.x.location.href =
"javascript: parent.str += 'c'; void(parent.finishTest());"
str += "b";
SimpleTest.waitForExplicitFinish();
function finishTest() {
is (str, "abc", "Unexpected ordering");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>