Move content tests into the Servo wpt tree (fixes #5686).

This commit is contained in:
Ms2ger 2015-04-15 16:00:41 +02:00
parent bdcf606f48
commit 48ac95c171
150 changed files with 2617 additions and 1962 deletions

View file

@ -13,11 +13,494 @@
},
"local_changes": {
"deleted": [],
"items": {},
"items": {
"testharness": {
"mozilla/DOMParser.html": [
{
"path": "mozilla/DOMParser.html",
"url": "/_mozilla/mozilla/DOMParser.html"
}
],
"mozilla/Event.html": [
{
"path": "mozilla/Event.html",
"url": "/_mozilla/mozilla/Event.html"
}
],
"mozilla/MouseEvent.html": [
{
"path": "mozilla/MouseEvent.html",
"url": "/_mozilla/mozilla/MouseEvent.html"
}
],
"mozilla/blob.html": [
{
"path": "mozilla/blob.html",
"url": "/_mozilla/mozilla/blob.html"
}
],
"mozilla/body_listener.html": [
{
"path": "mozilla/body_listener.html",
"url": "/_mozilla/mozilla/body_listener.html"
}
],
"mozilla/caption.html": [
{
"path": "mozilla/caption.html",
"url": "/_mozilla/mozilla/caption.html"
}
],
"mozilla/characterdata.html": [
{
"path": "mozilla/characterdata.html",
"url": "/_mozilla/mozilla/characterdata.html"
}
],
"mozilla/collections.html": [
{
"path": "mozilla/collections.html",
"url": "/_mozilla/mozilla/collections.html"
}
],
"mozilla/createElement_script.html": [
{
"path": "mozilla/createElement_script.html",
"url": "/_mozilla/mozilla/createElement_script.html"
}
],
"mozilla/create_element.html": [
{
"path": "mozilla/create_element.html",
"url": "/_mozilla/mozilla/create_element.html"
}
],
"mozilla/documentElement.html": [
{
"path": "mozilla/documentElement.html",
"url": "/_mozilla/mozilla/documentElement.html"
}
],
"mozilla/document_activeElement.html": [
{
"path": "mozilla/document_activeElement.html",
"url": "/_mozilla/mozilla/document_activeElement.html"
}
],
"mozilla/document_body.html": [
{
"path": "mozilla/document_body.html",
"url": "/_mozilla/mozilla/document_body.html"
}
],
"mozilla/document_characterSet.html": [
{
"path": "mozilla/document_characterSet.html",
"url": "/_mozilla/mozilla/document_characterSet.html"
}
],
"mozilla/document_characterSet_default.html": [
{
"path": "mozilla/document_characterSet_default.html",
"url": "/_mozilla/mozilla/document_characterSet_default.html"
}
],
"mozilla/document_characterSet_invalid.html": [
{
"path": "mozilla/document_characterSet_invalid.html",
"url": "/_mozilla/mozilla/document_characterSet_invalid.html"
}
],
"mozilla/document_compatMode_loose.html": [
{
"path": "mozilla/document_compatMode_loose.html",
"url": "/_mozilla/mozilla/document_compatMode_loose.html"
}
],
"mozilla/document_compatMode_strict.html": [
{
"path": "mozilla/document_compatMode_strict.html",
"url": "/_mozilla/mozilla/document_compatMode_strict.html"
}
],
"mozilla/document_contenttype.html": [
{
"path": "mozilla/document_contenttype.html",
"url": "/_mozilla/mozilla/document_contenttype.html"
}
],
"mozilla/document_datalist_options.html": [
{
"path": "mozilla/document_datalist_options.html",
"url": "/_mozilla/mozilla/document_datalist_options.html"
}
],
"mozilla/document_defaultView.html": [
{
"path": "mozilla/document_defaultView.html",
"url": "/_mozilla/mozilla/document_defaultView.html"
}
],
"mozilla/document_getElementById.html": [
{
"path": "mozilla/document_getElementById.html",
"url": "/_mozilla/mozilla/document_getElementById.html"
}
],
"mozilla/document_getElementsByName.html": [
{
"path": "mozilla/document_getElementsByName.html",
"url": "/_mozilla/mozilla/document_getElementsByName.html"
}
],
"mozilla/document_head.html": [
{
"path": "mozilla/document_head.html",
"url": "/_mozilla/mozilla/document_head.html"
}
],
"mozilla/document_images_cache.html": [
{
"path": "mozilla/document_images_cache.html",
"url": "/_mozilla/mozilla/document_images_cache.html"
}
],
"mozilla/document_implementation.html": [
{
"path": "mozilla/document_implementation.html",
"url": "/_mozilla/mozilla/document_implementation.html"
}
],
"mozilla/document_links_cache.html": [
{
"path": "mozilla/document_links_cache.html",
"url": "/_mozilla/mozilla/document_links_cache.html"
}
],
"mozilla/document_readystate.html": [
{
"path": "mozilla/document_readystate.html",
"url": "/_mozilla/mozilla/document_readystate.html"
}
],
"mozilla/document_set_node_value.html": [
{
"path": "mozilla/document_set_node_value.html",
"url": "/_mozilla/mozilla/document_set_node_value.html"
}
],
"mozilla/document_title_nontextchildren.html": [
{
"path": "mozilla/document_title_nontextchildren.html",
"url": "/_mozilla/mozilla/document_title_nontextchildren.html"
}
],
"mozilla/document_url.html": [
{
"path": "mozilla/document_url.html",
"url": "/_mozilla/mozilla/document_url.html"
}
],
"mozilla/domtokenlist.html": [
{
"path": "mozilla/domtokenlist.html",
"url": "/_mozilla/mozilla/domtokenlist.html"
}
],
"mozilla/element_attribute.html": [
{
"path": "mozilla/element_attribute.html",
"url": "/_mozilla/mozilla/element_attribute.html"
}
],
"mozilla/element_attributes.html": [
{
"path": "mozilla/element_attributes.html",
"url": "/_mozilla/mozilla/element_attributes.html"
}
],
"mozilla/element_classList.html": [
{
"path": "mozilla/element_classList.html",
"url": "/_mozilla/mozilla/element_classList.html"
}
],
"mozilla/element_className.html": [
{
"path": "mozilla/element_className.html",
"url": "/_mozilla/mozilla/element_className.html"
}
],
"mozilla/element_matches.html": [
{
"path": "mozilla/element_matches.html",
"url": "/_mozilla/mozilla/element_matches.html"
}
],
"mozilla/empty_clientrect.html": [
{
"path": "mozilla/empty_clientrect.html",
"url": "/_mozilla/mozilla/empty_clientrect.html"
}
],
"mozilla/enabled_disabled_selectors.html": [
{
"path": "mozilla/enabled_disabled_selectors.html",
"url": "/_mozilla/mozilla/enabled_disabled_selectors.html"
}
],
"mozilla/event_dispatch.html": [
{
"path": "mozilla/event_dispatch.html",
"url": "/_mozilla/mozilla/event_dispatch.html"
}
],
"mozilla/event_dispatch_dynamic.html": [
{
"path": "mozilla/event_dispatch_dynamic.html",
"url": "/_mozilla/mozilla/event_dispatch_dynamic.html"
}
],
"mozilla/event_dispatch_order.html": [
{
"path": "mozilla/event_dispatch_order.html",
"url": "/_mozilla/mozilla/event_dispatch_order.html"
}
],
"mozilla/event_handler_syntax_error.html": [
{
"path": "mozilla/event_handler_syntax_error.html",
"url": "/_mozilla/mozilla/event_handler_syntax_error.html"
}
],
"mozilla/event_listener.html": [
{
"path": "mozilla/event_listener.html",
"url": "/_mozilla/mozilla/event_listener.html"
}
],
"mozilla/focus_blur.html": [
{
"path": "mozilla/focus_blur.html",
"url": "/_mozilla/mozilla/focus_blur.html"
}
],
"mozilla/getBoundingClientRect.html": [
{
"path": "mozilla/getBoundingClientRect.html",
"url": "/_mozilla/mozilla/getBoundingClientRect.html"
}
],
"mozilla/getPropertyPriority.html": [
{
"path": "mozilla/getPropertyPriority.html",
"url": "/_mozilla/mozilla/getPropertyPriority.html"
}
],
"mozilla/global.html": [
{
"path": "mozilla/global.html",
"url": "/_mozilla/mozilla/global.html"
}
],
"mozilla/htmlcollection.html": [
{
"path": "mozilla/htmlcollection.html",
"url": "/_mozilla/mozilla/htmlcollection.html"
}
],
"mozilla/htmlfieldsetelement_elements.html": [
{
"path": "mozilla/htmlfieldsetelement_elements.html",
"url": "/_mozilla/mozilla/htmlfieldsetelement_elements.html"
}
],
"mozilla/htmlspacechars.html": [
{
"path": "mozilla/htmlspacechars.html",
"url": "/_mozilla/mozilla/htmlspacechars.html"
}
],
"mozilla/iframe_contentDocument.html": [
{
"path": "mozilla/iframe_contentDocument.html",
"url": "/_mozilla/mozilla/iframe_contentDocument.html"
}
],
"mozilla/img_width_height.html": [
{
"path": "mozilla/img_width_height.html",
"url": "/_mozilla/mozilla/img_width_height.html"
}
],
"mozilla/inline_event_handler.html": [
{
"path": "mozilla/inline_event_handler.html",
"url": "/_mozilla/mozilla/inline_event_handler.html"
}
],
"mozilla/innerHTML.html": [
{
"path": "mozilla/innerHTML.html",
"url": "/_mozilla/mozilla/innerHTML.html"
}
],
"mozilla/interfaces.html": [
{
"path": "mozilla/interfaces.html",
"url": "/_mozilla/mozilla/interfaces.html"
}
],
"mozilla/lenient_this.html": [
{
"path": "mozilla/lenient_this.html",
"url": "/_mozilla/mozilla/lenient_this.html"
}
],
"mozilla/load_event.html": [
{
"path": "mozilla/load_event.html",
"url": "/_mozilla/mozilla/load_event.html"
}
],
"mozilla/navigator.html": [
{
"path": "mozilla/navigator.html",
"url": "/_mozilla/mozilla/navigator.html"
}
],
"mozilla/node_cloneNode.html": [
{
"path": "mozilla/node_cloneNode.html",
"url": "/_mozilla/mozilla/node_cloneNode.html"
}
],
"mozilla/node_compareDocumentPosition.html": [
{
"path": "mozilla/node_compareDocumentPosition.html",
"url": "/_mozilla/mozilla/node_compareDocumentPosition.html"
}
],
"mozilla/node_contains.html": [
{
"path": "mozilla/node_contains.html",
"url": "/_mozilla/mozilla/node_contains.html"
}
],
"mozilla/node_insertBefore.html": [
{
"path": "mozilla/node_insertBefore.html",
"url": "/_mozilla/mozilla/node_insertBefore.html"
}
],
"mozilla/node_isEqualNode.html": [
{
"path": "mozilla/node_isEqualNode.html",
"url": "/_mozilla/mozilla/node_isEqualNode.html"
}
],
"mozilla/node_normalize.html": [
{
"path": "mozilla/node_normalize.html",
"url": "/_mozilla/mozilla/node_normalize.html"
}
],
"mozilla/node_replaceChild.html": [
{
"path": "mozilla/node_replaceChild.html",
"url": "/_mozilla/mozilla/node_replaceChild.html"
}
],
"mozilla/parentNode_querySelector.html": [
{
"path": "mozilla/parentNode_querySelector.html",
"url": "/_mozilla/mozilla/parentNode_querySelector.html"
}
],
"mozilla/parentNode_querySelectorAll.html": [
{
"path": "mozilla/parentNode_querySelectorAll.html",
"url": "/_mozilla/mozilla/parentNode_querySelectorAll.html"
}
],
"mozilla/parentnodes.html": [
{
"path": "mozilla/parentnodes.html",
"url": "/_mozilla/mozilla/parentnodes.html"
}
],
"mozilla/proxy_setter.html": [
{
"path": "mozilla/proxy_setter.html",
"url": "/_mozilla/mozilla/proxy_setter.html"
}
],
"mozilla/script_type.html": [
{
"path": "mozilla/script_type.html",
"url": "/_mozilla/mozilla/script_type.html"
}
],
"mozilla/storage.html": [
{
"path": "mozilla/storage.html",
"url": "/_mozilla/mozilla/storage.html"
}
],
"mozilla/textcontent.html": [
{
"path": "mozilla/textcontent.html",
"url": "/_mozilla/mozilla/textcontent.html"
}
],
"mozilla/title.html": [
{
"path": "mozilla/title.html",
"url": "/_mozilla/mozilla/title.html"
}
],
"mozilla/trace_null.html": [
{
"path": "mozilla/trace_null.html",
"url": "/_mozilla/mozilla/trace_null.html"
}
],
"mozilla/union.html": [
{
"path": "mozilla/union.html",
"url": "/_mozilla/mozilla/union.html"
}
],
"mozilla/window.html": [
{
"path": "mozilla/window.html",
"url": "/_mozilla/mozilla/window.html"
}
],
"mozilla/window_performance.html": [
{
"path": "mozilla/window_performance.html",
"url": "/_mozilla/mozilla/window_performance.html"
}
],
"mozilla/window_setInterval.html": [
{
"path": "mozilla/window_setInterval.html",
"url": "/_mozilla/mozilla/window_setInterval.html"
}
],
"mozilla/windowproxy.html": [
{
"path": "mozilla/windowproxy.html",
"url": "/_mozilla/mozilla/windowproxy.html"
}
]
}
},
"reftest_nodes": {}
},
"reftest_nodes": {},
"rev": null,
"url_base": "/_mozilla/",
"version": 2
}
}

