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

@ -1,11 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script>
is_function(DOMParser, "DOMParser");
let parser = new DOMParser();
is_a(parser, DOMParser);
is_a(parser.parseFromString("", "text/html"), Document);
</script>
</head>
</html>

View file

@ -1,16 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script>
is_function(Event, "Event");
let ev = new Event("foopy", {cancelable: true});
is_a(ev, Event);
is(ev.type, 'foopy');
is(ev.defaultPrevented, false);
ev.preventDefault();
is(ev.defaultPrevented, true);
</script>
</head>
</html>

View file

@ -1,16 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script>
is_function(MouseEvent, "MouseEvent");
let ev = new MouseEvent("press", {bubbles: true, screenX: 150, detail: 100});
is_a(ev, Event);
is_a(ev, UIEvent);
is_a(ev, MouseEvent);
is(ev.screenX, 150);
is(ev.detail, 100);
</script>
</head>
</html>

View file

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

View file

@ -1,19 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script>
waitForExplicitFinish();
function check_onload(listener) {
is(listener, window);
var ev = new Event('click', {bubbles: true, cancelable: true});
document.body.dispatchEvent(ev);
}
function check_onclick(listener) {
is(listener, document.body);
finish();
}
</script>
</head>
<body onload="check_onload(this)" onclick="check_onclick(this)">
</body>
</html>

View file

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

View file

@ -1,18 +0,0 @@
<html>
<head>
<script src="./harness.js"></script>
<a id="foo" href="/nonexistent">test link</a>
<script>
var link = document.getElementById('foo');
link.addEventListener('click', function(ev) {
ev.preventDefault();
});
var ev = new Event('click', {bubbles: true, cancelable: true});
link.dispatchEvent(ev);
setTimeout(function() {
is(true, true, "load probably would have occurred by now");
finish();
}, 500);
</script>
</head>
</html>

View file

