Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255

This commit is contained in:
James Graham 2015-03-27 09:15:38 +00:00
parent b2a5225831
commit 1a81b18b9f
12321 changed files with 544385 additions and 6 deletions

View file

@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Document.currentScript</title>
<link rel=help href="https://html.spec.whatwg.org/multipage/#dom-document-currentscript">
<link rel=help href="https://html.spec.whatwg.org/multipage/#execute-the-script-block">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var expected = [
"parse-inline",
"parse-ext",
"dom-inline",
"dom-ext",
];
var tests = {};
expected.forEach(function(id) {
tests[id] = async_test("Script " + id);
});
function verifyScript(id) {
tests[id].step(function() {
assert_equals(document.currentScript, document.getElementById(id));
this.done();
});
}
</script>
<!-- Test parser inserted scripts -->
<script id="parse-inline">
verifyScript("parse-inline");
</script>
<script id="parse-ext" src="data:text/plain,verifyScript('parse-ext');"></script>
<!-- Test DOM inserted scripts -->
<script>
var s = document.createElement("script");
s.textContent = "verifyScript('dom-inline');";
s.id = "dom-inline";
document.body.appendChild(s);
s = document.createElement("script");
s.src = "data:text/plain,verifyScript('dom-ext');";
s.id = "dom-ext";
document.body.appendChild(s);
</script>

View file

@ -0,0 +1,31 @@
<!doctype html>
<title>getElementsByClassName and null/undefined</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-getelementsbyclassname">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<p id="p1"></p>
<p class="undefined" id="p2"></p>
<p class="null" id="p3"></p>
<p class="undefined null" id="p4"></p>
</div>
<script>
test(function() {
var wrapper = document.getElementById("test");
assert_equals(document.getElementsByClassName(undefined).length, 2);
assert_equals(document.getElementsByClassName(undefined)[0],
document.getElementById("p2"));
assert_equals(document.getElementsByClassName(undefined)[1],
document.getElementById("p4"));
/*
assert_equals(document.getElementsByClassName(null).length, 2);
assert_equals(document.getElementsByClassName(null)[0],
document.getElementById("p3"));
assert_equals(document.getElementsByClassName(null)[1],
document.getElementById("p4"));
*/
});
</script>

View file

@ -0,0 +1,31 @@
<!doctype html>
<title>getElementsByClassName and null/undefined</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-getelementsbyclassname">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<p id="p1"></p>
<p class="undefined" id="p2"></p>
<p class="null" id="p3"></p>
<p class="undefined null" id="p4"></p>
</div>
<script>
test(function() {
var wrapper = document.getElementById("test");
assert_equals(wrapper.getElementsByClassName(undefined).length, 2);
assert_equals(wrapper.getElementsByClassName(undefined)[0],
document.getElementById("p2"));
assert_equals(wrapper.getElementsByClassName(undefined)[1],
document.getElementById("p4"));
/*
assert_equals(wrapper.getElementsByClassName(null).length, 2);
assert_equals(wrapper.getElementsByClassName(null)[0],
document.getElementById("p3"));
assert_equals(wrapper.getElementsByClassName(null)[1],
document.getElementById("p4"));
*/
});
</script>

View file

@ -0,0 +1,121 @@
<!DOCTYPE html>
<title>Document.body</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-body">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function createDocument() {
var doc = document.implementation.createHTMLDocument("");
doc.removeChild(doc.documentElement);
return doc;
}
test(function() {
var doc = createDocument();
assert_equals(doc.body, null);
}, "Childless document");
test(function() {
var doc = createDocument();
doc.appendChild(doc.createElement("html"));
assert_equals(doc.body, null);
}, "Childless html element");
test(function() {
var doc = createDocument();
var html = doc.appendChild(doc.createElement("html"));
var b =
html.appendChild(doc.createElement("body"));
html.appendChild(doc.createElement("frameset"));
assert_equals(doc.body, b);
}, "Body followed by frameset inside the html element");
test(function() {
var doc = createDocument();
var html = doc.appendChild(doc.createElement("html"));
var f =
html.appendChild(doc.createElement("frameset"));
html.appendChild(doc.createElement("body"));
assert_equals(doc.body, f);
}, "Frameset followed by body inside the html element");
test(function() {
var doc = createDocument();
var html =
doc.appendChild(doc.createElementNS("http://example.org/test", "html"));
html.appendChild(doc.createElement("body"));
html.appendChild(doc.createElement("frameset"));
assert_equals(doc.body, null);
}, "Body followed by frameset inside a non-HTML html element");
test(function() {
var doc = createDocument();
var html =
doc.appendChild(doc.createElementNS("http://example.org/test", "html"));
html.appendChild(doc.createElement("frameset"));
html.appendChild(doc.createElement("body"));
assert_equals(doc.body, null);
}, "Frameset followed by body inside a non-HTML html element");
test(function() {
var doc = createDocument();
var html = doc.appendChild(doc.createElement("html"));
html.appendChild(
doc.createElementNS("http://example.org/test", "body"));
var b = html.appendChild(doc.createElement("body"));
assert_equals(doc.body, b);
}, "Non-HTML body followed by body inside the html element");
test(function() {
var doc = createDocument();
var html = doc.appendChild(doc.createElement("html"));
html.appendChild(
doc.createElementNS("http://example.org/test", "frameset"));
var b = html.appendChild(doc.createElement("body"));
assert_equals(doc.body, b);
}, "Non-HTML frameset followed by body inside the html element");
test(function() {
var doc = createDocument();
var html = doc.appendChild(doc.createElement("html"));
var x = html.appendChild(doc.createElement("x"));
x.appendChild(doc.createElement("body"));
var body = html.appendChild(doc.createElement("body"));
assert_equals(doc.body, body);
}, "Body inside an x element followed by a body");
test(function() {
var doc = createDocument();
var html = doc.appendChild(doc.createElement("html"));
var x = html.appendChild(doc.createElement("x"));
x.appendChild(doc.createElement("frameset"));
var frameset = html.appendChild(doc.createElement("frameset"));
assert_equals(doc.body, frameset);
}, "Frameset inside an x element followed by a frameset");
// Root node is not a html element.
test(function() {
var doc = createDocument();
doc.appendChild(doc.createElement("body"));
assert_equals(doc.body, null);
}, "Body as the root node");
test(function() {
var doc = createDocument();
doc.appendChild(doc.createElement("frameset"));
assert_equals(doc.body, null);
}, "Frameset as the root node");
test(function() {
var doc = createDocument();
var body = doc.appendChild(doc.createElement("body"));
body.appendChild(doc.createElement("frameset"));
assert_equals(doc.body, null);
}, "Body as the root node with a frameset child");
test(function() {
var doc = createDocument();
var frameset = doc.appendChild(doc.createElement("frameset"));
frameset.appendChild(doc.createElement("body"));
assert_equals(doc.body, null);
}, "Frameset as the root node with a body child");
test(function() {
var doc = createDocument();
doc.appendChild(doc.createElementNS("http://example.org/test", "body"));
assert_equals(doc.body, null);
}, "Non-HTML body as the root node");
test(function() {
var doc = createDocument();
doc.appendChild(doc.createElementNS("http://example.org/test", "frameset"));
assert_equals(doc.body, null);
}, "Non-HTML frameset as the root node");
</script>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<title>Setting document.body to incorrect values</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-body">
<link rel="help" href="https://heycam.github.io/webidl/#es-interface">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var originalBody = document.body;
test(function() {
assert_throws(new TypeError(), function() {
document.body = "text"
})
}, "Should throw a TypeError when trying to set document.body to a string.")
test(function() {
assert_throws("HierarchyRequestError", function() {
document.body = document.createElement("div")
})
}, "Should throw a HierarchyRequestError when trying to set document.body to a div element.")
test(function() {
var doc = document.implementation.createHTMLDocument("")
doc.removeChild(doc.documentElement)
assert_throws("HierarchyRequestError", function() {
doc.body = document.createElement("body")
})
}, "Should throw a HierarchyRequestError when trying to set document.body when there's no root element.")
test(function() {
assert_equals(document.body, originalBody);
}, "document.body has not changed")
</script>