View file

@ -0,0 +1,5 @@
[enabled_disabled_selectors.html]
type: testharness
[menuitem initial state]
expected: FAIL

View file

@ -0,0 +1,5 @@
[windowproxy.html]
type: testharness
[Unforgeable location]
expected: FAIL

View file

@ -0,0 +1,14 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(String(DOMParser).indexOf("function DOMParser("), 0);
let parser = new DOMParser();
assert_true(parser instanceof DOMParser, "Should be DOMParser");
assert_true(parser.parseFromString("", "text/html") instanceof Document, "Should be Document");
});
</script>
</head>
</html>

View file

@ -0,0 +1,19 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(String(Event).indexOf("function Event("), 0);
let ev = new Event("foopy", {cancelable: true});
assert_true(ev instanceof Event, "Should be Event");
assert_equals(ev.type, 'foopy');
assert_equals(ev.defaultPrevented, false);
ev.preventDefault();
assert_equals(ev.defaultPrevented, true);
});
</script>
</head>
</html>

View file

@ -0,0 +1,19 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(String(MouseEvent).indexOf("function MouseEvent("), 0);
let ev = new MouseEvent("press", {bubbles: true, screenX: 150, detail: 100});
assert_true(ev instanceof Event, "Should be Event");
assert_true(ev instanceof UIEvent, "Should be UIEvent");
assert_true(ev instanceof MouseEvent, "Should be MouseEvent");
assert_equals(ev.screenX, 150);
assert_equals(ev.detail, 100);
});
</script>
</head>
</html>

View file

@ -0,0 +1,46 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var testData = ['<a id="a"><b id="b">hey!</b></a>'];
var b = new Blob(testData); // the blob
assert_equals(b.size, 32);
assert_equals(b.type, "");
var bs = b.slice(0, 5);
assert_equals(bs.size, 5);
assert_equals(b.type, "");
var bc = new Blob(testData, {type:"text/plain"}); // the blob
assert_equals(bc.size, 32);
assert_equals(bc.type, "text/plain");
var bss = new Blob(testData, {type:" text/plain "}); // spaces
assert_equals(bss.size, 32);
assert_equals(bss.type, " text/plain ");
var bcs = bc.slice(0, 7);
assert_equals(bcs.size, 7);
assert_equals(bcs.type, "");
var bcsc = bc.slice(0, 7, "text/xml");
assert_equals(bcsc.size, 7);
assert_equals(bcsc.type, "text/xml");
var bu = new Blob(testData, {type:"TEXT/PLAIN"}); // the blob
assert_equals(bu.size, 32);
assert_equals(bu.type, "text/plain");
var bj = new Blob(testData, {type:"☃"}); // the blob
assert_equals(bj.size, 32);
assert_equals(bj.type, "");
var bjs = bj.slice(0, 7, "☃");
assert_equals(bjs.size, 7);
assert_equals(bjs.type, "");
});
</script>
</head>
</html>

View file

@ -0,0 +1,20 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function() {
window.check_onload = this.step_func(function(listener) {
assert_equals(listener, window);
var ev = new Event('click', {bubbles: true, cancelable: true});
document.body.dispatchEvent(ev);
});
window.check_onclick = this.step_func_done(function(listener) {
assert_equals(listener, document.body);
});
});
</script>
</head>
<body onload="check_onload(this)" onclick="check_onclick(this)">
</body>
</html>

View file

@ -0,0 +1,27 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<table id="t">
<caption id="tcaption">old caption</caption>
</table>
<script>
test(function() {
var t = document.getElementById("t");
var tcaption = document.getElementById("tcaption");
assert_equals(t.caption, tcaption);
assert_equals(t.caption.innerHTML, "old caption");
var newCaption = document.createElement("caption");
newCaption.innerHTML = "new caption";
t.caption = newCaption;
assert_equals(newCaption.parentNode, t);
assert_equals(t.caption, newCaption);
// Test for https://github.com/servo/servo/issues/3997
t.getBoundingClientRect();
});
</script>
</html>

View file

@ -0,0 +1,47 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<p>This is the character data</p>
</body>
<script>
test(function() {
var a = document.getElementsByTagName('p')[0].childNodes[0];
assert_equals(a.data, "This is the character data");
// append test utf8
a.appendData(", append more 資料,測試資料");
assert_equals(a.data, "This is the character data, append more 資料,測試資料");
// length test utf8
assert_equals(a.length, 47);
// insert test non-utf8
a.insertData(26, " test");
assert_equals(a.data, "This is the character data test, append more 資料,測試資料");
// insert test utf8
a.insertData(48, "更多");
assert_equals(a.data, "This is the character data test, append more 資料,更多測試資料");
// delete test non-utf8
a.deleteData(40, 5);
assert_equals(a.data, "This is the character data test, append 資料,更多測試資料");
// delete test utf8
a.deleteData(45, 2);
assert_equals(a.data, "This is the character data test, append 資料,更多資料");
// replace test non-utf8
a.replaceData(33, 6, "other");
assert_equals(a.data, "This is the character data test, other 資料,更多資料");
// replace test non-utf8
a.replaceData(44, 2, "文字");
assert_equals(a.data, "This is the character data test, other 資料,更多文字");
// substring test non-utf8
assert_equals(a.substringData(12, 4), "char");
// substring test utf8
assert_equals(a.substringData(39, 2), "資料");
});
</script>
</html>

View file

@ -0,0 +1,17 @@
<html>
<head>
<script src="./harness.js"></script>
<a id="foo" href="/nonexistent">test link</a>
<script>
async_test(function() {
var link = document.getElementById('foo');
link.addEventListener('click', this.step_func(function(ev) {
ev.preventDefault();
}));
var ev = new Event('click', {bubbles: true, cancelable: true});
link.dispatchEvent(ev);
setTimeout(this.step_func_done(), 500);
});
</script>
</head>
</html>

View file

@ -0,0 +1,149 @@
<html>
<head>
<meta charset="utf-8">
<title>test_binding
page </title>
<base href="./"></base>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="first" name="test">fffff<br><br><br><br>fffffffffffffffff</div>
<div id="second">ggg</div>
<span id="third" name="test">hhhhhhhh</span>
<div id="fourth">iiiiiiiiiiiiiiiiiii</div>
<a href="http://www.mozilla.org"></a>
<img src="test.jpg"/>
<embed></embed>
<form>
<fieldset>
<legend>legend</legend>
<label for="">label<input type="text" value="input" /></label>
</fieldset>
</form>
<hr />
<canvas/>
<p>pppppppppp</p>
<q>qqqqqqqqqqqqqqqqqqqqqqqqqqq</q>
<progress max="100" value="80">80%</progress>
<applet></applet>
<input type="text" value="input"/>
<iframe></iframe>
<ol type="1">
<li>li</li>
</ol>
<table>
<caption>sample table</caption>
<colgroup>
<col/>
</colgroup>
<tbody>
<tr><th>head</th></tr>
<tr><td>data</td></tr>
</tbody>
</table>
<section>section</section>
<aside>aside</aside>
<b>b</b>
<i>i</i>
<small>small</small>
<textarea>textarea</textarea>
<time datetime="2014-02-14">Valentines day</time>
<area></area>
<data></data>
<dialog></dialog>
<template></template>
<pre>pre</pre>
<audio>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
</audio>
<video src="">
<track></track>
</video>
<foo-á>hi</foo-á>
<script>
test(function() {
function check_collection(obj, num, classes, name) {
test(function() {
assert_true(obj instanceof HTMLCollection, "Should be HTMLCollection");
assert_equals(obj.length, num);
assert_equals(obj[obj.length], undefined);
if (classes === undefined) {
return;
}
classes = [Element, HTMLElement].concat(classes);
for (var i = 0; i < obj.length; i++) {
assert_not_equals(obj[i], undefined);
assert_equals(obj[i].tagName, name);
for (var j = 0; j < classes.length; j++) {
assert_true(obj[i] instanceof classes[j], "Should be " + classes[j]);
}
}
});
}
function check_tag(tagname, num, classes, tagname_upper) {
if (tagname_upper === undefined)
tagname_upper = tagname.toUpperCase();
check_collection(document.getElementsByTagName(tagname), num, classes, tagname_upper);
}
check_collection(document.links, 1, [HTMLAnchorElement], "A");
check_collection(document.images, 1, [HTMLImageElement], "IMG");
check_collection(document.embeds, 1, [HTMLEmbedElement], "EMBED");
check_collection(document.plugins, 1, [HTMLEmbedElement], "EMBED");
check_collection(document.scripts, 3, [HTMLScriptElement], "SCRIPT");
check_collection(document.applets, 1, [HTMLAppletElement], "APPLET");
check_collection(document.forms, 1, [HTMLFormElement], "FORM");
check_collection(document.getElementsByTagName("nosuchtag"), 0);
check_tag("section", 1, []);
check_tag("aside", 1, []);
check_tag("b", 1, []);
check_tag("i", 1, []);
check_tag("small", 1, []);
check_tag("head", 1, [HTMLHeadElement]);
check_tag("div", 3, [HTMLDivElement]);
check_tag("iframe", 1, [HTMLIFrameElement]);
check_tag("body", 1, [HTMLBodyElement]);
check_tag("area", 1, [HTMLAreaElement]);
check_tag("base", 1, [HTMLBaseElement]);
check_tag("data", 1, [HTMLDataElement]);
check_tag("dialog", 1, [HTMLDialogElement]);
check_tag("ol", 1, [HTMLOListElement]);
check_tag("canvas", 1, [HTMLCanvasElement]);
check_tag("source", 2, [HTMLSourceElement]);
check_tag("time", 1, [HTMLTimeElement]);
check_tag("caption", 1, [HTMLTableCaptionElement]);
check_tag("textarea", 1, [HTMLTextAreaElement]);
check_tag("q", 1, [HTMLQuoteElement]);
check_tag("th", 1, [HTMLTableCellElement, HTMLTableHeaderCellElement]);
check_tag("td", 1, [HTMLTableCellElement, HTMLTableDataCellElement]);
check_tag("col", 1, [HTMLTableColElement]);
check_tag("colgroup", 1, [HTMLTableColElement]);
check_tag("input", 2, [HTMLInputElement]);
check_tag("li", 1, [HTMLLIElement]);
check_tag("progress", 1, [HTMLProgressElement]);
check_tag("template", 1, [HTMLTemplateElement]);
check_tag("pre", 1, [HTMLPreElement]);
check_tag("legend", 1, [HTMLLegendElement]);
check_tag("label", 1, [HTMLLabelElement]);
check_tag("track", 1, [HTMLTrackElement]);
check_tag("audio", 1, [HTMLMediaElement, HTMLAudioElement]);
check_tag("video", 1, [HTMLMediaElement, HTMLVideoElement]);
// Test non-ASCII tag names. Uppercasing is ASCII-only per spec:
// http://dom.spec.whatwg.org/#dom-element-tagname
check_tag("foo-á", 1, [HTMLUnknownElement], "FOO-á");
});
</script>
</body>
</html>

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
var output;
test(function() {
output = "start";
var script = document.createElement("script");
script.setAttribute('type','text/javascript');
script.textContent = "output += ' middle ';";
document.body.appendChild(script);
output += "end";
assert_equals(output, "start middle end");
});
</script>
</body>
</html>