@ -1,143 +0,0 @@
<html>
<head>
<meta charset="utf-8">
<title>test_binding
page </title>
<base href="./"></base>
<script src="harness.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>
function check_collection(obj, num, classes, name) {
is_a(obj, HTMLCollection);
is(obj.length, num);
is(obj[obj.length], undefined);
if (classes === undefined)
return;
classes = [Element, HTMLElement].concat(classes);
for (var i=0; i<obj.length; i++) {
is_not(obj[i], undefined);
is(obj[i].tagName, name);
for (var j=0; j<classes.length; j++) {
is_a(obj[i], 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, 2, [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

@ -1,18 +0,0 @@
<html>
<head>
<title></title>
<script src="harness.js"></script>
</head>
<body>
<script>
var elem = document.createElement("foo");
is(elem.tagName, "FOO");
var elem = document.createElement("p");
is_a(elem, HTMLParagraphElement);
var elem = document.createElement("sPAn");
is_a(elem, HTMLSpanElement);
var text = document.createTextNode("hello");
is_a(text, Text);
</script>
</body>
</html>

View file

@ -1,12 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script>
is_a(window, Window);
is_a(document.documentElement, HTMLHtmlElement);
is_a(document.documentElement.firstChild, HTMLHeadElement);
is(document.documentElement.nextSibling, null);
is_a(document, Document);
</script>
</head>
</html>

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head >
<title></title>
<script src="harness.js"></script>
</head>
<body>
<input id="foo" type="text"></input>
<script>
is_not(document.activeElement, null, "test_1.1, document.activeElement");
is(document.activeElement, document.body, "test_1.2, document.activeElement");
document.getElementById('foo').focus();
is_not(document.activeElement, null, "test_2.1, document.activeElement");
is(document.activeElement, document.getElementById("foo"), "test_2.2, document.activeElement");
</script>
</body>
</html>

View file

@ -1,71 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
</head>
<body>
<script>
// test1: existing document's body
{
is_not(document.body, null, "test1-0, existing document's body");
is_a(document.body, HTMLBodyElement, "test1-1, exising document's body");
is(document.body && document.body.tagName, "BODY", "test1-2, existing document's body");
}
// test2: replace document's body with new body
{
let new_body = document.createElement("body");
is_not(new_body, null, "test2-0, replace document's body with new body");
document.body = new_body;
is(new_body, document.body, "test2-1, replace document's body with new body");
}
// test3: replace document's body with new frameset
{
let new_frameset = document.createElement("frameset");
is_not(new_frameset, null, "test2-0, replace document's body with new frameset");
document.body = new_frameset;
is(new_frameset, document.body, "test2-1, replace document's body with new frameset");
}
// test4: append an invalid element to a new document
{
let new_document = new Document();
new_document.appendChild(new_document.createElement("html"));
let new_div = new_document.createElement("div");
is_not(new_div, null, "test4-0, append an invalid element to a new document");
should_throw(function() {
new_document.body = new_div;
});
is(new_document.body, null, "test4-1, append an invalid element to a new document");
}
// test5: append body to a new document
{
let new_document = document.implementation.createHTMLDocument();
let new_body = new_document.createElement("body");
is_not(new_body, null, "test5-0, append body to a new document");
is_a(new_body, HTMLBodyElement, "test5-1, append body to a new document");
is(new_body && new_body.tagName, "BODY", "test5-2, append body to a new document");
new_document.body = new_body;
is(new_document.body, new_body, "test5-3, append body to a new document");
}
// test6: append frameset to a new document
{
let new_document = document.implementation.createHTMLDocument();
let new_frameset = new_document.createElement("frameset");
is_not(new_frameset, null, "test6-0, append frameset to a new document");
is_a(new_frameset, HTMLFrameSetElement, "test6-1, append frameset to a new document");
is(new_frameset && new_frameset.tagName, "FRAMESET", "test6-2, append frameset to a new document");
new_document.body = new_frameset;
is(new_document.body, new_frameset, "test6-3, append frameset to a new document");
}
</script>
</body>
</html>

View file

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

View file

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
<script>
// test1: default characterSet
{
// FIXME: https://github.com/mozilla-servo/libhubbub/issues/5
is(document.characterSet, "UTF-8", "test1-0, default characterSet");
}
</script>
</head>
</html>

View file

@ -1,13 +0,0 @@
<!DOCTYPE html>
<meta charset="unknown-charset">
<html>
<head>
<script src="harness.js"></script>
<script>
// test1: unknown charset
{
is(document.characterSet, "UTF-8", "test1-0, unknown charset");
}
</script>
</head>
</html>

View file

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

View file

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

View file

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
<script>
// test1: HTML document
{
is_a(document, Document, "test1-0, HTML document");
is(document.contentType, "text/html", "test1-1, HTML document");
}
// test2: XML document
{
var doc = new Document;
is_a(doc, Document, "test2-0, XML document");
is(doc.contentType, "application/xml", "test2-1, XML document");
}
</script>
</head>
</html>

View file

@ -1,19 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
</head>
<datalist id="id">
<option value="A">
<option value="B">
<p>P</p>
<div>DIV</div>
<option value="C">
</datalist>
<script>
var datalist = document.getElementById("id");
is(datalist.options.length, 3);
is_a(datalist.options[0], HTMLOptionElement);
is_a(datalist.options[1], HTMLOptionElement);
is_a(datalist.options[2], HTMLOptionElement);
</script>
</html>

View file

@ -1,10 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
</head>
<body>
<script>
is(document.defaultView, window);
</script>
</body>
</html>

View file

@ -1,14 +0,0 @@
<html>
<head >
<title></title>
<script src="harness.js"></script>
</head>
<body>
<div name="foo"></div>
<script>
let nameList = document.getElementsByName("foo");
is_a(nameList, NodeList);
is_not_a(nameList, HTMLCollection);
</script>
</body>
</html>

View file

@ -1,45 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
</head>
<body>
<script>
// test1: existing document's head
{
is_not(document.head, null, "test1-0, existing document's head");
is_a(document.head, HTMLHeadElement, "test1-1, exising document's head");
is(document.head && document.head.tagName, "HEAD", "test1-2, existing document's head");
}
// test2: append head to a new document
{
let new_document = new Document();
new_document.appendChild(new_document.createElement("html"));
let new_head = new_document.createElement("head");
is_not(new_head, null, "test2-0, append head to a new document");
is_a(new_head, HTMLHeadElement, "test2-1, append head to a new document");
is(new_head && new_head.tagName, "head", "test2-2, append head to a new document");
// Document::head is read-only.
new_document.head = new_head;
is(new_document.head, null, "test2-3, append head to a new document");
new_document.documentElement.appendChild(new_head);
is(new_document.head, new_head, "test2-4, append head to a new document");
}
// test3: head's parent should be document element
{
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);
is(new_document.head, null, "test3-0, head's parent should be document element");
}
</script>
</body>
</html>

View file

@ -1,79 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script>
// test1: basic test
{
is_not(document.implementation, null, "test1-0, basic test");
is_a(document.implementation, DOMImplementation, "test1-1, basic test");
var implementation = document.implementation;
is(document.implementation, implementation, "test1-2, basic test");
}
// test2: createDocumentType
{
is(document.doctype, null, "test2-0, createDocumentType");
var doctype = document.implementation.createDocumentType("html", null, null);
is_a(doctype && doctype, DocumentType, "test2-1, createDocumentType");
doctype = document.implementation.createDocumentType("html:html", null, null);
is_a(doctype && doctype, DocumentType, "test2-2, createDocumentType");
}
// test3: createHTMLDocument
{
var htmldoc = document.implementation.createHTMLDocument("example title");
is_not(htmldoc, null, "test3-0, createHTMLDocument");
is_a(htmldoc, Document, "test3-1, createHTMLDocument");
is(htmldoc.childNodes.length, 2, "test3-3, createHTMLDocument");
is_a(htmldoc.doctype && htmldoc.doctype, DocumentType, "test3-4, createHTMLDocument");
is(htmldoc.doctype.name, "html", "test3-5, createHTMLDocument");
is_a(htmldoc.documentElement && htmldoc.documentElement, HTMLHtmlElement, "test3-6, createHTMLDocument");
is(htmldoc.documentElement.childNodes.length, 2, "test3-7, createHTMLDocument");
is(htmldoc.documentElement.tagName, "HTML", "test3-8, createHTMLDocument");
is_a(htmldoc.head && htmldoc.head, HTMLHeadElement, "test3-9, createHTMLDocument");
is(htmldoc.head.tagName, "HEAD", "test3-10, createHTMLDocument");
is(htmldoc.head, htmldoc.documentElement.childNodes[0], "test3-11, createHTMLDocument");
is(htmldoc.head.childNodes.length, 1, "test3-12, createHTMLDocument");
is_a(htmldoc.head.childNodes[0], HTMLTitleElement, "test3-13, createHTMLDocument");
is(htmldoc.head.childNodes[0].tagName, "TITLE", "test3-14, createHTMLDocument");
is(htmldoc.title, "example title", "test3-15, createHTMLDocument");
is_a(htmldoc.body && htmldoc.body, HTMLBodyElement, "test3-16, createHTMLDocument");
is(htmldoc.body.tagName, "BODY", "test3-17, createHTMLDocument");
is(htmldoc.body, htmldoc.documentElement.childNodes[1], "test3-18, createHTMLDocument");
is(htmldoc.body.childNodes.length, 0, "test3-19, createHTMLDocument");
}
// test4: createDocument
{
var doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
is_not(doc, null, "test4-0, createDocument");
is_a(doc, Document, "test4-1, createDocument");
is(doc.childNodes.length, 1, "test4-2, createDocument");
is(doc.doctype, null, "test4-3, createDocument");
is_a(doc.documentElement, HTMLHtmlElement, "test4-4, createDocument");
var doctype = document.implementation.createDocumentType("html", null, null);
doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', doctype);
is(doc.childNodes.length, 2, "test4-5, createDocument");
is(doc.doctype, doctype, "test4-6, createDocument");
is_a(doc.documentElement, HTMLHtmlElement, "test4-7, createDocument");
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);
is(doc.childNodes.length, 2, "test4-8, createDocument");
is(doc.doctype, doctype, "test4-9, createDocument");
is_a(doc.documentElement, Element, "test4-10, createDocument");
}
</script>
</head>
</html>

View file

@ -1,16 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
</head>
<body onload="is(document.readyState, 'complete'); is(gNumChanges, 2); finish()">
<script>
waitForExplicitFinish();
gNumChanges = 0;
document.addEventListener('readystatechange', function() {
gNumChanges++;
}, true);
is(document.readyState, "loading");
</script>
</body>
</html>

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<script src="harness.js"></script>
<body>
<div id="div" class="div-class">A</div>
<p>P</p>
<script>
is(document.nodeValue, null);
var div = document.getElementById("div");
is(div.nodeValue, null);
is(div.firstChild.nodeValue, "A");
div.firstChild.nodeValue = "B";
is(div.firstChild.nodeValue, "B");
var commentNode = document.createComment("comment node");
is(commentNode.nodeValue, "comment node");
</script>
</body>
</html>

View file

@ -1,8 +0,0 @@
<html>
<title>x</title>
<script src="harness.js"></script>
<script>
document.head.firstChild.appendChild(document.createElement("foo"));
is(document.title, "x");
</script>
</html>

View file

@ -1,30 +0,0 @@
<!doctype html>
<html>
<head>
<title></title>
<script src="harness.js"></script>
<script>
// test1: URL & documentURI
{
is_not(document.URL, null, "test1-0, URL & documentURI");
is_not(document.documentURI, null, "test1-1, URL & documentURI");
is(document.URL, document.documentURI, "test1-2, URL & documentURI");
}
// test2: new document
{
var doc = new Document();
is(doc.URL, "about:blank", "test2-0, new document");
}
// test3: current document
{
var url = document.URL.split("/");
is(url[0], "file:", "test3-0, current document");
is(url[url.length-1], "test_document_url.html", "test3-1, current document");
}
</script>
</head>
<body>
</body>
</html>

View file

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
<script>
var div = document.createElement("div");
var classList = div.classList;
is(classList.length, 0);
is(classList.item(0), null);
should_throw(function () {
classList.contains("");
});
should_throw(function () {
classList.contains(" ");
});
var list = ["foo", " foo", "foo ", " foo ", " foo "];
for(var i = 0; i < list.length; i++) {
div.className = list[i];
is(div.className, list[i]);
is(classList.length, 1);
is(classList.item(0), "foo");
is(classList.item(1), null);
is(classList.contains("foo"), true);
is(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];
is(div.className, list[i]);
is(classList.length, 2);
is(classList.item(0), "foo");
is(classList.item(1), "bar");
is(classList.item(2), null);
is(classList.contains("foo"), true);
is(classList.contains("bar"), true);
is(classList.contains("baz"), false);
}
</script>
</head>
</html>

View file

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

View file

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

View file

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
</head>
<body>
<div id="foo"></div>
<script>
let test = document.getElementById("foo");
is(test.matches("#foo"), true, "test-1");
is(test.matches("#not-foo"), false, "test-2");
</script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script>
var rect = window.document.head.getBoundingClientRect();
var rects = window.document.head.getClientRects();
is_a(rect, DOMRect);
is(rect.top, 0);
is(rect.bottom, 0);
is(rect.left, 0);
is(rect.right, 0);
is(rect.width, 0);
is(rect.height, 0);
is(rects.length, 0);
</script>
</head>
</html>

View file

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

View file

@ -1,20 +0,0 @@
<!DOCTYPE html>
<script src="harness.js"></script>
<b><b><b></b></b></b>
<script>
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", function() {
middleb.addEventListener("x", function() {
sawmiddle = step++;
}, true);
sawouter = step++;
}, true);
innerb.dispatchEvent(new Event("x"));
is(sawmiddle, 1);
is(sawouter, 0);
</script>

View file

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

View file

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

View file

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="harness.js"></script>
</head>
<body>
<input id="a">
<input id="b">
<script>
var a = document.getElementById("a");
var b = document.getElementById("b");
is(document.activeElement, document.body);
a.focus();
is(document.activeElement, a);
b.focus();
is(document.activeElement, b);
a.blur();
is(document.activeElement, b);
b.blur();
is(document.activeElement, document.body);
</script>
</body>
</html>

View file

@ -1,34 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<style>
div {
position: relative;
top: 100px;
left: 100px;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div>my div</div>
<script>
is_function(DOMRect, "DOMRect");
var elems = document.getElementsByTagName('div');
var rect = elems[0].getBoundingClientRect();
is_a(rect, DOMRect);
geq(rect.top, 100);
geq(rect.bottom, 200);
geq(rect.left, 100);
geq(rect.right, 200);
is(rect.width, 100);
is(rect.height, 100);
is(rect.width, rect.right - rect.left);
is(rect.height, rect.bottom - rect.top);
</script>
</body>
</html>

View file

@ -1,12 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<script>
is(window, window.window);
is(window, this);
for (var key in this) {
is(this[key], window[key]);
}
</script>
</head>
</html>

View file

@ -1,44 +0,0 @@
<html>
<script src="harness.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>
var fs = document.getElementById("fs");
is(fs.elements.length, 10);
is_a(fs.elements[0], HTMLInputElement);
is_a(fs.elements[1], HTMLFieldSetElement);
is_a(fs.elements[2], HTMLButtonElement);
is_a(fs.elements[3], HTMLUnknownElement);
is_a(fs.elements[4], HTMLTextAreaElement);
is_a(fs.elements[5], HTMLSelectElement);
is_a(fs.elements[6], HTMLInputElement);
is_a(fs.elements[7], HTMLInputElement);
is_a(fs.elements[8], HTMLOutputElement);
is_a(fs.elements[9], HTMLObjectElement);
</script>
</html>

View file

@ -1,27 +0,0 @@
<html>
<head>
<meta charset="utf8" />
<script src="harness.js"></script>
<title>Iframe contentDocument test.</title>
</head>
<body>
<iframe src="resources/iframe_contentDocument_inner.html" id="iframe"></iframe>
<script>
waitForExplicitFinish();
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(test_contentWindow, timeout);
return;
}
is(iframe.contentDocument.getElementById('test').textContent, 'value');
finish();
}
test_contentWindow();
</script>
</body>
</html>