View file

@ -0,0 +1,55 @@
<!DOCTYPE html>
<title>document.embeds and document.plugins</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-embeds">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-plugins">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
assert_equals(document.embeds, document.embeds,
"embeds should be constant");
assert_equals(document.plugins, document.plugins,
"plugins should be constant");
assert_equals(document.embeds, document.plugins,
"embeds should be the same as plugins");
assert_equals(document.embeds.length, 0);
assert_equals(document.plugins.length, 0);
}, "No plugins");
test(function() {
var embed = document.body.appendChild(document.createElement("embed"));
this.add_cleanup(function() { document.body.removeChild(embed) });
assert_array_equals(document.embeds, [embed]);
assert_array_equals(document.plugins, [embed]);
assert_equals(document.embeds, document.embeds,
"embeds should be constant");
assert_equals(document.plugins, document.plugins,
"plugins should be constant");
assert_equals(document.embeds, document.plugins,
"embeds should be the same as plugins");
}, "One plugin");
test(function() {
var embed1 = document.createElement("embed"),
embed2 = document.createElement("embed");
document.body.appendChild(embed2);
this.add_cleanup(function() { document.body.removeChild(embed2) });
document.body.insertBefore(embed1, embed2);
this.add_cleanup(function() { document.body.removeChild(embed1) });
assert_array_equals(document.embeds, [embed1, embed2]);
assert_array_equals(document.plugins, [embed1, embed2]);
assert_equals(document.embeds, document.embeds,
"embeds should be constant");
assert_equals(document.plugins, document.plugins,
"plugins should be constant");
assert_equals(document.embeds, document.plugins,
"embeds should be the same as plugins");
}, "Two plugins");
</script>

View file

@ -0,0 +1,58 @@
<!doctype html>
<meta charset=utf-8>
<title>Document.forms</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<form id="form1">
<input type="button" name="thebutton" value="alpha">
<input type=radio name=r1 value=a>
<input type=radio name=r1 value=b>
<input type=radio name=r1 value=c>
<input type=radio name=r1 value=d>
<input type=radio name=r1 value=e>
</form>
<form id="form2">
<input type="button" name="thebutton" value="alpha">
<input type=radio name=r1 value="a">
<input type=radio name=r1 value="b">
<input type=radio name=r1 value="c">
<input type=radio name=r1 value="d">
<input type=radio name=r1 value="e">
</form>
<form id=""></form>
<script>
test(function() {
assert_equals(document.forms.length, 3);
assert_equals(document.forms[0].id, "form1");
assert_equals(document.forms[1].id, "form2");
assert_equals(document.forms.form1.id, "form1");
assert_equals(document.forms.form2.id, "form2");
assert_equals(document.forms.item(0).id, "form1");
assert_equals(document.forms.item(1).id, "form2");
assert_equals(document.forms.namedItem("form1").id, "form1");
assert_equals(document.forms.namedItem("form2").id, "form2");
assert_equals(document.forms.item("form1").id, "form1");
assert_equals(document.forms.item("form2").id, "form2");
}, "document.forms")
test(function() {
assert_equals(document.forms[""], undefined);
assert_equals(document.forms.namedItem(""), null);
}, "document.forms with empty string")
test(function() {
var result = [];
for (var p in document.forms) {
result.push(p);
}
assert_array_equals(result, ["0", "1", "2", "item", "namedItem", "length"])
}, "document.forms iteration")
test(function() {
var result = Object.getOwnPropertyNames(document.forms);
assert_array_equals(result, ["0", "1", "2", "form1", "form2"])
}, "document.forms getOwnPropertyNames")
</script>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<title>Calling getElementsByClassName with the same argument</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-getelementsbyclassname">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<div class="abcd"></div>
</div>
<script>
test(function() {
var list1 = document.getElementsByClassName("abcd");
var list2 = document.getElementsByClassName("abcd");
assert_true(list1 === list2 || list1 !== list2);
}, "The user agent may return the same object as the object returned by the earlier call.");
</script>

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<title>getElementsByName and case</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<div name="abcd"></div>
</div>
<script>
test(function() {
assert_equals(document.getElementsByName("ABCD").length, 0);
assert_equals(document.getElementsByName("abcd").length, 1);
});
</script>

View file

@ -0,0 +1,22 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>getElementsByName and case</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname"/>
<link rel="stylesheet" href="/resources/testharness.css"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<div id="test">
<div name="abcd"></div>
</div>
<script>
test(function() {
assert_equals(document.getElementsByName("ABCD").length, 0);
assert_equals(document.getElementsByName("abcd").length, 1);
});
</script>
</body>
</html>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<title>getElementsByName and ids</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<div id="abcd"></div>
</div>
<script>
test(function() {
assert_equals(document.getElementsByName("abcd").length, 0);
});
</script>

View file

@ -0,0 +1,21 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>getElementsByName and ids</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname"/>
<link rel="stylesheet" href="/resources/testharness.css"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<div id="test">
<div id="abcd"></div>
</div>
<script>
test(function() {
assert_equals(document.getElementsByName("abcd").length, 0);
});
</script>
</body>
</html>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<title>Document.getElementsByName: interfaces</title>
<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var collection = document.getElementsByName("name");
assert_class_string(collection, "NodeList");
assert_true(collection instanceof NodeList, "Should be a NodeList");
assert_false(collection instanceof HTMLCollection,
"Should not be a HTMLCollection");
});
</script>

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<title>getElementsByName and foreign namespaces</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<p name="math"><math name="math">
<mi>a</mi>
<mo>+</mo>
<mi>b</mi>
</math>
<p name="svg"><svg width="300" height="100" name="svg">
<rect width="300" height="100" fill="rgb(0,0,255)"/>
</svg>
</div>
<script>
test(function() {
var ps = document.getElementById("test")
.getElementsByTagName("p");
assert_equals(document.getElementsByName("math").length, 1);
assert_equals(document.getElementsByName("math")[0], ps[0]);
assert_equals(document.getElementsByName("svg").length, 1);
assert_equals(document.getElementsByName("svg")[0], ps[1]);
});
</script>

View file