View file

@ -0,0 +1,21 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
var elem = document.createElement("foo");
assert_equals(elem.tagName, "FOO");
var elem = document.createElement("p");
assert_true(elem instanceof HTMLParagraphElement, "Should be HTMLParagraphElement");
var elem = document.createElement("sPAn");
assert_true(elem instanceof HTMLSpanElement, "Should be HTMLSpanElement");
var text = document.createTextNode("hello");
assert_true(text instanceof Text, "Should be Text");
});
</script>
</body>
</html>

View file

@ -0,0 +1,15 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_true(window instanceof Window, "Should be Window");
assert_true(document.documentElement instanceof HTMLHtmlElement, "Should be HTMLHtmlElement");
assert_true(document.documentElement.firstChild instanceof HTMLHeadElement, "Should be HTMLHeadElement");
assert_equals(document.documentElement.nextSibling, null);
assert_true(document instanceof Document, "Should be Document");
});
</script>
</head>
</html>

View file

@ -0,0 +1,21 @@
<!doctype html>
<html>
<head >
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<input id="foo" type="text"></input>
<script>
test(function() {
assert_not_equals(document.activeElement, null, "test_1.1, document.activeElement");
assert_equals(document.activeElement, document.body, "test_1.2, document.activeElement");
document.getElementById('foo').focus();
assert_not_equals(document.activeElement, null, "test_2.1, document.activeElement");
assert_equals(document.activeElement, document.getElementById("foo"), "test_2.2, document.activeElement");
});
</script>
</body>
</html>

View file

@ -0,0 +1,66 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
assert_not_equals(document.body, null, "test1-0, existing document's body");
assert_true(document.body instanceof HTMLBodyElement, "test1-1, exising document's body: should be HTMLBodyElement");
assert_equals(document.body && document.body.tagName, "BODY", "test1-2, existing document's body");
}, "existing document's body");
test(function() {
let new_body = document.createElement("body");
assert_not_equals(new_body, null, "test2-0, replace document's body with new body");
document.body = new_body;
assert_equals(new_body, document.body, "test2-1, replace document's body with new body");
}, "replace document's body with new body");
test(function() {
let new_frameset = document.createElement("frameset");
assert_not_equals(new_frameset, null, "test2-0, replace document's body with new frameset");
document.body = new_frameset;
assert_equals(new_frameset, document.body, "test2-1, replace document's body with new frameset");
}, "replace document's body with new frameset");
test(function() {
let new_document = new Document();
new_document.appendChild(new_document.createElement("html"));
let new_div = new_document.createElement("div");
assert_not_equals(new_div, null, "test4-0, append an invalid element to a new document");
assert_throws(null, function() {
new_document.body = new_div;
});
assert_equals(new_document.body, null, "test4-1, append an invalid element to a new document");
}, "append an invalid element to a new document");
test(function() {
let new_document = document.implementation.createHTMLDocument();
let new_body = new_document.createElement("body");
assert_not_equals(new_body, null, "test5-0, append body to a new document");
assert_true(new_body instanceof HTMLBodyElement, "test5-1, append body to a new document: should be HTMLBodyElement");
assert_equals(new_body && new_body.tagName, "BODY", "test5-2, append body to a new document");
new_document.body = new_body;
assert_equals(new_document.body, new_body, "test5-3, append body to a new document");
}, "append body to a new document");
test(function() {
let new_document = document.implementation.createHTMLDocument();
let new_frameset = new_document.createElement("frameset");
assert_not_equals(new_frameset, null, "test6-0, append frameset to a new document");
assert_true(new_frameset instanceof HTMLFrameSetElement, "test6-1, append frameset to a new document: should be HTMLFrameSetElement");
assert_equals(new_frameset && new_frameset.tagName, "FRAMESET", "test6-2, append frameset to a new document");
new_document.body = new_frameset;
assert_equals(new_document.body, new_frameset, "test6-3, append frameset to a new document");
}, "append frameset to a new document");
</script>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.characterSet, "UTF-8", "test1-0, characterSet");
var xmldoc = new Document;
assert_equals(xmldoc.characterSet, "UTF-8", "test2-1, characterSet");
var htmldoc = document.implementation.createHTMLDocument("title");
assert_equals(htmldoc.characterSet, "UTF-8", "test2-2, characterSet");
});
</script>
</head>
</html>

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.characterSet, "UTF-8", "test1-0, default characterSet");
});
</script>
</head>
</html>

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<meta charset="unknown-charset">
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.characterSet, "UTF-8", "test1-0, unknown charset");
});
</script>
</head>
</html>

View file

@ -0,0 +1,12 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.compatMode, "BackCompat", "test1-0, Loose HTML");
});
</script>
</head>
</html>

View file

@ -0,0 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.compatMode, "CSS1Compat", "test1-0, Strict HTML");
});
</script>
</head>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_true(document instanceof Document, "test1-0, HTML document: should be Document");
assert_equals(document.contentType, "text/html", "test1-1, HTML document");
}, "HTML document");
test(function() {
var doc = new Document;
assert_true(doc instanceof Document, "test2-0, XML document: should be Document");
assert_equals(doc.contentType, "application/xml", "test2-1, XML document");
}, "XML document");
</script>
</head>
</html>

View file

@ -0,0 +1,22 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<datalist id="id">
<option value="A">
<option value="B">
<p>P</p>
<div>DIV</div>
<option value="C">
</datalist>
<script>
test(function() {
var datalist = document.getElementById("id");
assert_equals(datalist.options.length, 3);
assert_true(datalist.options[0] instanceof HTMLOptionElement, "Should be HTMLOptionElement");
assert_true(datalist.options[1] instanceof HTMLOptionElement, "Should be HTMLOptionElement");
assert_true(datalist.options[2] instanceof HTMLOptionElement, "Should be HTMLOptionElement");
});
</script>
</html>

View file

@ -0,0 +1,13 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
assert_equals(document.defaultView, window);
});
</script>
</body>
</html>

View file

@ -0,0 +1,27 @@
<html>
<head id="foo">
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="bar"></div>
<script>
test(function() {
let gBody = document.getElementsByTagName("body")[0];
// Test the assertion with inserting node with child having id into the document (mozilla#2630)
// This need not to port to WPF-test because this tests servo's internally flags.
{
let TEST_ID = "test-9";
let a = document.createElement("a");
let b = document.createElement("b");
a.appendChild(b).id = TEST_ID;
gBody.appendChild(a);
let result = document.getElementById(TEST_ID);
assert_equals(result, b, "test 9-0");
}
});
</script>
</body>
</html>

View file

@ -0,0 +1,17 @@
<html>
<head >
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div name="foo"></div>
<script>
test(function() {
let nameList = document.getElementsByName("foo");
assert_true(nameList instanceof NodeList, "Should be NodeList");
assert_false(nameList instanceof HTMLCollection, "Should not be HTMLCollection");
});
</script>
</body>
</html>

View file

@ -0,0 +1,43 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
assert_not_equals(document.head, null, "test1-0, existing document's head");
assert_true(document.head instanceof HTMLHeadElement, "test1-1, exising document's head: should be HTMLHeadElement");
assert_equals(document.head && document.head.tagName, "HEAD", "test1-2, existing document's head");
}, "existing document's head");
test(function() {
let new_document = new Document();
new_document.appendChild(new_document.createElement("html"));
let new_head = new_document.createElement("head");
assert_not_equals(new_head, null, "test2-0, append head to a new document");
assert_true(new_head instanceof HTMLHeadElement, "test2-1, append head to a new document: should be HTMLHeadElement");
assert_equals(new_head && new_head.tagName, "head", "test2-2, append head to a new document");
// Document::head is read-only.
new_document.head = new_head;
assert_equals(new_document.head, null, "test2-3, append head to a new document");
new_document.documentElement.appendChild(new_head);
assert_equals(new_document.head, new_head, "test2-4, append head to a new document");
}, "append head to a new document");
test(function() {
let new_document = new Document();
let html = new_document.createElement("html");
let foo = new_document.createElement("foo");
let head = new_document.createElement("head");
new_document.appendChild(html);
html.appendChild(foo);
foo.appendChild(head);
assert_equals(new_document.head, null, "test3-0, head's parent should be document element");
}, "head's parent should be document element");
</script>
</body>
</html>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<img src="test.png">
<noscript>
<img src="test.jpg">
</noscript>
<script>
test(function() {
var images = document.images;
assert_equals(images, document.images);
assert_equals(images.length, 1);
var image = document.createElement("img");
image.setAttribute("src", "test.jpg");
document.body.appendChild(image);
assert_equals(images.length, 2);
document.body.removeChild(image);
assert_equals(images.length, 1);
});
</script>
</body>
</html>

View file

@ -0,0 +1,76 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_not_equals(document.implementation, null, "test1-0, basic test");
assert_true(document.implementation instanceof DOMImplementation, "test1-1, basic test: should be DOMImplementation");
var implementation = document.implementation;
assert_equals(document.implementation, implementation, "test1-2, basic test");
}, "basic test");
test(function() {
assert_equals(document.doctype, null, "test2-0, createDocumentType");
var doctype = document.implementation.createDocumentType("html", null, null);
assert_true(doctype && doctype instanceof DocumentType, "test2-1, createDocumentType: should be DocumentType");
doctype = document.implementation.createDocumentType("html:html", null, null);
assert_true(doctype && doctype instanceof DocumentType, "test2-2, createDocumentType: should be DocumentType");
}, "createDocumentType");
test(function() {
var htmldoc = document.implementation.createHTMLDocument("example title");
assert_not_equals(htmldoc, null, "test3-0, createHTMLDocument");
assert_true(htmldoc instanceof Document, "test3-1, createHTMLDocument: should be Document");
assert_equals(htmldoc.childNodes.length, 2, "test3-3, createHTMLDocument");
assert_true(htmldoc.doctype && htmldoc.doctype instanceof DocumentType, "test3-4, createHTMLDocument: should be DocumentType");
assert_equals(htmldoc.doctype.name, "html", "test3-5, createHTMLDocument");
assert_true(htmldoc.documentElement && htmldoc.documentElement instanceof HTMLHtmlElement, "test3-6, createHTMLDocument: should be HTMLHtmlElement");
assert_equals(htmldoc.documentElement.childNodes.length, 2, "test3-7, createHTMLDocument");
assert_equals(htmldoc.documentElement.tagName, "HTML", "test3-8, createHTMLDocument");
assert_true(htmldoc.head && htmldoc.head instanceof HTMLHeadElement, "test3-9, createHTMLDocument: should be HTMLHeadElement");
assert_equals(htmldoc.head.tagName, "HEAD", "test3-10, createHTMLDocument");
assert_equals(htmldoc.head, htmldoc.documentElement.childNodes[0], "test3-11, createHTMLDocument");
assert_equals(htmldoc.head.childNodes.length, 1, "test3-12, createHTMLDocument");
assert_true(htmldoc.head.childNodes[0] instanceof HTMLTitleElement, "test3-13, createHTMLDocument: should be HTMLTitleElement");
assert_equals(htmldoc.head.childNodes[0].tagName, "TITLE", "test3-14, createHTMLDocument");
assert_equals(htmldoc.title, "example title", "test3-15, createHTMLDocument");
assert_true(htmldoc.body && htmldoc.body instanceof HTMLBodyElement, "test3-16, createHTMLDocument: should be HTMLBodyElement");
assert_equals(htmldoc.body.tagName, "BODY", "test3-17, createHTMLDocument");
assert_equals(htmldoc.body, htmldoc.documentElement.childNodes[1], "test3-18, createHTMLDocument");
assert_equals(htmldoc.body.childNodes.length, 0, "test3-19, createHTMLDocument");
}, "createHTMLDocument");
test(function() {
var doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
assert_not_equals(doc, null, "test4-0, createDocument");
assert_true(doc instanceof Document, "test4-1, createDocument: should be Document");
assert_equals(doc.childNodes.length, 1, "test4-2, createDocument");
assert_equals(doc.doctype, null, "test4-3, createDocument");
assert_true(doc.documentElement instanceof HTMLHtmlElement, "test4-4, createDocument: should be HTMLHtmlElement");
var doctype = document.implementation.createDocumentType("html", null, null);
doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', doctype);
assert_equals(doc.childNodes.length, 2, "test4-5, createDocument");
assert_equals(doc.doctype, doctype, "test4-6, createDocument");
assert_true(doc.documentElement instanceof HTMLHtmlElement, "test4-7, createDocument: should be HTMLHtmlElement");
doctype = document.implementation.createDocumentType(
'svg:svg', '-//W3C//DTD SVG 1.1//EN',
'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
doc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg:svg', doctype);
assert_equals(doc.childNodes.length, 2, "test4-8, createDocument");
assert_equals(doc.doctype, doctype, "test4-9, createDocument");
assert_true(doc.documentElement instanceof Element, "test4-10, createDocument: should be Element");
}, "createDocument");
</script>
</head>
</html>

View file

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
var links = document.links;
assert_equals(links, document.links);
assert_equals(links.length, 0);
var anchor = document.createElement("a");
anchor.id = "anchor-with-href";
anchor.setAttribute("href", "http://www.google.com");
document.body.appendChild(anchor);
assert_equals(links.length, 1);
anchor = document.createElement("a");
anchor.id = "anchor-without-href";
document.body.appendChild(anchor);
assert_equals(links.length, 1);
anchor.setAttribute("href", "http://www.google.com");
assert_equals(links.length, 2);
anchor.removeAttribute("href", "http://www.google.com");
assert_equals(links.length, 1);
document.body.removeChild(document.getElementById("anchor-without-href"));
assert_equals(links.length, 1);
document.body.removeChild(document.getElementById("anchor-with-href"));
assert_equals(links, document.links);
assert_equals(links.length, 0);
});
</script>
</body>
</html>