View file

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

View file

@ -1,10 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
</head>
<body onload="is_a(event, Event); finish()">
<script>
waitForExplicitFinish();
</script>
</body>
</html>

View file

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

View file

@ -1,36 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
</head>
<body>
<script>
waitForExplicitFinish();
var onloads = 0;
function check(ev) {
is_a(ev, Event);
ev.preventDefault();
is(ev.defaultPrevented, false);
is(ev.target, document);
is(ev.currentTarget, window);
if (onloads == 2) {
finish();
}
}
window.onload = function(ev) {
_fail("this inline handler should be overwritten");
}
window.onload = function(ev) {
onloads++;
is(onloads, 1);
check(ev);
}
addEventListener("load", function(ev) {
onloads++;
is(onloads, 2);
check(ev);
});
</script>
</body>
</html>

View file

@ -1,20 +0,0 @@
<html>
<head>
<title></title>
<script src="harness.js"></script>
</head>
<body>
<script>
is(window.navigator, window.navigator);
is_a(window.navigator, Navigator);
var nav = window.navigator;
is(nav.product, "Gecko");
is(nav.taintEnabled(), false);
is(nav.appName, "Netscape");
is(nav.appCodeName, "Mozilla");
is(nav.platform, "");
is(nav.appVersion, "4.0");
</script>
</body>
</html>