@ -0,0 +1,33 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>getElementsByName and foreign namespaces</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname"/>
<link rel="stylesheet" href="/resources/testharness.css"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<div id="test">
<p name="math"><math name="math" xmlns="http://www.w3.org/1998/Math/MathML">
<mi>a</mi>
<mo>+</mo>
<mi>b</mi>
</math></p>
<p name="svg"><svg width="300" height="100" name="svg" xmlns="http://www.w3.org/2000/svg">
<rect width="300" height="100" fill="rgb(0,0,255)"/>
</svg></p>
</div>
<script>
test(function() {
var ps = document.getElementById("test")
.getElementsByTagName("p");
assert_equals(document.getElementsByName("math").length, 1);
assert_equals(document.getElementsByName("math")[0], ps[0]);
assert_equals(document.getElementsByName("svg").length, 1);
assert_equals(document.getElementsByName("svg")[0], ps[1]);
});
</script>
</body>
</html>

View file

@ -0,0 +1,122 @@
<!DOCTYPE html>
<title>getElementsByName and newly introduced HTML elements</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<section name="section"></section>
<article name="article"></article>
<aside name="aside"></aside>
<hgroup name="hgroup"></hgroup>
<header name="header"></header>
<footer name="footer"></footer>
<nav name="nav"></nav>
<dialog name="dialog"></dialog>
<figure name="figure"></figure>
<audio name="audio"></audio>
<video name="video"></video>
<embed name="embed"></embed>
<mark name="mark"></mark>
<meter name="meter"></meter>
<progress name="progress"></progress>
<time name="time"></time>
<canvas name="canvas"></canvas>
<command name="command"></command>
<menu name="menu"></menu>
<details name="details"></details>
<datalist name="datalist"></datalist>
<keygen name="keygen"></keygen>
<output name="output"></output>
<ruby name="ruby"></ruby>
<rt name="rt"></rt>
<rp name="rp"></rp>
<source name="source">
</div>
<script>
test(function() {
assert_equals(document.getElementsByName("section").length, 1);
assert_equals(document.getElementsByName("section")[0],
document.getElementsByTagName("section")[0]);
assert_equals(document.getElementsByName("article").length, 1);
assert_equals(document.getElementsByName("article")[0],
document.getElementsByTagName("article")[0]);
assert_equals(document.getElementsByName("aside").length, 1);
assert_equals(document.getElementsByName("aside")[0],
document.getElementsByTagName("aside")[0]);
assert_equals(document.getElementsByName("hgroup").length, 1);
assert_equals(document.getElementsByName("hgroup")[0],
document.getElementsByTagName("hgroup")[0]);
assert_equals(document.getElementsByName("header").length, 1);
assert_equals(document.getElementsByName("header")[0],
document.getElementsByTagName("header")[0]);
assert_equals(document.getElementsByName("footer").length, 1);
assert_equals(document.getElementsByName("footer")[0],
document.getElementsByTagName("footer")[0]);
assert_equals(document.getElementsByName("nav").length, 1);
assert_equals(document.getElementsByName("nav")[0],
document.getElementsByTagName("nav")[0]);
assert_equals(document.getElementsByName("dialog").length, 1);
assert_equals(document.getElementsByName("dialog")[0],
document.getElementsByTagName("dialog")[0]);
assert_equals(document.getElementsByName("figure").length, 1);
assert_equals(document.getElementsByName("figure")[0],
document.getElementsByTagName("figure")[0]);
assert_equals(document.getElementsByName("audio").length, 1);
assert_equals(document.getElementsByName("audio")[0],
document.getElementsByTagName("audio")[0]);
assert_equals(document.getElementsByName("video").length, 1);
assert_equals(document.getElementsByName("video")[0],
document.getElementsByTagName("video")[0]);
assert_equals(document.getElementsByName("embed").length, 1);
assert_equals(document.getElementsByName("embed")[0],
document.getElementsByTagName("embed")[0]);
assert_equals(document.getElementsByName("mark").length, 1);
assert_equals(document.getElementsByName("mark")[0],
document.getElementsByTagName("mark")[0]);
assert_equals(document.getElementsByName("meter").length, 1);
assert_equals(document.getElementsByName("meter")[0],
document.getElementsByTagName("meter")[0]);
assert_equals(document.getElementsByName("progress").length, 1);
assert_equals(document.getElementsByName("progress")[0],
document.getElementsByTagName("progress")[0]);
assert_equals(document.getElementsByName("time").length, 1);
assert_equals(document.getElementsByName("time")[0],
document.getElementsByTagName("time")[0]);
assert_equals(document.getElementsByName("canvas").length, 1);
assert_equals(document.getElementsByName("canvas")[0],
document.getElementsByTagName("canvas")[0]);
assert_equals(document.getElementsByName("command").length, 1);
assert_equals(document.getElementsByName("command")[0],
document.getElementsByTagName("command")[0]);
assert_equals(document.getElementsByName("menu").length, 1);
assert_equals(document.getElementsByName("menu")[0],
document.getElementsByTagName("menu")[0]);
assert_equals(document.getElementsByName("details").length, 1);
assert_equals(document.getElementsByName("details")[0],
document.getElementsByTagName("details")[0]);
assert_equals(document.getElementsByName("datalist").length, 1);
assert_equals(document.getElementsByName("datalist")[0],
document.getElementsByTagName("datalist")[0]);
assert_equals(document.getElementsByName("keygen").length, 1);
assert_equals(document.getElementsByName("keygen")[0],
document.getElementsByTagName("keygen")[0]);
assert_equals(document.getElementsByName("output").length, 1);
assert_equals(document.getElementsByName("output")[0],
document.getElementsByTagName("output")[0]);
assert_equals(document.getElementsByName("ruby").length, 1);
assert_equals(document.getElementsByName("ruby")[0],
document.getElementsByTagName("ruby")[0]);
assert_equals(document.getElementsByName("rt").length, 1);
assert_equals(document.getElementsByName("rt")[0],
document.getElementsByTagName("rt")[0]);
assert_equals(document.getElementsByName("rp").length, 1);
assert_equals(document.getElementsByName("rp")[0],
document.getElementsByTagName("rp")[0]);
assert_equals(document.getElementsByName("source").length, 1);
assert_equals(document.getElementsByName("source")[0],
document.getElementsByTagName("source")[0]);
});
</script>

View file