View file

@ -0,0 +1,21 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function() {
var numChanges = 0;
document.addEventListener('readystatechange', this.step_func(function() {
numChanges++;
}), true);
window.onload = this.step_func_done(function() {
assert_equals(document.readyState, 'complete');
assert_equals(numChanges, 2);
});
assert_equals(document.readyState, "loading");
});
</script>
</body>
</html>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="div" class="div-class">A</div>
<p>P</p>
<script>
test(function() {
assert_equals(document.nodeValue, null);
var div = document.getElementById("div");
assert_equals(div.nodeValue, null);
assert_equals(div.firstChild.nodeValue, "A");
div.firstChild.nodeValue = "B";
assert_equals(div.firstChild.nodeValue, "B");
var commentNode = document.createComment("comment node");
assert_equals(commentNode.nodeValue, "comment node");
});
</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<html>
<title>x</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
document.head.firstChild.appendChild(document.createElement("foo"));
assert_equals(document.title, "x");
});
</script>
</html>

View file

@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_not_equals(document.URL, null, "test1-0, URL & documentURI");
assert_not_equals(document.documentURI, null, "test1-1, URL & documentURI");
assert_equals(document.URL, document.documentURI, "test1-2, URL & documentURI");
}, "URL & documentURI");
test(function() {
var doc = new Document();
assert_equals(doc.URL, "about:blank", "test2-0, new document");
}, "new document");
test(function() {
var url = document.URL.split("/");
assert_equals(url[0], "http:", "test3-0, current document");
assert_equals(url[url.length-1], "document_url.html", "test3-1, current document");
}, "current document");
</script>
</head>
<body>
</body>
</html>

View file

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var div = document.createElement("div");
var classList = div.classList;
assert_equals(classList.length, 0);
assert_equals(classList.item(0), null);
assert_throws(null, function () {
classList.contains("");
});
assert_throws(null, function () {
classList.contains(" ");
});
var list = ["foo", " foo", "foo ", " foo ", " foo "];
for(var i = 0; i < list.length; i++) {
div.className = list[i];
assert_equals(div.className, list[i]);
assert_equals(classList.length, 1);
assert_equals(classList.item(0), "foo");
assert_equals(classList.item(1), null);
assert_equals(classList.contains("foo"), true);
assert_equals(classList.contains("bar"), false);
}
list = ["foo bar", " foo bar", " foo bar ", " foo bar "];
for(var i = 0; i < list.length; i++) {
div.className = list[i];
assert_equals(div.className, list[i]);
assert_equals(classList.length, 2);
assert_equals(classList.item(0), "foo");
assert_equals(classList.item(1), "bar");
assert_equals(classList.item(2), null);
assert_equals(classList.contains("foo"), true);
assert_equals(classList.contains("bar"), true);
assert_equals(classList.contains("baz"), false);
}
});
</script>
</head>
</html>

View file

@ -0,0 +1,67 @@
<html>
<head id="foo">
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="test" foo="bar"></div>
<script>
let element = document.getElementById("test");
test(function() {
let r1 = element.getAttribute("id");
assert_equals(r1, "test", "test1-0, Element.getAttribute().");
let r2 = element.getAttribute("foo");
assert_equals(r2, "bar", "test1-1, Element.getAttribute().");
});
test(function() {
let NAME = "hoge";
let VALUE = "fuga";
element.setAttribute(NAME, VALUE);
let r = element.getAttribute(NAME);
assert_equals(r, VALUE, "test2. Element.setAttribute().");
});
test(function() {
let NAME = "foo";
let VALUE = "mozilla";
element.setAttribute(NAME, VALUE);
let r = element.getAttribute(NAME);
assert_equals(r, VALUE, "test3, attribute update by Element.setAttribute().")
});
test(function() {
element.setAttribute("id", "bar");
element.removeAttribute("id");
let r1 = element.hasAttribute("id");
assert_equals(r1, false, "test4-0, Element.removeAttribute().");
let r2 = element.getAttribute("id");
assert_equals(r2, null, "test4-1, Element.removeAttribute().");
});
test(function() {
element.setAttribute("xml:lang", "en");
let r1 = element.hasAttribute("xml:lang");
assert_equals(r1, true, "test5-0, Element.setAttribute('xml:lang').");
let r2 = element.getAttribute("xml:lang");
assert_not_equals(r2, null, "test5-1, Element.setAttribute('xml:lang').");
});
test(function() {
assert_throws(null, function () {
element.setAttributeNS("http://example.com", "xmlns", "foo");
});
assert_throws(null, function () {
element.setAttributeNS("http://www.w3.org/2000/xmlns/", "attr", "value");
});
assert_throws(null, function () {
element.setAttributeNS("http://www.w3.org/2000/xmlns/", "prefix:attr", "value");
});
});
</script>
</body>
</html>

View file

@ -0,0 +1,23 @@
<html>
<head id="foo">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div></div>
<script>
test(function() {
var attrs = [];
for (var i = 'a'.charCodeAt(0); i != 'z'.charCodeAt(0); i++) {
document.getElementsByTagName('div')[0].setAttribute(String.fromCharCode(i),
i.toString());
}
var attributes = document.getElementsByTagName('div')[0].attributes;
for (var i = 0; i < attributes.length; i++) {
assert_equals(attributes[i].name, String.fromCharCode(i + 'a'.charCodeAt(0)));
assert_equals(attributes[i].value, (i + 'a'.charCodeAt(0)).toString());
}
});
</script>
</body>
</html>

View file

@ -0,0 +1,22 @@
<!-- Remove this and update WPT metadata once DOMTokenList.toggle (#3138) is implemented. -->
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
let div = document.createElement("div");
div.className = "foo bar";
let classList = div.classList;
div.className = "";
assert_equals(classList.item(0), null, "classList.item(0) must return null when all classes have been removed");
assert_equals(classList[0], undefined, "classList[0] must be undefined when all classes have been removed");
});
</script>
</head>
<body>
</body>
</html>

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="foo-1" class="foo"></div>
<div id="foo-2" class="baz"></div>
<script>
test(function() {
let foo1 = document.getElementById("foo-1");
let foo2 = document.getElementById("foo-2");
foo1.className += " bar";
assert_equals(foo1.className, "foo bar");
let foo3 = document.createElement("div");
foo3.id = "foo-3";
foo3.className = "foo";
document.body.appendChild(foo3);
assert_equals(foo3, document.getElementById("foo-3"));
let collection = document.getElementsByClassName("foo");
assert_equals(collection.length, 2);
assert_equals(collection[0].id, foo1.id);
assert_equals(collection[1].id, foo3.id);
collection = document.getElementsByClassName("bar");
assert_equals(collection.length, 1);
assert_equals(collection[0].id, foo1.id);
collection = document.getElementsByClassName("baz");
assert_equals(collection.length, 1);
assert_equals(collection[0].id, foo2.id);
});
</script>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="foo"></div>
<script>
test(function() {
let test = document.getElementById("foo");
assert_equals(test.matches("#foo"), true, "test-1");
assert_equals(test.matches("#not-foo"), false, "test-2");
});
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var rect = window.document.head.getBoundingClientRect();
var rects = window.document.head.getClientRects();
assert_true(rect instanceof DOMRect, "Should be DOMRect");
assert_equals(rect.top, 0);
assert_equals(rect.bottom, 0);
assert_equals(rect.left, 0);
assert_equals(rect.right, 0);
assert_equals(rect.width, 0);
assert_equals(rect.height, 0);
assert_equals(rects.length, 0);
});
</script>
</head>
</html>

View file

@ -0,0 +1,191 @@
<!DOCTYPE html>
<html>
<head>
<title>Tests for :enabled and :disabled selectors</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<button id="button-1"></button>
<button id="button-2" disabled></button>
<input id="input-1"></input>
<input id="input-2" disabled></input>
<option id="option-1"></option>
<option id="option-2" disabled></option>
<select id="select-1"></select>
<select id="select-2" disabled></select>
<textarea id="textarea-1"></textarea>
<textarea id="textarea-2" disabled></textarea>
<optgroup disabled>
<option id="option-3"></option>
</optgroup>
<fieldset disabled>
<fieldset>
<button id="button-3"></button>
<input id="input-3"></input>
<select id="select-3"></select>
<textarea id="textarea-3"></textarea>
</fieldset>
</fieldset>
<fieldset disabled>
<legend>
<button id="button-4"></button>
<input id="input-4"></input>
<select id="select-4"></select>
<textarea id="textarea-4"></textarea>
</legend>
</fieldset>
<fieldset disabled>
<legend></legend>
<legend>
<button id="button-5"></button>
<input id="input-5"></input>
<select id="select-5"></select>
<textarea id="textarea-5"></textarea>
</legend>
</fieldset>
<script>
function check_selector(elem, selector, matches) {
assert_equals(elem.matches(selector), matches);
}
function check_disabled_selector(elem, disabled) {
check_selector(elem, ":disabled", disabled);
check_selector(elem, ":enabled", !disabled);
}
test(function() {
var list, i, elem;
// Examples of elements which are never :enabled or :disabled.
list = ['div', 'p', 'body', 'head', 'span'];
for(i = 0; i < list.length; i++) {
elem = document.createElement(list[i]);
check_selector(elem, ":enabled", false);
check_selector(elem, ":disabled", false);
}
// Anchor, Area and Link elements are no longer :enabled with an href.
list = ["a", "area", "link"];
for(i = 0; i < list.length; i++) {
elem = document.createElement(list[i]);
elem.setAttribute("href", "");
check_selector(elem, ":enabled", false);
check_selector(elem, ":disabled", false);
}
// These are :enabled (and not :disabled) by default.
list = ['button', 'input', 'select', 'textarea', 'optgroup', 'option', 'fieldset'];
for(i = 0; i < list.length; i++) {
elem = document.createElement(list[i]);
check_disabled_selector(elem, false);
}
}, "Simple initialization checks");
test(function() {
var elem = document.createElement('menuitem');
check_disabled_selector(elem, false);
}, "menuitem initial state");
test(function() {
var click_count = 0;
var click_event = new Event('click', {bubbles: true, cancelable: true});
var list, elem1, elem2, elem3, elem4, elem5;
function on_click(ev) { click_count++; }
list = ['button', 'input', 'option', 'select', 'textarea'];
for(i = 0; i < list.length; i++) {
click_count = 0;
elem1 = document.getElementById(list[i] + "-1");
assert_equals(elem1.disabled, false);
elem1.addEventListener('click', on_click);
elem1.dispatchEvent(click_event);
assert_equals(click_count, 1);
elem2 = document.getElementById(list[i] + "-2");
assert_equals(elem2.disabled, true);
// Only user-generated click events are prevented.
elem2.addEventListener('click', on_click);
elem2.dispatchEvent(click_event);
assert_equals(click_count, 2);
// This should look disabled, though - missing UA's CSS for :disabled?
elem3 = document.getElementById(list[i] + "-3");
assert_equals(elem3.disabled, false);
if (list[i] == 'option') { continue; }
elem4 = document.getElementById(list[i] + "-4");
assert_equals(elem4.disabled, false);
// This should look disabled, though - missing UA's CSS for :disabled?
elem5 = document.getElementById(list[i] + "-5");
assert_equals(elem5.disabled, false);
}
}, "Document elements tests")
test(function() {
var list = ['button', 'input', 'select', 'textarea'];
var fieldset = document.createElement("fieldset");
fieldset.disabled = true;
var div = document.createElement("div");
var elem;
for(i = 0; i < list.length; i++) {
elem = document.createElement(list[i]);
check_disabled_selector(elem, false);
div.appendChild(elem);
check_disabled_selector(elem, false);
fieldset.appendChild(div);
check_disabled_selector(elem, true);
document.body.appendChild(fieldset);
check_disabled_selector(elem, true);
document.body.removeChild(fieldset);
check_disabled_selector(elem, true);
fieldset.removeChild(div);
check_disabled_selector(elem, false);
div.removeChild(elem);
check_disabled_selector(elem, false);
}
}, "JS tests (Button, Input, Select, TextArea)");
test(function() {
var optgroup = document.createElement("optgroup");
optgroup.disabled = true;
var option = document.createElement("option");
check_disabled_selector(option, false);
optgroup.appendChild(option);
check_disabled_selector(option, true);
document.body.appendChild(optgroup);
check_disabled_selector(option, true);
document.body.removeChild(optgroup);
check_disabled_selector(option, true);
optgroup.removeChild(option);
check_disabled_selector(option, false);
}, "JS tests (Option)");
</script>
</body>
</html>