View file

@ -1,35 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
<script>
{
var elem = document.createElement("div");
var other = document.createElement("div");
is(elem.compareDocumentPosition(elem),0);
var nonTree = elem.compareDocumentPosition(other);
var prefix = Node.DOCUMENT_POSITION_DISCONNECTED + Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
is(nonTree == prefix + Node.DOCUMENT_POSITION_FOLLOWING || nonTree == prefix + Node.DOCUMENT_POSITION_PRECEDING,
true);
elem.appendChild(other);
is(elem.compareDocumentPosition(other), Node.DOCUMENT_POSITION_CONTAINED_BY + Node.DOCUMENT_POSITION_FOLLOWING);
is(other.compareDocumentPosition(elem), Node.DOCUMENT_POSITION_CONTAINS + Node.DOCUMENT_POSITION_PRECEDING);
var another = document.createElement("div");
other.appendChild(another);
is(elem.compareDocumentPosition(another), Node.DOCUMENT_POSITION_CONTAINED_BY + Node.DOCUMENT_POSITION_FOLLOWING);
is(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);
is(another.compareDocumentPosition(follower), Node.DOCUMENT_POSITION_FOLLOWING);
is(follower.compareDocumentPosition(another), Node.DOCUMENT_POSITION_PRECEDING);
is(follower.compareDocumentPosition(preceder), Node.DOCUMENT_POSITION_PRECEDING);
}
</script>
</head>
</html>