@ -0,0 +1,127 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>getElementsByName and newly introduced HTML elements</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname"/>
<link rel="stylesheet" href="/resources/testharness.css"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<div id="test">
<section name="section"></section>
<article name="article"></article>
<aside name="aside"></aside>
<hgroup name="hgroup"></hgroup>
<header name="header"></header>
<footer name="footer"></footer>
<nav name="nav"></nav>
<dialog name="dialog"></dialog>
<figure name="figure"></figure>
<audio name="audio"></audio>
<video name="video"></video>
<embed name="embed"></embed>
<mark name="mark"></mark>
<meter name="meter"></meter>
<progress name="progress"></progress>
<time name="time"></time>
<canvas name="canvas"></canvas>
<command name="command"></command>
<menu name="menu"></menu>
<details name="details"></details>
<datalist name="datalist"></datalist>
<keygen name="keygen"></keygen>
<output name="output"></output>
<ruby name="ruby"></ruby>
<rt name="rt"></rt>
<rp name="rp"></rp>
<source name="source"/>
</div>
<script>
test(function() {
assert_equals(document.getElementsByName("section").length, 1);
assert_equals(document.getElementsByName("section")[0],
document.getElementsByTagName("section")[0]);
assert_equals(document.getElementsByName("article").length, 1);
assert_equals(document.getElementsByName("article")[0],
document.getElementsByTagName("article")[0]);
assert_equals(document.getElementsByName("aside").length, 1);
assert_equals(document.getElementsByName("aside")[0],
document.getElementsByTagName("aside")[0]);
assert_equals(document.getElementsByName("hgroup").length, 1);
assert_equals(document.getElementsByName("hgroup")[0],
document.getElementsByTagName("hgroup")[0]);
assert_equals(document.getElementsByName("header").length, 1);
assert_equals(document.getElementsByName("header")[0],
document.getElementsByTagName("header")[0]);
assert_equals(document.getElementsByName("footer").length, 1);
assert_equals(document.getElementsByName("footer")[0],
document.getElementsByTagName("footer")[0]);
assert_equals(document.getElementsByName("nav").length, 1);
assert_equals(document.getElementsByName("nav")[0],
document.getElementsByTagName("nav")[0]);
assert_equals(document.getElementsByName("dialog").length, 1);
assert_equals(document.getElementsByName("dialog")[0],
document.getElementsByTagName("dialog")[0]);
assert_equals(document.getElementsByName("figure").length, 1);
assert_equals(document.getElementsByName("figure")[0],
document.getElementsByTagName("figure")[0]);
assert_equals(document.getElementsByName("audio").length, 1);
assert_equals(document.getElementsByName("audio")[0],
document.getElementsByTagName("audio")[0]);
assert_equals(document.getElementsByName("video").length, 1);
assert_equals(document.getElementsByName("video")[0],
document.getElementsByTagName("video")[0]);
assert_equals(document.getElementsByName("embed").length, 1);
assert_equals(document.getElementsByName("embed")[0],
document.getElementsByTagName("embed")[0]);
assert_equals(document.getElementsByName("mark").length, 1);
assert_equals(document.getElementsByName("mark")[0],
document.getElementsByTagName("mark")[0]);
assert_equals(document.getElementsByName("meter").length, 1);
assert_equals(document.getElementsByName("meter")[0],
document.getElementsByTagName("meter")[0]);
assert_equals(document.getElementsByName("progress").length, 1);
assert_equals(document.getElementsByName("progress")[0],
document.getElementsByTagName("progress")[0]);
assert_equals(document.getElementsByName("time").length, 1);
assert_equals(document.getElementsByName("time")[0],
document.getElementsByTagName("time")[0]);
assert_equals(document.getElementsByName("canvas").length, 1);
assert_equals(document.getElementsByName("canvas")[0],
document.getElementsByTagName("canvas")[0]);
assert_equals(document.getElementsByName("command").length, 1);
assert_equals(document.getElementsByName("command")[0],
document.getElementsByTagName("command")[0]);
assert_equals(document.getElementsByName("menu").length, 1);
assert_equals(document.getElementsByName("menu")[0],
document.getElementsByTagName("menu")[0]);
assert_equals(document.getElementsByName("details").length, 1);
assert_equals(document.getElementsByName("details")[0],
document.getElementsByTagName("details")[0]);
assert_equals(document.getElementsByName("datalist").length, 1);
assert_equals(document.getElementsByName("datalist")[0],
document.getElementsByTagName("datalist")[0]);
assert_equals(document.getElementsByName("keygen").length, 1);
assert_equals(document.getElementsByName("keygen")[0],
document.getElementsByTagName("keygen")[0]);
assert_equals(document.getElementsByName("output").length, 1);
assert_equals(document.getElementsByName("output")[0],
document.getElementsByTagName("output")[0]);
assert_equals(document.getElementsByName("ruby").length, 1);
assert_equals(document.getElementsByName("ruby")[0],
document.getElementsByTagName("ruby")[0]);
assert_equals(document.getElementsByName("rt").length, 1);
assert_equals(document.getElementsByName("rt")[0],
document.getElementsByTagName("rt")[0]);
assert_equals(document.getElementsByName("rp").length, 1);
assert_equals(document.getElementsByName("rp")[0],
document.getElementsByTagName("rp")[0]);
assert_equals(document.getElementsByName("source").length, 1);
assert_equals(document.getElementsByName("source")[0],
document.getElementsByTagName("source")[0]);
});
</script>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<title>Calling getElementsByName with null and undefined</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname">
<link rel="help" href="https://heycam.github.io/webidl/#es-DOMString">
<link rel="help" href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf#page=57">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var n = document.createElement("div");
n.setAttribute("name", "null");
document.body.appendChild(n);
this.add_cleanup(function() { document.body.removeChild(n) });
assert_equals(document.getElementsByName(null)[0], n);
}, "getElementsByName(null)");
test(function() {
var u = document.createElement("div");
u.setAttribute("name", "undefined");
document.body.appendChild(u);
this.add_cleanup(function() { document.body.removeChild(u) });
assert_equals(document.getElementsByName(undefined)[0], u);
}, "getElementsByName(undefined)");
</script>

View file

@ -0,0 +1,35 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Calling getElementsByName with null and undefined</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname"/>
<link rel="help" href="https://heycam.github.io/webidl/#es-DOMString"/>
<link rel="help" href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf#page=57"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
test(function() {
var n = document.createElement("div");
n.setAttribute("name", "null");
document.body.appendChild(n);
this.add_cleanup(function() { document.body.removeChild(n) });
assert_equals(document.getElementsByName(null)[0], n);
}, "getElementsByName(null)");
test(function() {
var u = document.createElement("div");
u.setAttribute("name", "undefined");
document.body.appendChild(u);
this.add_cleanup(function() { document.body.removeChild(u) });
assert_equals(document.getElementsByName(undefined)[0], u);
}, "getElementsByName(undefined)");
</script>
</body>
</html>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<title>getElementsByName and the param element</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<param name="test1">
<object>
<param name="test2">
</object>
</div>
<script>
test(function() {
assert_equals(document.getElementsByName("test1").length, 1);
assert_equals(document.getElementsByName("test1")[0],
document.getElementsByTagName("param")[0]);
assert_equals(document.getElementsByName("test2").length, 1);
assert_equals(document.getElementsByName("test2")[0],
document.getElementsByTagName("param")[1]);
});
</script>

View file

@ -0,0 +1,29 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>getElementsByName and the param element</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname"/>
<link rel="stylesheet" href="/resources/testharness.css"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<div id="test">
<param name="test1"/>
<object>
<param name="test2"/>
</object>
</div>
<script>
test(function() {
assert_equals(document.getElementsByName("test1").length, 1);
assert_equals(document.getElementsByName("test1")[0],
document.getElementsByTagName("param")[0]);
assert_equals(document.getElementsByName("test2").length, 1);
assert_equals(document.getElementsByName("test2")[0],
document.getElementsByTagName("param")[1]);
});
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<title>Calling getElementsByName with the same argument</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-getelementsbyname">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<div name="abcd"></div>
</div>
<script>
test(function() {
var list1 = document.getElementsByName("abcd");
var list2 = document.getElementsByName("abcd");
assert_true(list1 === list2 || list1 !== list2);
}, "The user agent may return the same object as the object returned by the earlier call.");
</script>

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<title>document.head</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-head">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var head = document.getElementsByTagName("head")[0];
assert_equals(document.head, head);
document.head = "";
assert_equals(document.head, head);
document.head = document.createElement("head");
assert_equals(document.head, head);
document.documentElement.appendChild(document.createElement("head"));
assert_equals(document.head, head);
var head2 = document.createElement("head");
document.documentElement.insertBefore(head2, head);
assert_equals(document.head, head2);
});
</script>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<title>document.head</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-head">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var HTML = "http://www.w3.org/1999/xhtml";
test(function() {
var head = document.getElementsByTagName("head")[0];
assert_equals(document.head, head);
var head2 = document.createElementNS(HTML, "blah:head");
document.documentElement.insertBefore(head2, head);
assert_equals(document.head, head2);
var head3 = document.createElementNS("http://www.example.org/", "blah:head");
document.documentElement.insertBefore(head3, head2);
assert_equals(document.head, head2);
});
</script>