View file

@ -0,0 +1,52 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<span>Paragraph containing <div>event listener</div>.</span>
<script>
test(function() {
var bodyTimes = 0;
function bodyListener(ev) {
bodyTimes++;
assert_equals(ev.currentTarget, document.getElementsByTagName('body')[0]);
assert_equals(ev.target, document.getElementsByTagName('div')[0]);
if (bodyTimes == 1) {
assert_equals(ev.eventPhase, ev.CAPTURING_PHASE);
} else if (bodyTimes == 2) {
assert_equals(ev.eventPhase, ev.BUBBLING_PHASE);
}
}
var spanTimes = 0;
function spanListener(ev) {
assert_equals(ev.currentTarget, document.getElementsByTagName('span')[0]);
assert_equals(ev.target, document.getElementsByTagName('div')[0]);
assert_equals(ev.eventPhase, ev.BUBBLING_PHASE);
spanTimes++;
}
var divTimes = 0;
function divListener(ev) {
var self = document.getElementsByTagName('div')[0];
assert_equals(ev.currentTarget, self);
assert_equals(ev.target, self);
assert_equals(ev.eventPhase, ev.AT_TARGET);
divTimes++;
}
document.getElementsByTagName('body')[0].addEventListener("foopy", this.step_func(bodyListener), true);
document.getElementsByTagName('body')[0].addEventListener("foopy", this.step_func(bodyListener), false);
document.getElementsByTagName('span')[0].addEventListener("foopy", this.step_func(spanListener), false);
document.getElementsByTagName('div')[0].addEventListener("foopy", this.step_func(divListener), false);
var ev = new Event('foopy', {bubbles: true});
assert_equals(ev.bubbles, true);
document.getElementsByTagName('div')[0].dispatchEvent(ev);
assert_equals(bodyTimes, 2, 'body listener should be called multiple times');
assert_equals(divTimes, 1, 'target listener should be called once');
assert_equals(spanTimes, 1, 'span listener should be called while bubbling');
});
</script>
</body>
</html>

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<b><b><b></b></b></b>
<script>
test(function() {
var sawmiddle = -1;
var sawouter = -1;
var step = 0;
var outerb = document.getElementsByTagName('b')[0];
var middleb = outerb.firstChild;
var innerb = middleb.firstChild;
outerb.addEventListener("x", this.step_func(function() {
middleb.addEventListener("x", this.step_func(function() {
sawmiddle = step++;
}), true);
sawouter = step++;
}), true);
innerb.dispatchEvent(new Event("x"));
assert_equals(sawmiddle, 1);
assert_equals(sawouter, 0);
});
</script>

View file

@ -0,0 +1,44 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="foo"></div>
<script>
test(function() {
var sawBubble = false;
var sawCapture = false;
var sawBubbleTwice = false;
function handler(ev) {
assert_equals(ev.eventPhase, ev.AT_TARGET);
assert_equals(sawBubble, false);
assert_equals(sawCapture, false);
sawBubble = true;
}
function handler2(ev) {
assert_equals(ev.eventPhase, ev.AT_TARGET);
assert_equals(sawBubble, true);
assert_equals(sawCapture, false);
sawCapture = true;
}
function handler3(ev) {
assert_equals(ev.eventPhase, ev.AT_TARGET);
assert_equals(sawBubble, true);
assert_equals(sawCapture, true);
sawBubbleTwice = true;
}
var target = document.getElementById('foo');
target.addEventListener('foopy', this.step_func(handler), false);
target.addEventListener('foopy', this.step_func(handler2), true);
target.addEventListener('foopy', this.step_func(handler3), false);
var ev = new Event('foopy', {bubbles: true});
target.dispatchEvent(ev);
assert_equals(sawBubble, true);
assert_equals(sawCapture, true);
assert_equals(sawBubbleTwice, true);
});
</script>
</body>
</html>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<a id="a" onclick="{">link</a>
<script>
test(function() {
var a = document.getElementById("a");
assert_equals(a.onclick, null, "invalid onclick attribute");
document.body.setAttribute("onx", "{");
document.body.setAttribute("ony", "}");
assert_equals(document.body.getAttribute("onx"), "{");
assert_equals(document.body.getAttribute("ony"), "}");
});
</script>
</body>
</html>

View file

@ -0,0 +1,40 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
function onFoopy(ev) {
window.removeEventListener('foopy', onFoopy);
assert_equals(ev instanceof expected, true);
assert_equals(ev.type, 'foopy');
}
var expected;
var events = [['HTMLEvents', Event, function(ev) { ev.initEvent('foopy', true, true); }],
['UIEvents', UIEvent, function(ev) { ev.initUIEvent('foopy', true, true, null, 0); }],
['MouseEvents', MouseEvent,
function(ev) { ev.initMouseEvent('foopy', true, true, null, 0,
0, 0, 0, 0, false, false,
false, false, 0, null); }]];
for (var i = 0; i < events.length; i++) {
addEventListener('foopy', this.step_func(onFoopy));
expected = events[i][1];
var ev = document.createEvent(events[i][0]);
events[i][2](ev);
window.dispatchEvent(ev);
}
var constructors = [Event, UIEvent, MouseEvent];
for (var i = 0; i < constructors.length; i++) {
addEventListener('foopy', this.step_func(onFoopy));
expected = constructors[i];
var ev = new constructors[i]('foopy', {cancelable: true, bubbles: true});
window.dispatchEvent(ev);
}
});
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<input id="a">
<input id="b">
<script>
test(function() {
var a = document.getElementById("a");
var b = document.getElementById("b");
assert_equals(document.activeElement, document.body);
a.focus();
assert_equals(document.activeElement, a);
b.focus();
assert_equals(document.activeElement, b);
a.blur();
assert_equals(document.activeElement, b);
b.blur();
assert_equals(document.activeElement, document.body);
});
</script>
</body>
</html>

View file

@ -0,0 +1,37 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
div {
position: relative;
top: 100px;
left: 100px;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div>my div</div>
<script>
test(function() {
assert_equals(String(DOMRect).indexOf("function DOMRect("), 0);
var elems = document.getElementsByTagName('div');
var rect = elems[0].getBoundingClientRect();
assert_true(rect instanceof DOMRect, "Should be DOMRect");
assert_greater_than_equal(rect.top, 100);
assert_greater_than_equal(rect.bottom, 200);
assert_greater_than_equal(rect.left, 100);
assert_greater_than_equal(rect.right, 200);
assert_equals(rect.width, 100);
assert_equals(rect.height, 100);
assert_equals(rect.width, rect.right - rect.left);
assert_equals(rect.height, rect.bottom - rect.top);
});
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="important" style='outline-color: #111 !important; outline-style: solid !important; outline-width: 1px !important; background-color: #222 !important; color: #FFF'></div>
<script>
test(function() {
var properties = {
'outline-color': 'important',
'outline-style': 'important',
'outline-width': 'important',
'outline': 'important',
'background-color': 'important',
'background': '',
'color': '',
};
var elem = document.getElementById('important')
for (var property in Object.keys(properties)) {
var name = Object.keys(properties)[property];
var value = properties[name];
assert_equals(elem.style.getPropertyPriority(name), value, name + ' priority');
}
});
</script>
</body>
</html>

View file

@ -0,0 +1,16 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var global = this;
test(function() {
assert_equals(window, window.window);
assert_equals(window, global);
for (var key in global) {
assert_equals(global[key], window[key]);
}
});
</script>
</head>
</html>

View file

@ -0,0 +1,113 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="foo-1" class="foo"></div>
<div id="foo-2" class="foo"></div>
<div id="bar" class="bar"></div>
<div id="live" class="live"></div>
<div id="class-example">
<p id="p1" class="aaa bbb"/>
<p id="p2" class="aaa ccc"/>
<p id="p3" class="bbb ccc"/>
</div>
<script>
let foo1 = document.getElementById("foo-1");
let foo2 = document.getElementById("foo-2");
let bar = document.getElementById("bar");
let live = document.getElementById("live");
let child = document.createElement("p");
let p1 = document.getElementById("p1");
let p2 = document.getElementById("p2");
let p3 = document.getElementById("p3");
let htmlcollection = null;
test(function() {
htmlcollection = document.getElementsByClassName("foo");
assert_equals(htmlcollection.length, 2);
assert_equals(htmlcollection.item(0), foo1);
assert_equals(htmlcollection.item(1), foo2);
assert_equals(htmlcollection.item(2), null);
assert_equals(htmlcollection.namedItem("foo-1"), foo1);
assert_equals(htmlcollection.namedItem("bar"), null);
htmlcollection = document.getElementsByClassName("FOO");
assert_equals(htmlcollection.length, 0);
htmlcollection = document.getElementsByClassName("bar");
assert_equals(htmlcollection.length, 1);
assert_equals(htmlcollection.item(0), bar);
assert_equals(htmlcollection.item(1), null);
assert_equals(htmlcollection.namedItem("bar"), bar);
}, "HTMLCollection interface");
test(function() {
htmlcollection = document.getElementsByClassName("live");
assert_equals(htmlcollection.length, 1);
assert_equals(htmlcollection.item(0), live);
let new_live = document.createElement("div");
new_live.className = "live";
document.body.appendChild(new_live);
assert_equals(htmlcollection.length, 2);
assert_equals(htmlcollection.item(1), new_live);
document.body.removeChild(new_live);
assert_equals(htmlcollection.length, 1);
}, "live HTMLCollection");
test(function() {
assert_equals(document.getElementsByTagName("DIV").length, 5);
assert_equals(document.getElementsByTagName("div").length,
document.documentElement.getElementsByTagName("div").length);
assert_equals(document.getElementsByTagName("p").length,
document.getElementById("class-example").getElementsByTagName("p").length);
}, "getElementsByTagName");
test(function() {
htmlcollection = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "div");
assert_equals(htmlcollection.length, 5);
let from_element = document.documentElement.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "div");
assert_equals(htmlcollection.length, from_element.length);
htmlcollection = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "DIV");
assert_equals(htmlcollection.length, 0);
htmlcollection = document.getElementsByTagNameNS("", "div");
assert_equals(htmlcollection.length, 0);
htmlcollection = document.getElementsByTagNameNS("invalid", "div");
assert_equals(htmlcollection.length, 0);
from_element = document.getElementById("class-example").getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "p");
assert_equals(from_element.length, 3);
}, "getElementsByTagNameNS");
test(function() {
htmlcollection = document.getElementsByClassName("aaa");
assert_equals(htmlcollection.length, 2);
assert_equals(htmlcollection.item(0), p1);
assert_equals(htmlcollection.item(1), p2);
htmlcollection = document.getElementsByClassName("ccc bbb");
assert_equals(htmlcollection.length, 1);
assert_equals(htmlcollection.item(0), p3);
htmlcollection = document.getElementsByClassName("aaa,bbb");
assert_equals(htmlcollection.length, 0);
let from_element = document.getElementById("class-example").getElementsByClassName("bbb");
assert_equals(from_element.length, 2);
assert_equals(from_element.item(0), p1);
assert_equals(from_element.item(1), p3);
}, "document.getElementsByClassName");
</script>
</body>
</html>