View file

@ -1,23 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
<script>
// test1: Node.contains
{
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);
is(parent.contains(parent), true, "test1-0, Node.contains");
is(parent.contains(child), true, "test1-1, Node.contains");
is(parent.contains(child_of_child), true, "test1-2, Node.contains");
is(parent.contains(other), false, "test1-3, Node.contains");
}
</script>
</head>
</html>

View file

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

View file

@ -1,37 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
<script>
// test1: simple checks
{
var elem = document.createElement("div");
var other = document.createElement("div");
is(elem.isEqualNode(elem), true);
is(elem.isEqualNode(other), true);
is(other.isEqualNode(elem), true);
is(elem.isEqualNode(document), false);
}
// test2: non-element children
{
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);
is(parent_elem.isEqualNode(other_parent), true);
is(child_elem.isEqualNode(other_child), true);
var child_text = document.createTextNode("lorem ipsum");
child_elem.appendChild(child_text);
is(parent_elem.isEqualNode(other_parent), false);
is(child_elem.isEqualNode(other_child), false);
}
</script>
</head>
</html>

View file

@ -1,33 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
</head>
<body>
<script>
// test1: Node.normalize
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();
is(Array.prototype.map.call(parent1.childNodes, function(el) {return el.length}).indexOf(0), -1, "Node.normalize removes empty text nodes");
is(parent1.childNodes.length, 1, "Node.normalize merges text nodes in one");
is(parent1.childNodes[0].length, 5, "test 1-2, Node.normalize merges text nodes values");
is(parent2.childNodes.length, 0, "Node.normalize removes empty text nodes even if there is only one text node");
is(child2.textContent, "", "Node.normalize doesn't change removed children original content")
is(child3.textContent, "bb", "Node.normalize doesn't change removed children original content")
</script>
</body>
</html>