View file

@ -0,0 +1,105 @@
<!doctype html>
<meta charset=utf-8>
<title>Document.images</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<div id=test>
<img>
<img id=x><img name=y><img id=z1 name=z2>
<img id=a><img id=a>
<img name=b><img name=b>
<img id=><img name=>
<input type=image name=input>
</div>
<script>
function assert_all(aAssertFunc, aCollection) {
for (var i = 0; i < aCollection.length; ++i) {
aAssertFunc(aCollection[i]);
}
}
var XHTML = "http://www.w3.org/1999/xhtml";
var div, images, c;
setup(function() {
div = document.getElementById("test");
var foreign =
div.appendChild(document.createElementNS("http://example.org", "img"));
foreign.setAttribute("id", "f");
images = [].slice.call(div.getElementsByTagNameNS(XHTML, "img"));
c = document.images;
});
test(function() {
assert_equals(c.length, 10);
assert_array_equals(c, images);
assert_all(function (aElement) {
assert_equals(aElement.namespaceURI, XHTML);
}, c);
}, "document.images should contain all HTML img elements");
test(function() {
assert_equals(c.x, images[1]);
assert_equals(c.namedItem("x"), images[1]);
assert_true("x" in c, '"x" in c');
}, "img with id");
test(function() {
assert_equals(c.y, images[2]);
assert_equals(c.namedItem("y"), images[2]);
assert_true("y" in c, '"y" in c');
}, "img with name");
test(function() {
assert_equals(c.z1, images[3]);
assert_equals(c.namedItem("z1"), images[3]);
assert_true("z1" in c, '"z1" in c');
assert_equals(c.z2, images[3]);
assert_equals(c.namedItem("z2"), images[3]);
assert_true("z2" in c, '"z2" in c');
}, "img with id and name");
test(function() {
assert_equals(c.a, images[4]);
assert_equals(c.namedItem("a"), images[4]);
assert_true("a" in c, '"a" in c');
}, "Two img elements with the same id");
test(function() {
assert_equals(c.b, images[6]);
assert_equals(c.namedItem("b"), images[6]);
assert_true("b" in c, '"b" in c');
}, "Two img elements with the same name");
test(function() {
assert_equals(c.c, undefined);
assert_equals(c.namedItem("c"), null);
assert_false("c" in c, '"c" in c');
}, "Unknown name should not be in the collection");
test(function() {
assert_equals(c.f, undefined);
assert_equals(c.namedItem("f"), null);
assert_false("f" in c, '"f" in c');
}, "Foreign element should not be in the collection");
test(function() {
assert_equals(c.input, undefined);
assert_equals(c.namedItem("input"), null);
assert_false("input" in c, '"input" in c');
var input = div.getElementsByTagName("input")[0];
assert_all(function (aElement) {
assert_not_equals(aElement.namespaceURI, input);
}, c);
}, "Input elements should not be in the collection");
test(function() {
assert_equals(c[""], undefined);
assert_equals(c.namedItem(""), null);
assert_false("" in c, '"" in c');
}, "The empty string should not be in the collections");
</script>

View file

@ -0,0 +1,33 @@
<!DOCTYPE html>
<title>document.title with head blown away</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#document.title">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
assert_equals(document.title, "document.title with head blown away");
})
test(function() {
var head = document.getElementsByTagName("head")[0];
assert_true(!!head, "Head gone?!")
head.parentNode.removeChild(head);
assert_false(!!document.getElementsByTagName("head")[0], "Head still there?!")
document.title = "FAIL";
assert_equals(document.title, "");
})
test(function() {
var title2 = document.createElement("title");
title2.appendChild(document.createTextNode("PASS"));
document.body.appendChild(title2);
assert_equals(document.title, "PASS");
})
test(function() {
var title3 = document.createElement("title");
title3.appendChild(document.createTextNode("PASS2"));
document.documentElement.insertBefore(title3, document.body);
assert_equals(document.title, "PASS2");
})
</script>

View file

@ -0,0 +1,38 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>document.title with head blown away</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#document.title"/>
<link rel="stylesheet" href="/resources/testharness.css"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
test(function() {
assert_equals(document.title, "document.title with head blown away");
})
test(function() {
var head = document.getElementsByTagName("head")[0];
assert_true(!!head, "Head gone?!")
head.parentNode.removeChild(head);
assert_false(!!document.getElementsByTagName("head")[0], "Head still there?!")
document.title = "FAIL";
assert_equals(document.title, "");
})
test(function() {
var title2 = document.createElement("title");
title2.appendChild(document.createTextNode("PASS"));
document.body.appendChild(title2);
assert_equals(document.title, "PASS");
})
test(function() {
var title3 = document.createElement("title");
title3.appendChild(document.createTextNode("PASS2"));
document.documentElement.insertBefore(title3, document.body);
assert_equals(document.title, "PASS2");
})
</script>
</body>
</html>

View file

@ -0,0 +1,44 @@
<!DOCTYPE html>
<title> document.title and space normalization </title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#document.title">
<link rel="stylesheet" href="/resources/testharness.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
// Single space characters must be normalized. (WHATWG r4353)
assert_equals(document.title, "document.title and space normalization");
document.title = "one space";
assert_equals(document.title, "one space");
document.title = "two spaces";
assert_equals(document.title, "two spaces");
document.title = "one\ttab";
assert_equals(document.title, "one tab");
document.title = "two\t\ttabs";
assert_equals(document.title, "two tabs");
document.title = "one\nnewline";
assert_equals(document.title, "one newline");
document.title = "two\n\nnewlines";
assert_equals(document.title, "two newlines");
document.title = "one\fform feed";
assert_equals(document.title, "one form feed");
document.title = "two\f\fform feeds";
assert_equals(document.title, "two form feeds");
document.title = "one\rcarriage return";
assert_equals(document.title, "one carriage return");
document.title = "two\r\rcarriage returns";
assert_equals(document.title, "two carriage returns");
});
</script>

View file

@ -0,0 +1,49 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> document.title and space normalization </title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#document.title"/>
<link rel="stylesheet" href="/resources/testharness.css"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>
test(function() {
// Single space characters must be normalized. (WHATWG r4353)
assert_equals(document.title, "document.title and space normalization");
document.title = "one space";
assert_equals(document.title, "one space");
document.title = "two spaces";
assert_equals(document.title, "two spaces");
document.title = "one\ttab";
assert_equals(document.title, "one tab");
document.title = "two\t\ttabs";
assert_equals(document.title, "two tabs");
document.title = "one\nnewline";
assert_equals(document.title, "one newline");
document.title = "two\n\nnewlines";
assert_equals(document.title, "two newlines");
document.title = "one\fform feed";
assert_equals(document.title, "one form feed");
document.title = "two\f\fform feeds";
assert_equals(document.title, "two form feeds");
document.title = "one\rcarriage return";
assert_equals(document.title, "one carriage return");
document.title = "two\r\rcarriage returns";
assert_equals(document.title, "two carriage returns");
});
</script>
</body>
</html>