View file

@ -0,0 +1,47 @@
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<fieldset id="fs">
<legend>Display</legend>
<input type=radio name=a>
<fieldset>
<button>Click!</button>
</fieldset>
<keygen name="key">
<textarea>
A
</textarea>
<select>
<option value="1"> A </option>
<option value="2" selected> B </option>
</select>
<form onsubmit="return false" oninput="o.value = a.valueAsNumber + b.valueAsNumber">
<input name=a type=number step=any> +
<input name=b type=number step=any> =
<output name=c for="a b"></output>
</form>
<figure>
<object type="application/x-java-applet">
<param name="code" value="MyJavaClass">
<p>You do not have Java available, or it is disabled.</p>
</object>
<figcaption>My Java Clock</figcaption>
</figure>
</fieldset>
<script>
test(function() {
var fs = document.getElementById("fs");
assert_equals(fs.elements.length, 10);
assert_true(fs.elements[0] instanceof HTMLInputElement, "Should be HTMLInputElement");
assert_true(fs.elements[1] instanceof HTMLFieldSetElement, "Should be HTMLFieldSetElement");
assert_true(fs.elements[2] instanceof HTMLButtonElement, "Should be HTMLButtonElement");
assert_true(fs.elements[3] instanceof HTMLUnknownElement, "Should be HTMLUnknownElement");
assert_true(fs.elements[4] instanceof HTMLTextAreaElement, "Should be HTMLTextAreaElement");
assert_true(fs.elements[5] instanceof HTMLSelectElement, "Should be HTMLSelectElement");
assert_true(fs.elements[6] instanceof HTMLInputElement, "Should be HTMLInputElement");
assert_true(fs.elements[7] instanceof HTMLInputElement, "Should be HTMLInputElement");
assert_true(fs.elements[8] instanceof HTMLOutputElement, "Should be HTMLOutputElement");
assert_true(fs.elements[9] instanceof HTMLObjectElement, "Should be HTMLObjectElement");
});
</script>
</html>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<!-- \u0020 Space -->
<div id="foo-1" class="aaa&#32;foo"></div>
<!-- \u0009 Character tabulation -->
<div id="foo-2" class="bbb&#9;foo"></div>
<!-- \u000a Line feed -->
<div id="foo-3" class="ccc&#10;foo"></div>
<!-- \u000c Form feed -->
<div id="foo-4" class="ddd&#12;foo"></div>
<!-- \u000d Carriage return -->
<div id="foo-5" class="eee&#13;foo"></div>
<!-- Space -->
<div id="foo-6" class="fff foo"></div>
<!-- Non-HTML space character -->
<div id="bar" class="ggg&#11;foo"></div>
<script>
test(function() {
assert_equals(document.getElementsByClassName("foo").length, 6);
assert_not_equals(document.getElementById("bar").className, "ggg foo");
});
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<html>
<head>
<meta charset="utf8" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<title>Iframe contentDocument test.</title>
</head>
<body>
<iframe src="resources/iframe_contentDocument_inner.html" id="iframe"></iframe>
<script>
async_test(function() {
var timeout = 100;
var iframe = document.getElementById('iframe');
function test_contentWindow() {
if (!iframe.contentWindow) {
// Iframe not loaded yet, try again.
// No load event for iframe, insert bug number here.
setTimeout(this.step_func(test_contentWindow), timeout);
return;
}
assert_equals(iframe.contentDocument.getElementById('test').textContent, 'value');
this.done();
}
this.step(test_contentWindow);
});
</script>
</body>
</html>

View file

@ -0,0 +1,33 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<img src="test.png"/>
<script>
// Testing get/set of image width/height properties
async_test(function() {
var img = window.document.getElementsByTagName("img")[0];
var wait_for_img_load = this.step_func(function (f) {
if (img.width != 0) {
f();
} else {
window.setTimeout(function() { wait_for_img_load(f) }, 1);
}
});
wait_for_img_load(this.step_func_done(function() {
assert_equals(img.width, 500);
assert_equals(img.height, 378);
img.width = 200;
img.height = 100;
assert_equals(img.width, 200);
assert_equals(img.height, 100);
}));
});
</script>
</body>
</html>

View file

@ -0,0 +1,11 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body onload="t.step(function() { assert_true(event instanceof Event, 'Should be Event'); this.done(); })">
<script>
var t = async_test();
</script>
</body>
</html>

View file

@ -0,0 +1,15 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var a = document.createElement("div");
a.appendChild(document.createElement("pre")).appendChild(new Text(""));
var b = document.createElement("div");
b.appendChild(a);
assert_equals(b.innerHTML, "<div><pre></pre></div>");
});
</script>
</head>
</html>

View file

@ -0,0 +1,227 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Interfaces exposed on the window</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// This is a list of all interfaces that are exposed to every webpage.
// Please only add things to this list with great care and proper review
// from the associated module peers.
// IMPORTANT: Do not change this list without review from
// a JavaScript Engine peer!
var ecmaGlobals = [
"Array",
"ArrayBuffer",
"Boolean",
"DataView",
"Date",
"Error",
"EvalError",
"Float32Array",
"Float64Array",
"Function",
"Infinity",
"Int16Array",
"Int32Array",
"Int8Array",
"InternalError",
"Iterator",
"JSON",
"Map",
"Math",
"NaN",
"Number",
"Object",
"Proxy",
"RangeError",
"ReferenceError",
"RegExp",
"Set",
"StopIteration",
"String",
"SyntaxError",
"TypeError",
"Uint16Array",
"Uint32Array",
"Uint8Array",
"Uint8ClampedArray",
"URIError",
"WeakMap",
];
// IMPORTANT: Do not change the list below without review from a DOM peer!
var interfaceNamesInGlobalScope = [
"Attr",
"Blob",
"CanvasGradient",
"CanvasRenderingContext2D",
"CanvasPattern",
"CharacterData",
"CSSStyleDeclaration",
"DOMRect",
"Comment",
"Console",
"CustomEvent",
"DedicatedWorkerGlobalScope", // #2823
"Document",
"DocumentFragment",
"DocumentType",
"DOMException",
"DOMImplementation",
"DOMParser",
"DOMTokenList",
"DOMStringMap",
"Element",
"ErrorEvent",
"Event",
"EventTarget",
"File",
"FormData",
"HTMLAnchorElement",
"HTMLAppletElement",
"HTMLAreaElement",
"HTMLAudioElement",
"HTMLBaseElement",
"HTMLBodyElement",
"HTMLBRElement",
"HTMLButtonElement",
"HTMLCanvasElement",
"HTMLCollection",
"HTMLDataElement",
"HTMLDataListElement",
"HTMLDialogElement",
"HTMLDirectoryElement",
"HTMLDivElement",
"HTMLDListElement",
"HTMLElement",
"HTMLEmbedElement",
"HTMLFieldSetElement",
"HTMLFontElement",
"HTMLFormElement",
"HTMLFrameElement",
"HTMLFrameSetElement",
"HTMLHeadElement",
"HTMLHeadingElement",
"HTMLHRElement",
"HTMLHtmlElement",
"HTMLIFrameElement",
"HTMLImageElement",
"HTMLInputElement",
"HTMLLabelElement",
"HTMLLegendElement",
"HTMLLIElement",
"HTMLLinkElement",
"HTMLMapElement",
"HTMLMediaElement",
"HTMLMetaElement",
"HTMLMeterElement",
"HTMLModElement",
"HTMLObjectElement",
"HTMLOListElement",
"HTMLOptGroupElement",
"HTMLOptionElement",
"HTMLOutputElement",
"HTMLParagraphElement",
"HTMLParamElement",
"HTMLPreElement",
"HTMLProgressElement",
"HTMLQuoteElement",
"HTMLScriptElement",
"HTMLSelectElement",
"HTMLSourceElement",
"HTMLSpanElement",
"HTMLStyleElement",
"HTMLTableCaptionElement",
"HTMLTableCellElement",
"HTMLTableColElement",
"HTMLTableDataCellElement",
"HTMLTableElement",
"HTMLTableHeaderCellElement",
"HTMLTableRowElement",
"HTMLTableSectionElement",
"HTMLTemplateElement",
"HTMLTextAreaElement",
"HTMLTimeElement",
"HTMLTitleElement",
"HTMLTrackElement",
"HTMLUListElement",
"HTMLUnknownElement",
"HTMLVideoElement",
"ImageData",
"KeyboardEvent",
"Location",
"MessageEvent",
"MouseEvent",
"NamedNodeMap",
"Navigator",
"Node",
"NodeFilter",
"NodeIterator",
"NodeList",
"Performance",
"PerformanceTiming",
"ProcessingInstruction",
"ProgressEvent",
"Range",
"Screen",
"Storage",
"StorageEvent",
"TestBinding", // XXX
"Text",
"TextDecoder",
"TextEncoder",
"TreeWalker",
"UIEvent",
"URLSearchParams",
"ValidityState",
"WebSocket",
"Window",
"Worker",
"WorkerGlobalScope", // #2823
"WorkerLocation", // #2823
"WorkerNavigator", // #2823
"XMLHttpRequest",
"XMLHttpRequestEventTarget",
"XMLHttpRequestUpload",
];
function createInterfaceMap() {
var interfaceMap = {};
function addInterfaces(interfaces)
{
for (var entry of interfaces) {
interfaceMap[entry] = true;
}
}
addInterfaces(ecmaGlobals);
addInterfaces(interfaceNamesInGlobalScope);
addInterfaces(["EventWatcher"]);
return interfaceMap;
}
test(function() {
var interfaceMap = createInterfaceMap();
for (var name of Object.getOwnPropertyNames(window)) {
if (!/^[A-Z]/.test(name)) {
continue;
}
assert_true(name in interfaceMap,
"If this is failing: DANGER, are you sure you want to expose the new " +
"interface " + name + " to all webpages as a property on the window? " +
"Do not make a change to this file without review from jdm or Ms2ger " +
"for that specific change!");
if (name in interfaceMap) {
delete interfaceMap[name];
}
}
for (var name of Object.keys(interfaceMap)) {
assert_true(name in window, name + " should be defined on the global scope");
}
assert_equals(Object.keys(interfaceMap).length, 0,
"The following interface(s) are not enumerated: " +
Object.keys(interfaceMap).join(", "));
});
</script>

View file

@ -0,0 +1,22 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var handler = function () { };
document.onreadystatechange = handler;
var obj = {};
test(function() {
var val = Object.getOwnPropertyDescriptor(Document.prototype, "onreadystatechange").get.call(document);
assert_equals(val, handler, "test1-0, basic test");
}, "basic test");
test(function() {
var val = Object.getOwnPropertyDescriptor(Document.prototype, "onreadystatechange").get.call(obj);
assert_equals(val, undefined, "test2-0, calling getter returns undefined");
assert_equals(Document.prototype.onreadystatechange, undefined, "test2-1, property access returns undefined");
}, 'Should not throw for attribute marked "[LenientThis]"');
</script>
</head>
</html>

View file

@ -0,0 +1,32 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function() {
var onloads = 0;
function check(ev) {
assert_true(ev instanceof Event, "Should be Event");
ev.preventDefault();
assert_equals(ev.defaultPrevented, false);
assert_equals(ev.target, document);
assert_equals(ev.currentTarget, window);
}
window.onload = this.unreached_func("this inline handler should be overwritten");
window.onload = this.step_func(function(ev) {
onloads++;
assert_equals(onloads, 1);
check(ev);
});
addEventListener("load", this.step_func_done(function(ev) {
onloads++;
assert_equals(onloads, 2);
check(ev);
}));
});
</script>
</body>
</html>

View file

@ -0,0 +1,23 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
assert_equals(window.navigator, window.navigator);
assert_true(window.navigator instanceof Navigator, "Should be Navigator");
var nav = window.navigator;
assert_equals(nav.product, "Gecko");
assert_equals(nav.taintEnabled(), false);
assert_equals(nav.appName, "Netscape");
assert_equals(nav.appCodeName, "Mozilla");
assert_equals(nav.platform, "");
assert_equals(nav.appVersion, "4.0");
});
</script>
</body>
</html>

View file

