Bug 647323 - Part d: Import tests Mozilla contributed to the HTML WG test suite; r=jhammel

This commit is contained in:
Ms2ger 2012-03-29 23:09:00 +02:00
parent 821597c580
commit 5d6fdd311e
14 changed files with 263 additions and 0 deletions

View File

@ -11,6 +11,7 @@ relativesrcdir = dom/tests/mochitest/w3c
DIRS = \
$(NULL)
include $(srcdir)/html.mk
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1 @@
html

View File

@ -0,0 +1,2 @@
{
}

View File

@ -0,0 +1,3 @@
DIRS += \
html/tests/submission/Mozilla \
$(NULL)

View File

@ -0,0 +1,2 @@
https://dvcs.w3.org/hg/html|html
tests/submission/Mozilla

View File

@ -0,0 +1,31 @@
# THIS FILE IS AUTOGENERATED - DO NOT EDIT
DEPTH = ../../../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = dom/tests/mochitest/w3c/html/tests/submission/Mozilla
DIRS = \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TESTS = \
test_body-onload.html \
test_pageload-image.html \
test_pageload-video.html \
test_script-for-onload.html \
test_window-onerror-parse-error.html \
test_window-onerror-runtime-error.html \
test_window-onerror-runtime-error-throw.html \
$(NULL)
_TESTS += \
nested-document-write-external.js \
$(NULL)
libs:: $(_TESTS)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

View File

@ -0,0 +1 @@
document.write("w"); document.write("o");

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<title>HTMLBodyElement.onload</title>
<link rel="author" title="Boris Zbarsky" href="mailto:bzbarsky@mit.edu">
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="http://www.whatwg.org/html/#handler-window-onload">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t = async_test("body.onload should set the window.onload handler")
window.onload = t.step_func(function() {
assert_unreached("This handler should be overwritten.")
})
var b = document.createElement("body")
b.onload = t.step_func(function(e) {
assert_equals(e.currentTarget, window,
"The event should be fired at the window.")
t.done()
})
</script>

View File

@ -0,0 +1,30 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Media documents: image</title>
<link rel="author" title="Michael Ventnor" href="mailto:mventnor@mozilla.com">
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="http://www.whatwg.org/html/#read-media">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test("The document for a standalone media file should have one child in the body.");
function frameLoaded() {
var testframe = document.getElementById('testframe');
var testframeChildren = testframe.contentDocument.body.childNodes;
assert_equals(testframeChildren.length, 1, "Body of image document has 1 child");
assert_equals(testframeChildren[0].nodeName, "IMG", "Only child of body must be an <img> element");
assert_equals(testframeChildren[0].namespaceURI, "http://www.w3.org/1999/xhtml",
"Only child of body must be an HTML element");
t.done();
}
</script>
</head>
<body>
<div id="log"></div>
<iframe id="testframe" onload="t.step(frameLoaded)"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oMFgQGMyFwHucAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAADElEQVQI12P4//8/AAX+Av7czFnnAAAAAElFTkSuQmCC"></iframe>
</body>
</html>

View File

@ -0,0 +1,30 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Media documents: video</title>
<link rel="author" title="Michael Ventnor" href="mailto:mventnor@mozilla.com">
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="http://www.whatwg.org/html/#read-media">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t = async_test("The document for a standalone media file should have one child in the body.");
function frameLoaded() {
var testframe = document.getElementById('testframe');
var testframeChildren = testframe.contentDocument.body.childNodes;
assert_equals(testframeChildren.length, 1, "Body of image document has 1 child");
assert_equals(testframeChildren[0].nodeName, "VIDEO", "Only child of body must be an <video> element");
assert_equals(testframeChildren[0].namespaceURI, "http://www.w3.org/1999/xhtml",
"Only child of body must be an HTML element");
t.done();
}
</script>
</head>
<body>
<div id="log"></div>
<iframe id="testframe" onload="t.step(frameLoaded)"
src="data:video/webm,"></iframe>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<title>Script for and onload attributes</title>
<link rel="author" title="Matheus Kerschbaum" href="mailto:matjk7@gmail.com">
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="http://www.whatwg.org/html/#prepare-a-script">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t = async_test("Script for and onload attributes");
</script>
<script for=" window " event=" onload() ">
var foo = "bar";
</script>
<script for="object" event="handler">
// This script should fail to run
foo = "baz";
t.step(function() { assert_unreached("This script should fail to run."); });
</script>
<script>
t.step(function() { assert_equals(foo, "bar", "Correct script was executed."); });
t.done();
</script>

View File

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<title>window.onerror: parse errors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!--
In http://dev.w3.org/html5/spec/webappapis.html#creating-scripts ,
step 3 describes parsing the script, and step 5 says:
# Otherwise, report the error using the onerror event handler of
# the script's global object. If the error is still not handled
# after this, then the error may be reported to the user.
which links to
http://dev.w3.org/html5/spec/webappapis.html#report-the-error ,
which describes what to do when onerror is a Function.
-->
</head>
<body>
<div id="log"></div>
<script>
var error_count = 0;
window.onerror = function(msg, url, lineno) {
++error_count;
test(function() {assert_equals(url, window.location.href)},
"correct url passed to window.onerror");
test(function() {assert_equals(lineno, 33)},
"correct line number passed to window.onerror");
};
</script>
<script>This script does not parse correctly.</script>
<script>
test(function() {assert_equals(error_count, 1)},
"correct number of calls to window.onerror");
</script>
</body>
</html>

View File

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>window.onerror: runtime scripterrors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!--
http://www.w3.org/TR/html5/webappapis.html#runtime-script-errors
says what to do for uncaught runtime script errors, and just below
describes what to do when onerror is a Function.
-->
</head>
<body>
<div id="log"></div>
<script>
var error_count = 0;
window.onerror = function(msg, url, lineno) {
++error_count;
};
</script>
<script>
try {
// This error is caught, so it should NOT trigger onerror.
throw "foo";
} catch (ex) {
}
// This error is NOT caught, so it should trigger onerror.
throw "bar";
</script>
<script>
test(function() {assert_equals(error_count, 1)},
"correct number of calls to window.onerror");
</script>
</body>
</html>

View File

@ -0,0 +1,42 @@
<!doctype html>
<html>
<head>
<title>window.onerror: runtime scripterrors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!--
http://www.w3.org/TR/html5/webappapis.html#runtime-script-errors
says what to do for uncaught runtime script errors, and just below
describes what to do when onerror is a Function.
-->
</head>
<body>
<div id="log"></div>
<script>
var error_count = 0;
window.onerror = function(msg, url, lineno) {
++error_count;
test(function() {assert_equals(url, window.location.href)},
"correct url passed to window.onerror");
test(function() {assert_equals(lineno, 35)},
"correct line number passed to window.onerror");
};
</script>
<script>
try {
// This error is caught, so it should NOT trigger onerror.
window.nonexistentproperty.oops();
} catch (ex) {
}
// This error is NOT caught, so it should trigger onerror.
window.nonexistentproperty.oops();
</script>
<script>
test(function() {assert_equals(error_count, 1)},
"correct number of calls to window.onerror");
</script>
</body>
</html>