View file

@ -0,0 +1,42 @@
<!doctype html>
<title>document.title and White_Space characters</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#document.title">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var White_Space = [
"\u000B",
"\u0085",
"\u00A0",
"\u1680",
"\u180E",
"\u2000",
"\u2001",
"\u2002",
"\u2003",
"\u2004",
"\u2005",
"\u2006",
"\u2007",
"\u2008",
"\u2009",
"\u200A",
"\u2028",
"\u2029",
"\u202F",
"\u205F",
"\u3000"
];
White_Space.forEach(function(character, i) {
test(function() {
var s = character + "a" + character + character + "b" + character + "c" +
String(i) + character;
document.title = s;
assert_equals(document.title, s);
}, "Removing whitespace in document.title: U+" +
character.charCodeAt(0).toString(16));
});
</script>

View file

@ -0,0 +1,19 @@
<!doctype html>
<title>document.title and the empty string</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#document.title">
<meta name="assert" content="On setting document.title to the empty string, no text node must be created.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var head = document.documentElement.firstChild;
head.removeChild(head.firstChild);
assert_equals(document.title, "");
document.title = "";
assert_equals(document.title, "");
assert_true(head.lastChild instanceof HTMLTitleElement, "Need a title element.");
assert_equals(head.lastChild.firstChild, null);
});
</script>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Document.title and DOMImplementation.createHTMLDocument</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/dom/nodes/DOMImplementation-createHTMLDocument.js"></script>
<div id="log"></div>
<script>
createHTMLDocuments(function(doc, expectedtitle, normalizedtitle) {
assert_equals(doc.title, normalizedtitle)
})
</script>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#document.title">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
assert_equals(document.title, "");
}, "No title element");
test(function() {
var title = document.createElement("title");
title.appendChild(document.createTextNode("PASS"));
document.head.appendChild(title);
assert_equals(document.title, "PASS");
title.appendChild(document.createTextNode("PASS2"));
title.appendChild(document.createTextNode("PASS3"));
assert_equals(document.title, "PASSPASS2PASS3");
}, "title element contains multiple child text nodes");
</script>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Named items: img id &amp; name</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-nameditem">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<img id="a" name="b">
</div>
<script>
test(function() {
assert_equals(document.a, document.getElementsByTagName("img")[0]);
assert_equals(document['a'], document.getElementsByTagName("img")[0]);
assert_equals(document.b, document.getElementsByTagName("img")[0]);
assert_equals(document['b'], document.getElementsByTagName("img")[0]);
}, "img elements that have a name and id attribute, should be accessible by both values.");
</script>

View file

@ -0,0 +1,99 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Named items: iframes</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-nameditem">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<iframe name="test1"></iframe>
<iframe name="test2"></iframe>
<iframe name="test2"></iframe>
<iframe name="test3"></iframe>
<img name="test3">
<img name="test4">
<iframe name="test4"></iframe>
<iframe id="test5"></iframe>
<iframe name="test6" id="fail"></iframe>
<iframe name="fail" id="test7"></iframe>
<iframe name="42"></iframe>
</div>
<script>
test(function() {
var iframe = document.getElementsByTagName("iframe")[0];
assert_equals(iframe.name, "test1");
assert_true("test1" in document, '"test1" in document should be true');
assert_equals(document.test1, iframe.contentWindow);
}, "If the only named item is an iframe, the contentWindow should be returned.");
test(function() {
var iframe1 = document.getElementsByTagName("iframe")[1];
assert_equals(iframe1.name, "test2");
var iframe2 = document.getElementsByTagName("iframe")[2];
assert_equals(iframe2.name, "test2");
assert_true("test2" in document, '"test2" in document should be true');
var collection = document.test2;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [iframe1, iframe2]);
}, "If there are two iframes, a collection should be returned.");
test(function() {
var iframe = document.getElementsByTagName("iframe")[3];
assert_equals(iframe.name, "test3");
var img = document.getElementsByTagName("img")[0];
assert_equals(img.name, "test3");
assert_true("test3" in document, '"test3" in document should be true');
var collection = document.test3;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [iframe, img]);
}, "If there are an iframe and another element (iframe first), a collection should be returned.");
test(function() {
var iframe = document.getElementsByTagName("iframe")[4];
assert_equals(iframe.name, "test4");
var img = document.getElementsByTagName("img")[1];
assert_equals(img.name, "test4");
assert_true("test4" in document, '"test4" in document should be true');
var collection = document.test4;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [img, iframe]);
}, "If there are an iframe and another element (iframe last), a collection should be returned.");
test(function() {
assert_false("test5" in document, '"test5" in document should be false');
assert_equals(document.test5, undefined);
}, "If an iframe has an id and no name, it should not be returned.");
test(function() {
var iframe = document.getElementsByTagName("iframe")[6];
assert_equals(iframe.name, "test6");
assert_true("test6" in document, '"test6" in document should be true');
assert_equals(document.test6, iframe.contentWindow);
}, "If an iframe has a name and a different id, it should be returned by its name.");
test(function() {
assert_false("test7" in document, '"test7" in document should be false');
assert_equals(document.test7, undefined);
}, "If an iframe has an id and a different name, it should not be returned by its id.");
test(function() {
var iframe = document.getElementsByTagName("iframe")[8];
assert_equals(iframe.name, "42");
assert_true(42 in document, '42 in document should be true');
assert_equals(document[42], iframe.contentWindow);
}, "An iframe whose name looks like an array index should work.");
</script>

View file

@ -0,0 +1,110 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Named items: applets</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-nameditem">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<applet name=test1></applet>
<applet name=test2></applet>
<applet name=test2></applet>
<applet id=test3></applet>
<applet id=test4></applet>
<applet id=test4></applet>
<applet name=test5></applet>
<applet id=test5></applet>
<applet id=test6></applet>
<applet name=test6></applet>
<applet id=test7 name=fail></applet>
<applet name=test8 id=fail></applet>
</div>
<script>
test(function() {
var applet = document.getElementsByTagName("applet")[0];
assert_equals(applet.name, "test1");
assert_true("test1" in document, '"test1" in document should be true');
assert_equals(document.test1, applet);
}, "If there is one applet, it should be returned (name)");
test(function() {
var applet1 = document.getElementsByTagName("applet")[1];
assert_equals(applet1.name, "test2");
var applet2 = document.getElementsByTagName("applet")[2];
assert_equals(applet2.name, "test2");
assert_true("test2" in document, '"test2" in document should be true');
var collection = document.test2;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [applet1, applet2]);
}, "If there are two applets, a collection should be returned. (name)");
test(function() {
var applet = document.getElementsByTagName("applet")[3];
assert_equals(applet.id, "test3");
assert_true("test3" in document, '"test3" in document should be true');
assert_equals(document.test3, applet);
}, "If there is one applet, it should be returned (id)");
test(function() {
var applet1 = document.getElementsByTagName("applet")[4];
assert_equals(applet1.id, "test4");
var applet2 = document.getElementsByTagName("applet")[5];
assert_equals(applet2.id, "test4");
assert_true("test4" in document, '"test4" in document should be true');
var collection = document.test4;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [applet1, applet2]);
}, "If there are two applets, a collection should be returned. (id)");
test(function() {
var applet1 = document.getElementsByTagName("applet")[6];
assert_equals(applet1.name, "test5");
var applet2 = document.getElementsByTagName("applet")[7];
assert_equals(applet2.id, "test5");
assert_true("test5" in document, '"test5" in document should be true');
var collection = document.test5;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [applet1, applet2]);
}, "If there are two applets, a collection should be returned. (name and id)");
test(function() {
var applet1 = document.getElementsByTagName("applet")[8];
assert_equals(applet1.id, "test6");
var applet2 = document.getElementsByTagName("applet")[9];
assert_equals(applet2.name, "test6");
assert_true("test6" in document, '"test6" in document should be true');
var collection = document.test6;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [applet1, applet2]);
}, "If there are two applets, a collection should be returned. (id and name)");
test(function() {
var applet = document.getElementsByTagName("applet")[10];
assert_equals(applet.id, "test7");
assert_true("test7" in document, '"test7" in document should be true');
assert_equals(document.test7, applet);
}, "A name shouldn't affect getting an applet by id");
test(function() {
var applet = document.getElementsByTagName("applet")[11];
assert_equals(applet.name, "test8");
assert_true("test8" in document, '"test8" in document should be true');
assert_equals(document.test8, applet);
}, "An id shouldn't affect getting an applet by name");
</script>