@ -0,0 +1,227 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function check_copy(orig, copy, type) {
assert_not_equals(orig, copy);
assert_true(orig instanceof type, "Should be type");
assert_true(copy instanceof type, "Should be type");
}
function create_element_and_check(localName, type) {
test(function() {
var element = document.createElement(localName);
var copy = element.cloneNode();
check_copy(element, copy, type);
}, "createElement(" + localName + ")");
}
// test1: createElement
test(function() {
create_element_and_check("a", HTMLAnchorElement);
create_element_and_check("abbr", HTMLElement);
create_element_and_check("acronym", HTMLElement);
create_element_and_check("address", HTMLElement);
create_element_and_check("applet", HTMLAppletElement);
create_element_and_check("area", HTMLAreaElement);
create_element_and_check("article", HTMLElement);
create_element_and_check("aside", HTMLElement);
create_element_and_check("audio", HTMLAudioElement);
create_element_and_check("b", HTMLElement);
create_element_and_check("base", HTMLBaseElement);
create_element_and_check("bdi", HTMLElement);
create_element_and_check("bdo", HTMLElement);
create_element_and_check("bgsound", HTMLElement);
create_element_and_check("big", HTMLElement);
create_element_and_check("blockquote",HTMLElement);
create_element_and_check("body", HTMLBodyElement);
create_element_and_check("br", HTMLBRElement);
create_element_and_check("button", HTMLButtonElement);
create_element_and_check("canvas", HTMLCanvasElement);
create_element_and_check("caption", HTMLTableCaptionElement);
create_element_and_check("center", HTMLElement);
create_element_and_check("cite", HTMLElement);
create_element_and_check("code", HTMLElement);
create_element_and_check("col", HTMLTableColElement);
create_element_and_check("colgroup", HTMLTableColElement);
create_element_and_check("data", HTMLDataElement);
create_element_and_check("datalist", HTMLDataListElement);
create_element_and_check("dialog", HTMLDialogElement);
create_element_and_check("dd", HTMLElement);
create_element_and_check("del", HTMLModElement);
create_element_and_check("details", HTMLElement);
create_element_and_check("dfn", HTMLElement);
create_element_and_check("dir", HTMLDirectoryElement);
create_element_and_check("div", HTMLDivElement);
create_element_and_check("dl", HTMLDListElement);
create_element_and_check("dt", HTMLElement);
create_element_and_check("embed", HTMLEmbedElement);
create_element_and_check("fieldset", HTMLFieldSetElement);
create_element_and_check("figcaption",HTMLElement);
create_element_and_check("figure", HTMLElement);
create_element_and_check("font", HTMLFontElement);
create_element_and_check("footer", HTMLElement);
create_element_and_check("form", HTMLFormElement);
create_element_and_check("frame", HTMLFrameElement);
create_element_and_check("frameset", HTMLFrameSetElement);
create_element_and_check("h1", HTMLHeadingElement);
create_element_and_check("h2", HTMLHeadingElement);
create_element_and_check("h3", HTMLHeadingElement);
create_element_and_check("h4", HTMLHeadingElement);
create_element_and_check("h5", HTMLHeadingElement);
create_element_and_check("h6", HTMLHeadingElement);
create_element_and_check("head", HTMLHeadElement);
create_element_and_check("header", HTMLElement);
create_element_and_check("hgroup", HTMLElement);
create_element_and_check("hr", HTMLHRElement);
create_element_and_check("html", HTMLHtmlElement);
create_element_and_check("i", HTMLElement);
create_element_and_check("iframe", HTMLIFrameElement);
create_element_and_check("img", HTMLImageElement);
create_element_and_check("input", HTMLInputElement);
create_element_and_check("ins", HTMLModElement);
create_element_and_check("isindex", HTMLElement);
create_element_and_check("kbd", HTMLElement);
create_element_and_check("label", HTMLLabelElement);
create_element_and_check("legend", HTMLLegendElement);
create_element_and_check("li", HTMLLIElement);
create_element_and_check("link", HTMLLinkElement);
create_element_and_check("main", HTMLElement);
create_element_and_check("map", HTMLMapElement);
create_element_and_check("mark", HTMLElement);
create_element_and_check("marquee", HTMLElement);
create_element_and_check("meta", HTMLMetaElement);
create_element_and_check("meter", HTMLMeterElement);
create_element_and_check("nav", HTMLElement);
create_element_and_check("nobr", HTMLElement);
create_element_and_check("noframes", HTMLElement);
create_element_and_check("noscript", HTMLElement);
create_element_and_check("object", HTMLObjectElement);
create_element_and_check("ol", HTMLOListElement);
create_element_and_check("optgroup", HTMLOptGroupElement);
create_element_and_check("option", HTMLOptionElement);
create_element_and_check("output", HTMLOutputElement);
create_element_and_check("p", HTMLParagraphElement);
create_element_and_check("param", HTMLParamElement);
create_element_and_check("pre", HTMLPreElement);
create_element_and_check("progress", HTMLProgressElement);
create_element_and_check("q", HTMLQuoteElement);
create_element_and_check("rp", HTMLElement);
create_element_and_check("rt", HTMLElement);
create_element_and_check("ruby", HTMLElement);
create_element_and_check("s", HTMLElement);
create_element_and_check("samp", HTMLElement);
create_element_and_check("script", HTMLScriptElement);
create_element_and_check("section", HTMLElement);
create_element_and_check("select", HTMLSelectElement);
create_element_and_check("small", HTMLElement);
create_element_and_check("source", HTMLSourceElement);
create_element_and_check("spacer", HTMLElement);
create_element_and_check("span", HTMLSpanElement);
create_element_and_check("strike", HTMLElement);
create_element_and_check("style", HTMLStyleElement);
create_element_and_check("sub", HTMLElement);
create_element_and_check("summary", HTMLElement);
create_element_and_check("sup", HTMLElement);
create_element_and_check("table", HTMLTableElement);
create_element_and_check("tbody", HTMLTableSectionElement);
create_element_and_check("td", HTMLTableDataCellElement);
create_element_and_check("template", HTMLTemplateElement);
create_element_and_check("textarea", HTMLTextAreaElement);
create_element_and_check("th", HTMLTableHeaderCellElement);
create_element_and_check("time", HTMLTimeElement);
create_element_and_check("title", HTMLTitleElement);
create_element_and_check("tr", HTMLTableRowElement);
create_element_and_check("tt", HTMLElement);
create_element_and_check("track", HTMLTrackElement);
create_element_and_check("u", HTMLElement);
create_element_and_check("ul", HTMLUListElement);
create_element_and_check("var", HTMLElement);
create_element_and_check("video", HTMLVideoElement);
create_element_and_check("unknown", HTMLUnknownElement);
create_element_and_check("wbr", HTMLElement);
}, "");
test(function() {
var fragment = document.createDocumentFragment();
var copy = fragment.cloneNode();
check_copy(fragment, copy, DocumentFragment);
}, "createDocumentFragment");
test(function() {
var text = document.createTextNode("hello world");
var copy = text.cloneNode();
check_copy(text, copy, Text);
assert_equals(text.data, copy.data);
assert_equals(text.wholeText, copy.wholeText);
}, "createTextNode");
test(function() {
var comment = document.createComment("a comment");
var copy = comment.cloneNode();
check_copy(comment, copy, Comment);
assert_equals(comment.data, copy.data);
}, "createComment");
test(function() {
var pi = document.createProcessingInstruction("target", "data");
var copy = pi.cloneNode();
check_copy(pi, copy, ProcessingInstruction);
assert_equals(pi.data, copy.data);
assert_equals(pi.target, pi.target);
}, "createProcessingInstruction");
test(function() {
var doctype = document.implementation.createDocumentType("html", "public", "system");
var copy = doctype.cloneNode();
check_copy(doctype, copy, DocumentType);
assert_equals(doctype.name, copy.name);
assert_equals(doctype.publicId, copy.publicId);
assert_equals(doctype.systemId, copy.systemId);
}, "implementation.createDocumentType");
test(function() {
// FIXME: https://github.com/mozilla/servo/issues/1509
}, "implementation.createDocument");
test(function() {
var html = document.implementation.createHTMLDocument("title");
var copy = html.cloneNode();
check_copy(html, copy, Document);
assert_equals(html.title, copy.title);
}, "implementation.createHTMLDocument");
test(function() {
var parent = document.createElement("div");
var child1 = document.createElement("div");
var child2 = document.createElement("div");
var grandChild = document.createElement("div");
child2.appendChild(grandChild);
parent.appendChild(child1);
parent.appendChild(child2);
var deep = true;
var copy = parent.cloneNode(deep);
check_copy(parent, copy, HTMLDivElement);
assert_equals(copy.childNodes.length, 2);
check_copy(child1, copy.childNodes[0], HTMLDivElement);
assert_equals(copy.childNodes[0].childNodes.length, 0);
check_copy(child2, copy.childNodes[1], HTMLDivElement);
assert_equals(copy.childNodes[1].childNodes.length, 1);
check_copy(grandChild, copy.childNodes[1].childNodes[0], HTMLDivElement);
deep = false;
copy = parent.cloneNode(deep);
check_copy(parent, copy, HTMLDivElement);
assert_equals(copy.childNodes.length, 0);
}, "node with children");
</script>
</head>
</html>

View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var elem = document.createElement("div");
var other = document.createElement("div");
assert_equals(elem.compareDocumentPosition(elem),0);
var nonTree = elem.compareDocumentPosition(other);
var prefix = Node.DOCUMENT_POSITION_DISCONNECTED + Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
assert_equals(nonTree == prefix + Node.DOCUMENT_POSITION_FOLLOWING || nonTree == prefix + Node.DOCUMENT_POSITION_PRECEDING,
true);
elem.appendChild(other);
assert_equals(elem.compareDocumentPosition(other), Node.DOCUMENT_POSITION_CONTAINED_BY + Node.DOCUMENT_POSITION_FOLLOWING);
assert_equals(other.compareDocumentPosition(elem), Node.DOCUMENT_POSITION_CONTAINS + Node.DOCUMENT_POSITION_PRECEDING);
var another = document.createElement("div");
other.appendChild(another);
assert_equals(elem.compareDocumentPosition(another), Node.DOCUMENT_POSITION_CONTAINED_BY + Node.DOCUMENT_POSITION_FOLLOWING);
assert_equals(another.compareDocumentPosition(elem), Node.DOCUMENT_POSITION_CONTAINS + Node.DOCUMENT_POSITION_PRECEDING);
var follower = document.createElement("div");
elem.appendChild(follower);
var preceder = document.createElement("div");
another.appendChild(preceder);
assert_equals(another.compareDocumentPosition(follower), Node.DOCUMENT_POSITION_FOLLOWING);
assert_equals(follower.compareDocumentPosition(another), Node.DOCUMENT_POSITION_PRECEDING);
assert_equals(follower.compareDocumentPosition(preceder), Node.DOCUMENT_POSITION_PRECEDING);
});
</script>
</head>
</html>

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var parent = document.createElement("div");
var child = document.createElement("div");
var child_of_child = document.createElement("div");
var other = document.createElement("div");
child.appendChild(child_of_child);
parent.appendChild(child);
assert_equals(parent.contains(parent), true, "test1-0, Node.contains");
assert_equals(parent.contains(child), true, "test1-1, Node.contains");
assert_equals(parent.contains(child_of_child), true, "test1-2, Node.contains");
assert_equals(parent.contains(other), false, "test1-3, Node.contains");
});
</script>
</head>
</html>

View file

@ -0,0 +1,23 @@
<!doctype html>
<html>
<head>
<title>Node.insertBefore</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script type="text/javascript">
test(function() {
var root = document.createElement("div");
var after = document.createElement("div");
var before = document.createElement("div");
root.appendChild(after);
assert_equals(root.insertBefore(before, after), before, "test1-0, insertBefore");
assert_equals(root.childNodes[0], before, "test1-1, insertBefore");
assert_equals(root.childNodes[1], after, "test1-2, insertBefore");
});
</script>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var elem = document.createElement("div");
var other = document.createElement("div");
assert_equals(elem.isEqualNode(elem), true);
assert_equals(elem.isEqualNode(other), true);
assert_equals(other.isEqualNode(elem), true);
assert_equals(elem.isEqualNode(document), false);
}, "simple checks");
test(function() {
var parent_elem = document.createElement("div");
var child_elem = document.createElement("div");
parent_elem.appendChild(child_elem);
var other_parent = document.createElement("div");
var other_child = document.createElement("div");
other_parent.appendChild(other_child);
assert_equals(parent_elem.isEqualNode(other_parent), true);
assert_equals(child_elem.isEqualNode(other_child), true);
var child_text = document.createTextNode("lorem ipsum");
child_elem.appendChild(child_text);
assert_equals(parent_elem.isEqualNode(other_parent), false);
assert_equals(child_elem.isEqualNode(other_child), false);
}, "non-element children");
</script>
</head>
</html>