View file

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

View file

@ -1,69 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.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>
{ // document.querySelector
let div = document.getElementById("foo");
is(document.querySelector("#foo"), div);
div = document.getElementById("foo\\bar");
is(document.querySelector("#foo\\\\bar"), div);
div = document.getElementById("foo:bar");
is(document.querySelector("#foo\\:bar"), div);
div = document.getElementById("bar");
is(document.querySelector("div.myClass"), div);
is(document.querySelector("div:nth-of-type(4)"), div);
}
{ // element.querySelector
let body = document.body;
let div = document.getElementById("foo");
is(body.querySelector("#foo"), div);
div = document.getElementById("foo\\bar");
is(body.querySelector("#foo\\\\bar"), div);
div = document.getElementById("foo:bar");
is(body.querySelector("#foo\\:bar"), div);
div = document.getElementById("bar");
is(body.querySelector("div.myClass"), div);
is(body.querySelector("div:nth-of-type(4)"), div);
}
{ // docfrag.querySelector
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);
is(docfrag.querySelector("#foo"), div);
is(docfrag.querySelector("div.myClass"), div);
is(docfrag.querySelector("#bar"), p);
is(docfrag.querySelector("p.myClass"), p);
is(docfrag.querySelector(".myClass"), div);
is(docfrag.querySelector("div > div"), child);
}
</script>
</body>
</html>

View file

@ -1,23 +0,0 @@
<html>
<head>
<title></title>
<script src="harness.js"></script>
</head>
<body>
<div id="div1"></div>
<script>
is_a(document.documentElement.parentNode, Document);
is(document.documentElement.parentElement, null);
var elem = document.createElement("p");
is(elem.parentNode, null);
is(elem.parentElement, null);
var child = document.createElement("p");
elem.appendChild(child);
is(child.parentNode, elem);
is(child.parentElement, elem);
</script>
</body>
</html>

View file

@ -1,13 +0,0 @@
<html>
<head>
<title></title>
<script src="harness.js"></script>
</head>
<body>
<script>
is(window.document.title, '');
window.document.title = 'foo';
is(window.document.title, 'foo');
</script>
</body>
</html>

View file

@ -1,16 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
</head>
<body>
<div>this is
text content</div>
<script>
var div = document.getElementsByTagName('div')[0];
is(div.textContent, "this is\n text content");
var newContent = "new text con\ntent";
div.textContent = newContent;
is(div.textContent, newContent);
</script>
</body>
</html>