View file

@ -0,0 +1,104 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Named items: forms</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-nameditem">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<form name=test1></form>
<form name=test2></form>
<form name=test2></form>
<form id=test3></form>
<form id=test4></form>
<form id=test4></form>
<form name=test5></form>
<form id=test5></form>
<form id=test6></form>
<form name=test6></form>
<form id=test7 name=fail></form>
<form name=test8 id=fail></form>
</div>
<script>
test(function() {
var form = document.getElementsByTagName("form")[0];
assert_equals(form.name, "test1");
assert_true("test1" in document, '"test1" in document should be true');
assert_equals(document.test1, form);
}, "If there is one form, it should be returned (name)");
test(function() {
var form1 = document.getElementsByTagName("form")[1];
assert_equals(form1.name, "test2");
var form2 = document.getElementsByTagName("form")[2];
assert_equals(form2.name, "test2");
assert_true("test2" in document, '"test2" in document should be true');
var collection = document.test2;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [form1, form2]);
}, "If there are two forms, a collection should be returned. (name)");
test(function() {
var form = document.getElementsByTagName("form")[3];
assert_equals(form.id, "test3");
assert_false("test3" in document, '"test3" in document should be false');
assert_equals(document.test3, undefined);
}, "If there is one form, it should not be returned (id)");
test(function() {
var form1 = document.getElementsByTagName("form")[4];
assert_equals(form1.id, "test4");
var form2 = document.getElementsByTagName("form")[5];
assert_equals(form2.id, "test4");
assert_false("test4" in document, '"test4" in document should be false');
assert_equals(document.test4, undefined);
}, "If there are two forms, nothing should be returned. (id)");
test(function() {
var form1 = document.getElementsByTagName("form")[6];
assert_equals(form1.name, "test5");
var form2 = document.getElementsByTagName("form")[7];
assert_equals(form2.id, "test5");
assert_true("test5" in document, '"test5" in document should be true');
assert_equals(document.test5, form1);
}, "If there are two forms, a collection should be returned. (name and id)");
test(function() {
var form1 = document.getElementsByTagName("form")[8];
assert_equals(form1.id, "test6");
var form2 = document.getElementsByTagName("form")[9];
assert_equals(form2.name, "test6");
assert_true("test6" in document, '"test6" in document should be true');
assert_equals(document.test6, form2);
}, "If there are two forms, a collection should be returned. (id and name)");
test(function() {
var form = document.getElementsByTagName("form")[10];
assert_equals(form.id, "test7");
assert_false("test7" in document, '"test7" in document should be false');
assert_equals(document.test7, undefined);
}, "A name shouldn't affect getting an form by id");
test(function() {
var form = document.getElementsByTagName("form")[11];
assert_equals(form.name, "test8");
assert_true("test8" in document, '"test8" in document should be true');
assert_equals(document.test8, form);
}, "An id shouldn't affect getting an form by name");
</script>

View file

@ -0,0 +1,104 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Named items: embeds</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-nameditem">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<embed name=test1></embed>
<embed name=test2></embed>
<embed name=test2></embed>
<embed id=test3></embed>
<embed id=test4></embed>
<embed id=test4></embed>
<embed name=test5></embed>
<embed id=test5></embed>
<embed id=test6></embed>
<embed name=test6></embed>
<embed id=test7 name=fail></embed>
<embed name=test8 id=fail></embed>
</div>
<script>
test(function() {
var embed = document.getElementsByTagName("embed")[0];
assert_equals(embed.name, "test1");
assert_true("test1" in document, '"test1" in document should be true');
assert_equals(document.test1, embed);
}, "If there is one embed, it should be returned (name)");
test(function() {
var embed1 = document.getElementsByTagName("embed")[1];
assert_equals(embed1.name, "test2");
var embed2 = document.getElementsByTagName("embed")[2];
assert_equals(embed2.name, "test2");
assert_true("test2" in document, '"test2" in document should be true');
var collection = document.test2;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [embed1, embed2]);
}, "If there are two embeds, a collection should be returned. (name)");
test(function() {
var embed = document.getElementsByTagName("embed")[3];
assert_equals(embed.id, "test3");
assert_false("test3" in document, '"test3" in document should be false');
assert_equals(document.test3, undefined);
}, "If there is one embed, it should not be returned (id)");
test(function() {
var embed1 = document.getElementsByTagName("embed")[4];
assert_equals(embed1.id, "test4");
var embed2 = document.getElementsByTagName("embed")[5];
assert_equals(embed2.id, "test4");
assert_false("test4" in document, '"test4" in document should be false');
assert_equals(document.test4, undefined);
}, "If there are two embeds, nothing should be returned. (id)");
test(function() {
var embed1 = document.getElementsByTagName("embed")[6];
assert_equals(embed1.name, "test5");
var embed2 = document.getElementsByTagName("embed")[7];
assert_equals(embed2.id, "test5");
assert_true("test5" in document, '"test5" in document should be true');
assert_equals(document.test5, embed1);
}, "If there are two embeds, a collection should be returned. (name and id)");
test(function() {
var embed1 = document.getElementsByTagName("embed")[8];
assert_equals(embed1.id, "test6");
var embed2 = document.getElementsByTagName("embed")[9];
assert_equals(embed2.name, "test6");
assert_true("test6" in document, '"test6" in document should be true');
assert_equals(document.test6, embed2);
}, "If there are two embeds, a collection should be returned. (id and name)");
test(function() {
var embed = document.getElementsByTagName("embed")[10];
assert_equals(embed.id, "test7");
assert_false("test7" in document, '"test7" in document should be false');
assert_equals(document.test7, undefined);
}, "A name shouldn't affect getting an embed by id");
test(function() {
var embed = document.getElementsByTagName("embed")[11];
assert_equals(embed.name, "test8");
assert_true("test8" in document, '"test8" in document should be true');
assert_equals(document.test8, embed);
}, "An id shouldn't affect getting an embed by name");
</script>

View file