View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
var parent1 = document.createElement("div");
var child1 = document.createTextNode("aaa");
var child2 = document.createTextNode("");
var child3 = document.createTextNode("bb");
var parent2 = document.createElement("div");
parent1.appendChild(child1);
parent1.appendChild(child2);
parent1.appendChild(child3);
parent2.appendChild(document.createTextNode(""));
parent1.normalize();
parent2.normalize();
assert_equals(Array.prototype.map.call(parent1.childNodes, function(el) {return el.length}).indexOf(0), -1, "Node.normalize removes empty text nodes");
assert_equals(parent1.childNodes.length, 1, "Node.normalize merges text nodes in one");
assert_equals(parent1.childNodes[0].length, 5, "test 1-2, Node.normalize merges text nodes values");
assert_equals(parent2.childNodes.length, 0, "Node.normalize removes empty text nodes even if there is only one text node");
assert_equals(child2.textContent, "", "Node.normalize doesn't change removed children original content")
assert_equals(child3.textContent, "bb", "Node.normalize doesn't change removed children original content")
});
</script>
</body>
</html>

View file

@ -0,0 +1,48 @@
<!doctype html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
var root = document.createElement("div");
var elem = document.createElement("div");
var foo = document.createTextNode("foo");
var bar = document.createTextNode("bar");
elem.appendChild(bar);
assert_equals(elem.replaceChild(bar, bar), bar, "test1-0, 1-to-1");
assert_equals(elem.childNodes[0], bar, "test1-1, 1-to-1");
root.appendChild(foo);
assert_equals(root.replaceChild(bar, foo), foo, "test1-2, 1-to-1");
assert_equals(elem.childNodes.length, 0, "test1-3, 1-to-1");
assert_equals(root.childNodes[0], bar, "test1-4, 1-to-1");
elem.appendChild(foo);
assert_equals(root.replaceChild(elem, bar), bar, "test1-5, 1-to-1");
assert_equals(root.childNodes[0].childNodes[0], foo, "test1-6, 1-to-1");
}, "1-to-1");
test(function() {
var doc_doctype = document.doctype;
var new_doctype = document.implementation.createDocumentType("html", null, null);
assert_not_equals(doc_doctype, new_doctype, "test2-0, doctype");
assert_equals(document.replaceChild(new_doctype, doc_doctype), doc_doctype, "test2-1, doctype");
assert_equals(document.doctype, new_doctype, "test2-2, doctype");
}, "doctype");
test(function() {
var doc_elem = document.documentElement;
var new_elem = document.createElement("html");
assert_not_equals(doc_elem, new_elem, "test3-0, documentElement");
assert_equals(document.replaceChild(new_elem, doc_elem), doc_elem, "test3-1, documentElement");
assert_equals(document.documentElement, new_elem, "test3-2, documentElement");
}, "documentElement");
</script>
</body>
</html>

View file

@ -0,0 +1,71 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="foo"></div>
<div id="foo\bar"></div>
<div id="foo:bar"></div>
<div id="bar" class="myClass"></p>
<script>
test(function() {
let div = document.getElementById("foo");
assert_equals(document.querySelector("#foo"), div);
div = document.getElementById("foo\\bar");
assert_equals(document.querySelector("#foo\\\\bar"), div);
div = document.getElementById("foo:bar");
assert_equals(document.querySelector("#foo\\:bar"), div);
div = document.getElementById("bar");
assert_equals(document.querySelector("div.myClass"), div);
assert_equals(document.querySelector("div:nth-of-type(4)"), div);
}, "Document");
test(function() {
let body = document.body;
let div = document.getElementById("foo");
assert_equals(body.querySelector("#foo"), div);
div = document.getElementById("foo\\bar");
assert_equals(body.querySelector("#foo\\\\bar"), div);
div = document.getElementById("foo:bar");
assert_equals(body.querySelector("#foo\\:bar"), div);
div = document.getElementById("bar");
assert_equals(body.querySelector("div.myClass"), div);
assert_equals(body.querySelector("div:nth-of-type(4)"), div);
}, "Element");
test(function() {
let docfrag = document.createDocumentFragment();
let div = document.createElement("div");
div.id = "foo";
div.className = "myClass";
let child = document.createElement("div");
div.appendChild(child);
docfrag.appendChild(div);
let p = document.createElement("p");
p.id = "bar";
p.className = "myClass";
docfrag.appendChild(p);
assert_equals(docfrag.querySelector("#foo"), div);
assert_equals(docfrag.querySelector("div.myClass"), div);
assert_equals(docfrag.querySelector("#bar"), p);
assert_equals(docfrag.querySelector("p.myClass"), p);
assert_equals(docfrag.querySelector(".myClass"), div);
assert_equals(docfrag.querySelector("div > div"), child);
}, "DocumentFragment");
</script>
</body>
</html>

View file

@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="parent">
<div id="foo" class="test"></div>
<div id="bar" class="test"></div>
<div id="baz" class="test"></div>
</div>
<script>
let foo = document.getElementById("foo");
let bar = document.getElementById("bar");
let baz = document.getElementById("baz");
test(function() {
let nodelist = document.querySelectorAll(".test");
assert_true(nodelist instanceof NodeList, "Should be NodeList");
assert_equals(nodelist.length, 3);
assert_equals(nodelist.item(0), foo);
assert_equals(nodelist.item(1), bar);
assert_equals(nodelist.item(2), baz);
nodelist = document.querySelectorAll("div > .test");
assert_equals(nodelist.length, 3);
}, "Document");
test(function() {
let div = document.getElementById("parent");
let nodelist = div.querySelectorAll(".test");
assert_equals(nodelist.length, 3);
nodelist = div.querySelectorAll("div:nth-of-type(1)");
assert_equals(nodelist.item(0), div);
}, "Element");
test(function() {
let docfrag = document.createDocumentFragment();
let div = document.createElement("div");
div.id = "foo";
div.className = "myClass";
let child = document.createElement("div");
div.appendChild(child);
docfrag.appendChild(div);
let nodelist = docfrag.querySelectorAll("#foo");
assert_equals(nodelist.item(0), div);
nodelist = docfrag.querySelectorAll("#foo:nth-child(1)");
assert_equals(nodelist.item(0), div);
}, "DocumentFragment");
</script>
</body>
</html>

View file

@ -0,0 +1,26 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="div1"></div>
<script>
test(function() {
assert_true(document.documentElement.parentNode instanceof Document, "Should be Document");
assert_equals(document.documentElement.parentElement, null);
var elem = document.createElement("p");
assert_equals(elem.parentNode, null);
assert_equals(elem.parentElement, null);
var child = document.createElement("p");
elem.appendChild(child);
assert_equals(child.parentNode, elem);
assert_equals(child.parentElement, elem);
});
</script>
</body>
</html>

View file

@ -0,0 +1,16 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
assert_equals(window.document.title, '');
window.document.title = 'foo';
assert_equals(window.document.title, 'foo');
});
</script>
</body>
</html>

View file

@ -0,0 +1 @@
<html><body><div id="test">value</div></body></html>

View file

@ -0,0 +1,105 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function() {
var executed = 0;
window.ok = this.step_func(function() {
++executed;
})
window.fail = this.unreached_func()
window.onload = this.step_func_done(function() {
assert_equals(executed, 22);
});
});
</script>
<script type="">
ok('type is empty string');
</script>
<script language="">
ok('language is empty string');
</script>
<script type="text/javascript" language="vbscript">
ok('type is text/javascript, language ignored');
</script>
<script type="" language="fooscript">
ok('type is empty string, language ingored');
</script>
<script language="javascript">
ok('language is javascript');
</script>
<script language="ecmascript">
ok('language is ecmascript');
</script>
<!-- list found at http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting.html#support-the-scripting-language -->
<script type="application/ecmascript">
ok('type is application/ecmascript');
</script>
<script type="application/javascript">
ok('type is application/javascript');
</script>
<script type="application/x-ecmascript">
ok('type is application/x-ecmascript');
</script>
<script type="application/x-javascript">
ok('type is application/x-javascript');
</script>
<script type="text/ecmascript">
ok('type is text/ecmascript');
</script>
<script type="text/javascript">
ok('type is text/javascript');
</script>
<script type="text/javascript1.0">
ok('type is text/javascript1.0');
</script>
<script type="text/javascript1.1">
ok('type is text/javascript1.1');
</script>
<script type="text/javascript1.2">
ok('type is text/javascript1.2');
</script>
<script type="text/javascript1.3">
ok('type is text/javascript1.3');
</script>
<script type="text/javascript1.4">
ok('type is text/javascript1.4');
</script>
<script type="text/javascript1.5">
ok('type is text/javascript1.5');
</script>
<script type="text/jscript">
ok('type is text/jsscript');
</script>
<script type="text/livescript">
ok('type is text/livescript');
</script>
<script type="text/x-ecmascript">
ok('type is text/x-ecmascript');
</script>
<script type="text/x-javascript">
ok('type is text/x-javascript');
</script>
<!-- should not execute -->
<script type=" ">
fail('type is space');
</script>
<script type="foo">
fail('type is unknown');
</script>
<script type="text/javascript1.6">
fail('type is unknown');
</script>
<script language="text/javascript">
fail('language is text/javascript');
</script>
</body>
</html>

View file

@ -0,0 +1,17 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
// Delete keys that don't exist in either localStorage
// or sessionStorage.
delete localStorage.a;
delete sessionStorage.a;
});
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -0,0 +1,19 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div>this is
text content</div>
<script>
test(function() {
var div = document.getElementsByTagName('div')[0];
assert_equals(div.textContent, "this is\n text content");
var newContent = "new text con\ntent";
div.textContent = newContent;
assert_equals(div.textContent, newContent);
});
</script>
</body>
</html>

View file

@ -0,0 +1,14 @@
<html>
<head>
<title>starting title</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.title, "starting title");
document.title = "new title";
assert_equals(document.title, "new title");
});
</script>
</head>
</html>

View file

@ -0,0 +1,9 @@
<!-- crashtest -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
new CustomEvent("foo", { detail: null });
gc();
});
</script>

View file

@ -0,0 +1,24 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<select id="sel"></select>
<script>
test(function() {
var div = document.createElement('div');
var optgroup = document.createElement('optgroup');
var sel = document.getElementById('sel');
var opt = document.createElement('option');
sel.add(opt);
sel.add(optgroup);
sel.add(opt, div);
sel.add(optgroup, div);
sel.add(opt, 5);
sel.add(optgroup, 5);
assert_throws(null, function() { sel.add(div) });
sel.add(optgroup, function() {})
});
</script>
</head>
</html>

View file

@ -0,0 +1,15 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
assert_equals(window, window.self);
assert_true(window.self instanceof Window, "Should be Window");
});
</script>
</body>
</html>

View file

@ -0,0 +1,30 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
assert_not_equals(window.performance, undefined);
assert_true(window.performance instanceof Performance, "Should be Performance");
assert_not_equals(window.performance.timing, undefined);
assert_true(window.performance.timing instanceof PerformanceTiming, "Should be PerformanceTiming");
assert_greater_than(window.performance.timing.navigationStart, 0);
var last = window.performance.now();
assert_greater_than(last, 0);
// Check that window.performance.now() is monotonically increasing
for (var i = 0; i < 100; i++) {
var next = window.performance.now();
assert_greater_than(next, last);
last = next;
}
});
</script>
</body>
</html>

View file

@ -0,0 +1,22 @@
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function() {
var x = 0;
var intervalID = setInterval(this.step_func(function() {
x += 1;
if (x == 2) {
clearInterval(intervalID);
setTimeout(this.step_func_done(function() {
assert_equals(x, 2);
}), 300);
}
}), 10);
});
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<html>
<head id="foo">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div></div>
<script>
test(function() {
window.abcd = 15;
assert_equals(window.abcd, 15);
assert_equals(Object.getOwnPropertyDescriptor(window, 'abcd').value, 15);
assert_equals(window.hasOwnProperty('abcd'), true);
assert_equals('location' in window, true);
// Can't set indexed properties
window[100] = "abc";
assert_equals(window[100], undefined);
assert_equals(Object.getOwnPropertyDescriptor(window, 1000), undefined);
});
test(function() {
assert_own_property(window, 'location')
}, "Unforgeable location");
</script>
</body>
</html>