View file

@ -1,11 +0,0 @@
<html>
<head>
<title>starting title</title>
<script src="harness.js"></script>
<script>
is(document.title, "starting title");
document.title = "new title";
is(document.title, "new title");
</script>
</head>
</html>

View file

@ -1,6 +0,0 @@
<!-- crashtest -->
<script src=harness.js></script>
<script>
new CustomEvent("foo", { detail: null });
gc();
</script>

View file

@ -1,24 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
<select id="sel"></select>
<script>
var div = document.createElement('div');
var optgroup = document.createElement('optgroup');
var sel = document.getElementById('sel');
should_not_throw(function() {
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);
});
should_throw(function() { sel.add(div) });
should_not_throw(function() { sel.add(optgroup, function() {}) });
</script>
</head>
</html>

View file

@ -1,12 +0,0 @@
<html>
<head>
<title></title>
<script src="harness.js"></script>
</head>
<body>
<script>
is(window, window.self);
is_a(window.self, Window);
</script>
</body>
</html>

View file

@ -1,27 +0,0 @@
<html>
<head>
<title></title>
<script src="harness.js"></script>
</head>
<body>
<script>
is_not(window.performance, undefined);
is_a(window.performance, Performance);
is_not(window.performance.timing, undefined);
is_a(window.performance.timing, PerformanceTiming);
gt(window.performance.timing.navigationStart, 0);
var last = window.performance.now();
gt(last, 0);
// Check that window.performance.now() is monotonically increasing
for (var i = 0; i < 100; i++) {
var next = window.performance.now();
gt(next, last);
last = next;
}
</script>
</body>
</html>

View file

@ -1,20 +0,0 @@
<html>
<head>
<script src="harness.js"></script>
</head>
<body>
<script>
var x = 0;
var intervalID = setInterval(function() {
x += 1;
if (x == 2) {
clearInterval(intervalID);
setTimeout(function() {
is(x, 2);
finish();
}, 300);
}
}, 10);
</script>
</body>
</html>

View file

@ -1,23 +0,0 @@
<html>
<head id="foo">
<script src="harness.js"></script>
</head>
<body>
<div></div>
<script>
window.abcd = 15;
is(window.abcd, 15);
is(Object.getOwnPropertyDescriptor(window, 'abcd').value, 15);
is(window.hasOwnProperty('abcd'), true);
is('location' in window, true);
// FIXME: https://github.com/servo/servo/issues/4593
is(Object.hasOwnProperty('location'), false)
// Can't set indexed properties
window[100] = "abc";
is(window[100], undefined);
is(Object.getOwnPropertyDescriptor(window, 1000), undefined);
</script>
</body>
</html>

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

@ -1,24 +1,27 @@
<html>
<head>
<script src="harness.js"></script>
<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");
is(t.caption, tcaption);
is(t.caption.innerHTML, "old caption");
assert_equals(t.caption, tcaption);
assert_equals(t.caption.innerHTML, "old caption");
var newCaption = document.createElement("caption");
newCaption.innerHTML = "new caption";
t.caption = newCaption;
is(newCaption.parentNode, t);
is(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

@ -1,11 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
var output = "start";
var output;
test(function() {
output = "start";
var script = document.createElement("script");
script.setAttribute('type','text/javascript');
@ -13,7 +16,8 @@
document.body.appendChild(script);
output += "end";
is(output, "start middle 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

@ -1,11 +1,13 @@
<html>
<head id="foo">
<title></title>
<script src="harness.js"></script>
<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)
@ -17,8 +19,9 @@
a.appendChild(b).id = TEST_ID;
gBody.appendChild(a);
let result = document.getElementById(TEST_ID);
is(result, b, "test 9-0");
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

@ -1,7 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<script src="harness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
@ -12,17 +13,19 @@
</noscript>
<script>
test(function() {
var images = document.images;
is(images, document.images);
is(images.length, 1);
assert_equals(images, document.images);
assert_equals(images.length, 1);
var image = document.createElement("img");
image.setAttribute("src", "test.jpg");
document.body.appendChild(image);
is(images.length, 2);
assert_equals(images.length, 2);
document.body.removeChild(image);
is(images.length, 1);
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

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

Some files were not shown because too many files have changed in this diff Show more