@ -0,0 +1,106 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Named items: imgs</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-nameditem">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<img name=test1>
<img name=test2>
<img name=test2>
<img id=test3>
<img id=test4>
<img id=test4>
<img name=test5>
<img id=test5>
<img id=test6>
<img name=test6>
<img id=test7 name=fail>
<img name=test8 id=fail>
</div>
<script>
test(function() {
var img = document.getElementsByTagName("img")[0];
assert_equals(img.name, "test1");
assert_true("test1" in document, '"test1" in document should be true');
assert_equals(document.test1, img);
}, "If there is one img, it should be returned (name)");
test(function() {
var img1 = document.getElementsByTagName("img")[1];
assert_equals(img1.name, "test2");
var img2 = document.getElementsByTagName("img")[2];
assert_equals(img2.name, "test2");
assert_true("test2" in document, '"test2" in document should be true');
var collection = document.test2;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [img1, img2]);
}, "If there are two imgs, a collection should be returned. (name)");
test(function() {
var img = document.getElementsByTagName("img")[3];
assert_equals(img.id, "test3");
assert_false("test3" in document, '"test3" in document should be false');
assert_equals(document.test3, undefined);
}, "If there is one img, it should not be returned (id)");
test(function() {
var img1 = document.getElementsByTagName("img")[4];
assert_equals(img1.id, "test4");
var img2 = document.getElementsByTagName("img")[5];
assert_equals(img2.id, "test4");
assert_false("test4" in document, '"test4" in document should be false');
var collection = document.test4;
assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection");
assert_array_equals(collection, [img1, img2]);
}, "If there are two imgs, nothing should be returned. (id)");
test(function() {
var img1 = document.getElementsByTagName("img")[6];
assert_equals(img1.name, "test5");
var img2 = document.getElementsByTagName("img")[7];
assert_equals(img2.id, "test5");
assert_true("test5" in document, '"test5" in document should be true');
assert_equals(document.test5, img1);
}, "If there are two imgs, the one with a name should be returned. (name and id)");
test(function() {
var img1 = document.getElementsByTagName("img")[8];
assert_equals(img1.id, "test6");
var img2 = document.getElementsByTagName("img")[9];
assert_equals(img2.name, "test6");
assert_true("test6" in document, '"test6" in document should be true');
assert_equals(document.test6, img2);
}, "If there are two imgs, the one with a name should be returned. (id and name)");
test(function() {
var img = document.getElementsByTagName("img")[10];
assert_equals(img.id, "test7");
assert_true("test7" in document, '"test7" in document should be true');
assert_equals(document.test7, img);
}, "A name should affect getting an img by id");
test(function() {
var img = document.getElementsByTagName("img")[11];
assert_equals(img.name, "test8");
assert_true("test8" in document, '"test8" in document should be true');
assert_equals(document.test8, img);
}, "An id shouldn't affect getting an img by name");
</script>

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<title>document.compatMode: Standards</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode">
<body>
<div id="log"></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.compatMode, "CSS1Compat");
})
</script>

View file

@ -0,0 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>document.compatMode: Almost standards</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode">
<body>
<div id="log"></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.compatMode, "CSS1Compat");
})
</script>

View file

@ -0,0 +1,12 @@
<title>document.compatMode: Quirks</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode">
<body>
<div id="log"></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.compatMode, "BackCompat");
})
</script>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>document.compatMode: Standards</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode"/>
</head>
<body>
<div id="log"></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.compatMode, "CSS1Compat");
})
</script>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>document.compatMode: Standards</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode"/>
</head>
<body>
<div id="log"></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.compatMode, "CSS1Compat");
})
</script>
</body>
</html>

View file

@ -0,0 +1,17 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>document.compatMode: Standards</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-compatmode"/>
</head>
<body>
<div id="log"></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
assert_equals(document.compatMode, "CSS1Compat");
})
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>document.cookie</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/#resource-metadata-management">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function(){
assert_equals(document.cookie, "");
}, "document has no cookie");
test(function(){
var doc = document.implementation.createHTMLDocument("doc");
assert_equals(doc.cookie, "");
doc.cookie = "test=foobar";
assert_equals(doc.cookie, "");
}, "getting cookie for a cookie-averse document returns empty string, setting does nothing");
</script>

View file

@ -0,0 +1,47 @@
<!DOCTYPE html>
<title>document.lastModified should return current local time</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var d = new Date();
var last_modified = document.lastModified;
var initial_modified = Date.parse(last_modified) / 1000;
var expected = Math.round(d / 1000);
test(function() {
assert_approx_equals(initial_modified, expected, 2.5);
}, "Date returned by lastModified is current at page load");
var pattern = /[0-9]{2}\/[0-9]{2}\/[0-9]{4} ([0-9]{2}):([0-9]{2}):([0-9]{2})/
test(function() {
assert_regexp_match(last_modified, pattern,
"Format should match the pattern \"NN/NN/NNNN NN:NN:NN\".");
}, "Date returned by lastModified is in the form \"MM/DD/YYYY hh:mm:ss\".");
var hours = d.getHours()
var minutes = d.getMinutes()
var seconds = d.getSeconds()
test(function() {
var local_time = hours * 60 * 60 + minutes * 60 + seconds;
var m = pattern.exec(last_modified);
var last_modified_time = parseInt(m[1]) * 60 * 60 + parseInt(m[2]) * 60 + parseInt(m[3]);
assert_approx_equals(last_modified_time, local_time, 2,
"Hours and minutes should match local time.");
}, "Date returned by lastModified is in the user's local time zone.");
var t = async_test("Date returned by lastModified is current after timeout.");
setTimeout(function() {
t.step(function() {
var new_modified = Date.parse(document.lastModified) / 1000;
var new_expected = Math.round(new Date() / 1000);
assert_approx_equals(new_modified, new_expected, 2.5,
"(initial value was " + initial_modified + ")");
t.done();
});
}, 4000);
</script>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>document.lastModified</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/#resource-metadata-management">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function(){
var date = new Date("Thu, 01 Jan 1970 01:23:45 GMT");
var result = ('0' + (date.getMonth()+1)).slice(-2) + '/' + ('0' + date.getDate()).slice(-2) + '/' + date.getFullYear() + " " + [date.getHours(),date.getMinutes(),date.getSeconds()].map(function(n){return ("0" + n).slice(-2);}).join(":");
assert_equals(document.lastModified, result);
}, "lastModified should return the last modified date and time");
</script>

View file

@ -0,0 +1 @@
Last-Modified: Thu, 01 Jan 1970 01:23:45 GMT

View file

@ -0,0 +1,33 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>document.readyState</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/#resource-metadata-management">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t1 = async_test("readyState equals 'complete' when the document has loaded"),
t2 = async_test("readyState equals 'interactive' when the document is finished parsing"),
t3 = async_test("readystatechange event is fired each time document.readyState changes");
window.onload = t1.step_func_done(function(){
assert_equals(document.readyState, "complete");
});
document.addEventListener("DOMContentLoaded", function(event) {
t2.step(function() {
assert_equals(document.readyState, "interactive")
});
t2.done();
});
var states = [document.readyState];
document.onreadystatechange = t3.step_func(function(){
states.push(document.readyState);
if (document.readyState === "complete") {
assert_array_equals(states, ["loading", "interactive", "complete"]);
t3.done();
}
})
</script>