summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/dom/documents
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/dom/documents')
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html227
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.currentScript.html219
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.getElementsByClassName-null-undef.html30
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Element.getElementsByClassName-null-undef.html30
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/cross-domain.js1
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.embeds-document.plugins-01.html87
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.forms.html83
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByClassName-same.html17
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-case-xhtml.xhtml21
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-case.html16
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-id-xhtml.xhtml20
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-id.html15
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-interface.html16
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-liveness.html26
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-namespace-xhtml.xhtml32
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-namespace.html27
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-newelements-xhtml.xhtml126
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-newelements.html47
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-null-undef-xhtml.xhtml35
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-null-undef.html30
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-param-xhtml.xhtml28
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-param.html23
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-same.html17
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.head-01.html22
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.head-02.html20
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.images.html119
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.links.html27
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.scripts.html21
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-01.html32
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-02.xhtml37
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-03.html31
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-04.xhtml48
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-05.html42
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-06.html19
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-07.html11
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-08.html22
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-09.html97
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html27
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-01.html19
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-02.html99
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-03.html18
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-04.html104
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-05.html104
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-06.html104
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-07.html109
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-08.html31
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-names.html101
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-01.html13
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-02.html14
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-03.html12
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-04.xhtml18
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-05.xhtml19
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-06.xhtml17
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-cookie.html41
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified-01.html25
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html15
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html.headers1
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-readyState.html33
-rw-r--r--testing/web-platform/tests/html/dom/documents/resource-metadata-management/support/document-lastModified-utils.js78
59 files changed, 2723 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html
new file mode 100644
index 0000000000..77de1d93b5
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html
@@ -0,0 +1,227 @@
+<!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");
+
+test(function() {
+ assert_not_equals(document.body, null);
+ assert_true(document.body instanceof HTMLBodyElement, "should be HTMLBodyElement");
+ assert_equals(document.body.tagName, "BODY");
+}, "existing document's body");
+
+
+var originalBody = document.body;
+test(function() {
+ assert_throws_js(TypeError, function() {
+ document.body = "text"
+ })
+ assert_equals(document.body, originalBody);
+}, "Setting document.body to a string.")
+test(function() {
+ assert_throws_dom("HierarchyRequestError", function() {
+ document.body = document.createElement("div")
+ })
+ assert_equals(document.body, originalBody);
+}, "Setting document.body to a div element.")
+test(function() {
+ var doc = createDocument();
+ assert_throws_dom("HierarchyRequestError", function() {
+ doc.body = doc.createElement("body")
+ })
+ assert_equals(doc.body, null);
+}, "Setting document.body when there's no root element.")
+test(function() {
+ var doc = document.implementation.createHTMLDocument();
+
+ var new_body = doc.createElement("body");
+ assert_true(new_body instanceof HTMLBodyElement, "should be HTMLBodyElement");
+ assert_equals(new_body.tagName, "BODY");
+
+ doc.body = new_body;
+ assert_equals(doc.body, new_body);
+}, "Setting document.body to a new body element.");
+test(function() {
+ var doc = document.implementation.createHTMLDocument();
+
+ var new_frameset = doc.createElement("frameset");
+ assert_true(new_frameset instanceof HTMLFrameSetElement, "should be HTMLFrameSetElement");
+ assert_equals(new_frameset.tagName, "FRAMESET");
+
+ doc.body = new_frameset;
+ assert_equals(doc.body, new_frameset, "test6-3, append frameset to a new document");
+}, "Setting document.body to a new frameset element.");
+
+test(function() {
+ var doc = createDocument();
+ var html = doc.appendChild(doc.createElement("html"));
+ var f =
+ html.appendChild(doc.createElement("frameset"));
+ assert_equals(doc.body, f);
+
+ var b = doc.createElement("body");
+ doc.body = b;
+
+ assert_equals(f.parentNode, null,
+ "Frameset should have been removed from the tree");
+ assert_equals(doc.body, b, "Body should be the new doc.body");
+}, "Setting document.body to a body will replace an existing frameset if there is one.");
+
+test(function() {
+ var doc = createDocument();
+ var html = doc.appendChild(doc.createElement("html"));
+ var b =
+ html.appendChild(doc.createElement("body"));
+ assert_equals(doc.body, b);
+
+ var f = doc.createElement("frameset");
+ doc.body = f;
+
+ assert_equals(b.parentNode, null,
+ "Body should have been removed from the tree");
+ assert_equals(doc.body, f, "Frameset should be the new doc.body");
+}, "Setting document.body to a frameset will replace an existing body if there is one.");
+
+test(function() {
+ var doc = createDocument();
+ var html = doc.appendChild(doc.createElement("html"));
+ var b =
+ html.appendChild(doc.createElement("body"));
+ var f1 = html.appendChild(doc.createElement("frameset"));
+ assert_equals(doc.body, b);
+
+ var f2 = doc.createElement("frameset");
+ doc.body = f2;
+
+ assert_equals(b.parentNode, null,
+ "Body should have been removed from the tree");
+ assert_equals(f1.parentNode, html,
+ "Frameset following body should still be in the tree.");
+ assert_equals(doc.body, f2, "New frameset should be the new doc.body");
+ assert_equals(f2.nextSibling, f1, "New frameset should have replaced the body");
+}, "Setting document.body to a frameset will replace the first existing body/frameset.");
+
+test(function() {
+ var doc = createDocument();
+ doc.appendChild(doc.createElement("test"));
+ var new_body = doc.createElement("body");
+ doc.body = new_body;
+ assert_equals(doc.documentElement.firstChild, new_body, "new_body should be inserted");
+ assert_equals(doc.body, null, "Getter should return null when the root is not html");
+}, "Setting document.body to a new body element when the root element is a test element.");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.currentScript.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.currentScript.html
new file mode 100644
index 0000000000..245bae98ee
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.currentScript.html
@@ -0,0 +1,219 @@
+<!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>
+<script src="/common/get-host-info.sub.js"></script>
+<div id="log"></div>
+<script>
+var data = {
+ "parse-inline" : [],
+ "parse-ext" : [],
+ "dom-inline" : [],
+ "dom-ext" : [],
+ "nested" : ["nested-outer","nested-inner","nested-outer"],
+ "script-load-error" : [null],
+ "script-window-error" : ["script-error-compile","script-error-runtime"],
+ "timeout" : [null],
+ "eval" : [],
+ "xhr-test" : [],
+ "script-svg" : [],
+ "script-async" : [],
+ "script-defer" : [],
+ "script-async-false" : [],
+ "iframe-src" : [],
+ "cross-origin" : [null],
+ "document-write" : [],
+ "microtask": [],
+};
+
+var expected = {};
+var actual = {};
+
+Object.keys(data).forEach(function(id) {
+ var test_expected = data[id];
+ if(test_expected.length == 0) {
+ test_expected = [id];
+ }
+ expected[id] = test_expected;
+ actual[id] = [];
+});
+
+var tests = {};
+setup({allow_uncaught_exception : true});
+
+Object.keys(expected).forEach(function(id) {
+ var testmsg = "Script " + id;
+ tests[id] = async_test(testmsg);
+});
+
+function verify(id) {
+ tests[id].step(function() {
+ actual[id].push(document.currentScript);
+ })
+}
+
+function finish(id) {
+ tests[id].step(function() {
+ assert_array_equals(actual[id],expected[id].map(function(id) {
+ return document.getElementById(id);
+ }));
+ this.done();
+ })
+}
+
+</script>
+
+<!-- Test parser inserted scripts -->
+<script id="parse-inline">
+verify('parse-inline');
+finish('parse-inline')
+</script>
+<script id="parse-ext" src="data:text/plain,verify('parse-ext')"></script>
+<script>finish('parse-ext');</script>
+
+<!-- Test DOM inserted scripts -->
+<script>
+var s = document.createElement("script");
+s.textContent = "verify('dom-inline');";
+s.id = "dom-inline";
+document.body.appendChild(s);
+finish('dom-inline');
+
+s = document.createElement("script");
+s.src = "data:text/plain,verify('dom-ext');";
+s.id = "dom-ext";
+s.onload = function() {
+ finish('dom-ext');
+}
+document.body.appendChild(s);
+</script>
+
+<!-- Test Nested scripts -->
+<script id="nested-outer">
+ verify("nested");
+ var s = document.createElement("script");
+ s.textContent = "verify('nested')";
+ s.id = "nested-inner";
+ document.body.appendChild(s);
+ verify("nested");
+ finish('nested');
+</script>
+
+<!-- Test script load error event listener -->
+<script>
+function testLoadFail() {
+ verify('script-load-error');
+ finish('script-load-error');
+}
+</script>
+
+<script src="http://some.nonexistant.test/fail" id="script-load-error" onerror="testLoadFail()">
+</script>
+
+<!-- Test for runtime and compile time errors -->
+<script>
+ window.onerror = function() {
+ verify('script-window-error');
+ }
+
+ var s = document.createElement("script");
+ s.id = "script-error-compile";
+ s.textContent = "{";
+ document.body.appendChild(s);
+
+ window.onerror = function() {
+ verify('script-window-error');
+ }
+
+ s = document.createElement("script");
+ s.id = "script-error-runtime";
+ s.textContent = "undefinedfn();";
+ document.body.appendChild(s);
+
+ finish('script-window-error');
+</script>
+
+<!-- Verify in setTimeout -->
+<script>
+ setTimeout(function() {
+ verify('timeout');
+ finish('timeout');
+ },0);
+</script>
+
+<!-- Verify in eval -->
+<script id="eval">
+ eval('verify("eval")');
+ finish("eval");
+</script>
+
+<!-- Verify in synchronous xhr -->
+<script id="xhr-test">
+ var request = new XMLHttpRequest();
+ request.open('GET','/',false);
+ request.send(null);
+
+ if(request.status === 200) {
+ verify('xhr-test');
+ finish('xhr-test');
+ }
+</script>
+
+<!-- Testing script within svg -->
+<svg>
+ <script id="script-svg">
+ verify('script-svg');
+ finish('script-svg');
+ </script>
+</svg>
+
+<!-- Test script async and defer -->
+<script id='script-async' async src='data:text/plain,verify("script-async"),finish("script-async")'></script>
+
+<script id='script-defer' defer src='data:text/plain,verify("script-defer"),finish("script-defer")'></script>
+
+<!-- Test async = false dynamic script loading -->
+<script>
+ var s = document.createElement("script");
+ s.id = "script-async-false";
+ s.src = "data:text/plain,verify('script-async-false');"
+ s.onload = function() {
+ finish('script-async-false');
+ }
+ s.async = false;
+ document.body.appendChild(s);
+</script>
+
+<!-- Verify in iframe javascript uri scheme -->
+<iframe src="javascript:parent.verify('iframe-src'),parent.finish('iframe-src')"
+ style="visibility:hidden;display:none">
+</iframe>
+
+<!-- Testing cross origin script -->
+<script>
+var s = document.createElement("script");
+s.id = "cross-origin";
+s.src = get_host_info(). HTTP_REMOTE_ORIGIN + "/html/dom/documents/dom-tree-accessors/cross-domain.js"
+s.onload = function() {
+ verify('cross-origin')
+ finish('cross-origin');
+}
+document.body.appendChild(s);
+
+</script>
+
+<!-- Testing document.write -->
+<script>
+document.write('<script id="document-write">verify("document-write"); finish("document-write");</' + 'script>');
+</script>
+
+<!-- Testing microtask -->
+<script id="microtask">
+ Promise.resolve().then(() => {
+ verify("microtask");
+ finish("microtask");
+ });
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.getElementsByClassName-null-undef.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.getElementsByClassName-null-undef.html
new file mode 100644
index 0000000000..dc132e5ec7
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.getElementsByClassName-null-undef.html
@@ -0,0 +1,30 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Element.getElementsByClassName-null-undef.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Element.getElementsByClassName-null-undef.html
new file mode 100644
index 0000000000..b4d9241647
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Element.getElementsByClassName-null-undef.html
@@ -0,0 +1,30 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/cross-domain.js b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/cross-domain.js
new file mode 100644
index 0000000000..32effe3c45
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/cross-domain.js
@@ -0,0 +1 @@
+//test script to check cross-domain script execution as in Document.currentScript.sub.html \ No newline at end of file
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.embeds-document.plugins-01.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.embeds-document.plugins-01.html
new file mode 100644
index 0000000000..e710798915
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.embeds-document.plugins-01.html
@@ -0,0 +1,87 @@
+<!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");
+
+test(function() {
+ var embed1 = document.createElement("embed"),
+ embed2 = document.createElement("embed");
+ document.body.appendChild(embed1);
+ this.add_cleanup(function() { document.body.removeChild(embed1) });
+ var embeds = document.embeds;
+ assert_true(embeds instanceof HTMLCollection);
+ assert_equals(embeds.length, 1);
+
+ document.body.appendChild(embed2);
+ assert_equals(embeds.length, 2);
+
+ document.body.removeChild(embed2);
+ assert_equals(embeds.length, 1);
+}, "Document.embeds should be a live collection");
+
+test(function() {
+ var embed1 = document.createElement("embed"),
+ embed2 = document.createElement("embed");
+ document.body.appendChild(embed1);
+ this.add_cleanup(function() { document.body.removeChild(embed1) });
+ var pls = document.plugins;
+ assert_true(pls instanceof HTMLCollection);
+ assert_equals(pls.length, 1);
+
+ document.body.appendChild(embed2);
+ assert_equals(pls.length, 2);
+
+ document.body.removeChild(embed2);
+ assert_equals(pls.length, 1);
+}, "Document.plugins should be a live collection");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.forms.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.forms.html
new file mode 100644
index 0000000000..f354c57477
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.forms.html
@@ -0,0 +1,83 @@
+<!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");
+}, "document.forms")
+
+test(function() {
+ // The `item` method takes one *numeric* argument. Passing a string to `item`
+ // results in that string getting converted to 0
+ assert_equals(document.forms.item("form1").id, "form1");
+ assert_equals(document.forms.item("form2").id, "form1");
+}, "document.forms.item with string arg")
+
+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);
+ }
+ // https://webidl.spec.whatwg.org/#property-enumeration
+ // If the object supports indexed properties, then the object’s supported
+ // property indices are enumerated first, in numerical order.
+ assert_array_equals(result.splice(0, 3), ["0", "1", "2"]);
+ // [...]
+ // Finally, any enumerable own properties or properties from the object’s
+ // prototype chain are then enumerated, in no defined order.
+ assert_array_equals(result.sort(), ["item", "namedItem", "length"].sort())
+}, "document.forms iteration")
+
+test(function() {
+ var result = Object.getOwnPropertyNames(document.forms);
+ assert_array_equals(result, ["0", "1", "2", "form1", "form2"])
+}, "document.forms getOwnPropertyNames")
+
+test(function() {
+ var forms = document.forms;
+ assert_true(forms instanceof HTMLCollection);
+ assert_equals(forms.length, 3);
+
+ var form = document.createElement("form");
+ document.body.appendChild(form);
+ assert_equals(forms.length, 4);
+
+ document.body.removeChild(form);
+ assert_equals(forms.length, 3);
+}, "Document.forms should be a live collection");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByClassName-same.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByClassName-same.html
new file mode 100644
index 0000000000..a91c838d8a
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByClassName-same.html
@@ -0,0 +1,17 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-case-xhtml.xhtml b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-case-xhtml.xhtml
new file mode 100644
index 0000000000..f15edb6f1d
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-case-xhtml.xhtml
@@ -0,0 +1,21 @@
+<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"/>
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-case.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-case.html
new file mode 100644
index 0000000000..9a82e6805c
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-case.html
@@ -0,0 +1,16 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-id-xhtml.xhtml b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-id-xhtml.xhtml
new file mode 100644
index 0000000000..51b9e22f84
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-id-xhtml.xhtml
@@ -0,0 +1,20 @@
+<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"/>
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-id.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-id.html
new file mode 100644
index 0000000000..099215d3a7
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-id.html
@@ -0,0 +1,15 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-interface.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-interface.html
new file mode 100644
index 0000000000..97646e39cf
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-interface.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-liveness.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-liveness.html
new file mode 100644
index 0000000000..74aad6954f
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-liveness.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<title>Document.getElementsByName: liveness</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ var input = document.createElement("input"),
+ embed = document.createElement("embed");
+ input.setAttribute("name", "test");
+ input.setAttribute("type", "text");
+ embed.setAttribute("name", "test");
+ document.body.appendChild(input);
+ this.add_cleanup(function() { document.body.removeChild(input) });
+ var e = document.getElementsByName("test");
+ assert_true(e instanceof NodeList);
+ assert_equals(e.length, 1);
+
+ document.body.appendChild(embed);
+ assert_equals(e.length, 2);
+
+ document.body.removeChild(embed);
+ assert_equals(e.length, 1);
+}, "Document.getElementsByName() should be a live collection");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-namespace-xhtml.xhtml b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-namespace-xhtml.xhtml
new file mode 100644
index 0000000000..e09ece7b1f
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-namespace-xhtml.xhtml
@@ -0,0 +1,32 @@
+<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"/>
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-namespace.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-namespace.html
new file mode 100644
index 0000000000..63b6260424
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-namespace.html
@@ -0,0 +1,27 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-newelements-xhtml.xhtml b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-newelements-xhtml.xhtml
new file mode 100644
index 0000000000..c2dc99a55d
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-newelements-xhtml.xhtml
@@ -0,0 +1,126 @@
+<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"/>
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-newelements.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-newelements.html
new file mode 100644
index 0000000000..2ab42b9733
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-newelements.html
@@ -0,0 +1,47 @@
+<!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">
+<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>
+var testDiv = document.getElementById("test");
+for (var i = 0; i < testDiv.children.length; i++) {
+ var name = testDiv.children[i].getAttribute("name");
+ test(function() {
+ assert_equals(document.getElementsByName(name).length, 1);
+ assert_equals(document.getElementsByName(name)[0],
+ document.getElementsByTagName(name)[0]);
+ }, 'getElementsByName("' + name + '")');
+}
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-null-undef-xhtml.xhtml b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-null-undef-xhtml.xhtml
new file mode 100644
index 0000000000..06d182860b
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-null-undef-xhtml.xhtml
@@ -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://webidl.spec.whatwg.org/#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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-null-undef.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-null-undef.html
new file mode 100644
index 0000000000..f1dfbf9e39
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-null-undef.html
@@ -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://webidl.spec.whatwg.org/#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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-param-xhtml.xhtml b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-param-xhtml.xhtml
new file mode 100644
index 0000000000..e57e9d5c0d
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-param-xhtml.xhtml
@@ -0,0 +1,28 @@
+<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"/>
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-param.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-param.html
new file mode 100644
index 0000000000..aa1bb01bfa
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-param.html
@@ -0,0 +1,23 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-same.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-same.html
new file mode 100644
index 0000000000..f122857a2b
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.getElementsByName/document.getElementsByName-same.html
@@ -0,0 +1,17 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.head-01.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.head-01.html
new file mode 100644
index 0000000000..f919d79a32
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.head-01.html
@@ -0,0 +1,22 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.head-02.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.head-02.html
new file mode 100644
index 0000000000..d0189574e2
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.head-02.html
@@ -0,0 +1,20 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.images.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.images.html
new file mode 100644
index 0000000000..10ebe5ee8a
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.images.html
@@ -0,0 +1,119 @@
+<!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");
+
+test(function() {
+ var div = document.getElementById("test");
+ var imgs = document.images;
+ assert_true(imgs instanceof HTMLCollection);
+ assert_equals(imgs.length, 10);
+
+ var img = document.createElement("img");
+ div.appendChild(img);
+ assert_equals(imgs.length, 11);
+
+ div.removeChild(img);
+ assert_equals(imgs.length, 10);
+}, "Document.images should be a live collection");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.links.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.links.html
new file mode 100644
index 0000000000..69c7d8c52c
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.links.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Document.links</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<div id=test>
+<a href=""></a>
+<a href=""></a>
+</div>
+<script>
+test(function() {
+ var div = document.getElementById("test");
+ var links = document.links;
+ assert_true(links instanceof HTMLCollection);
+ assert_equals(links.length, 2);
+
+ var a = document.createElement("a");
+ a.setAttribute("href", "");
+ div.appendChild(a);
+ assert_equals(links.length, 3);
+
+ div.removeChild(a);
+ assert_equals(links.length, 2);
+}, "Document.links should be a live collection");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.scripts.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.scripts.html
new file mode 100644
index 0000000000..82d3db14b2
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.scripts.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Document.scripts</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var scripts = document.scripts;
+ assert_true(scripts instanceof HTMLCollection);
+ assert_equals(scripts.length, 3);
+
+ var script = document.createElement("script");
+ document.body.appendChild(script);
+ assert_equals(scripts.length, 4);
+
+ document.body.removeChild(script);
+ assert_equals(scripts.length, 3);
+}, "Document.scripts should be a live collection");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-01.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-01.html
new file mode 100644
index 0000000000..05ddab9ca4
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-01.html
@@ -0,0 +1,32 @@
+<!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">
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-02.xhtml b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-02.xhtml
new file mode 100644
index 0000000000..917b8787df
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-02.xhtml
@@ -0,0 +1,37 @@
+<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"/>
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-03.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-03.html
new file mode 100644
index 0000000000..952c29db5f
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-03.html
@@ -0,0 +1,31 @@
+<!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">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+function test_title(set, expected) {
+ test(function() {
+ document.title = set;
+ assert_equals(document.title, expected);
+ }, "document.title after setting to " + format_value(set));
+}
+
+test(function() {
+ // Single space characters must be normalized. (WHATWG r4353)
+ assert_equals(document.title, "document.title and space normalization");
+}, "document.title initial value");
+
+test_title("one space", "one space");
+test_title("two spaces", "two spaces");
+test_title("one\ttab", "one tab");
+test_title("two\t\ttabs", "two tabs");
+test_title("one\nnewline", "one newline");
+test_title("two\n\nnewlines", "two newlines");
+test_title("one\fform feed", "one form feed");
+test_title("two\f\fform feeds", "two form feeds");
+test_title("one\rcarriage return", "one carriage return");
+test_title("two\r\rcarriage returns", "two carriage returns");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-04.xhtml b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-04.xhtml
new file mode 100644
index 0000000000..fbe891650a
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-04.xhtml
@@ -0,0 +1,48 @@
+<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"/>
+<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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-05.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-05.html
new file mode 100644
index 0000000000..df6ffc30f8
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-05.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-06.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-06.html
new file mode 100644
index 0000000000..a80723f238
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-06.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-07.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-07.html
new file mode 100644
index 0000000000..9723d3f811
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-07.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-08.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-08.html
new file mode 100644
index 0000000000..a643b75f4e
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-08.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-09.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-09.html
new file mode 100644
index 0000000000..a3273f626c
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-09.html
@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<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 SVG_NAMESPACE = "http://www.w3.org/2000/svg";
+var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
+
+function newSVGDocument() {
+ return document.implementation.createDocument(SVG_NAMESPACE, "svg", null);
+}
+
+function assertIsSVGTitle(element, expectedText) {
+ assert_equals(element.namespaceURI, SVG_NAMESPACE);
+ assert_equals(element.localName, "title");
+ assert_equals(element.textContent, expectedText);
+}
+
+test(function() {
+ var doc = newSVGDocument();
+ assert_equals(doc.title, "");
+ var child = doc.createElementNS(SVG_NAMESPACE, "x-child");
+ doc.documentElement.appendChild(child);
+ doc.title = "foo";
+ assertIsSVGTitle(doc.documentElement.firstChild, "foo");
+ assert_equals(doc.title, "foo");
+}, "No title element in SVG document");
+
+test(function() {
+ var doc = newSVGDocument();
+ var title = doc.createElementNS(SVG_NAMESPACE, "title");
+ title.textContent = "foo";
+ doc.documentElement.appendChild(title)
+ assert_equals(doc.title, "foo");
+ doc.title += "bar";
+ assert_equals(title.textContent, "foobar");
+ assert_equals(title.childNodes.length, 1);
+ assert_true(title.childNodes[0] instanceof Text);
+ assert_equals(doc.title, "foobar");
+ doc.title = "";
+ assert_equals(title.textContent, "");
+ assert_equals(doc.title, "");
+ assert_equals(title.childNodes.length, 0);
+}, "Title element in SVG document");
+
+test(function() {
+ var doc = newSVGDocument();
+ var title = doc.createElementNS(SVG_NAMESPACE, "title");
+ title.textContent = "foo";
+ var child = doc.createElementNS(SVG_NAMESPACE, "x-child");
+ child.appendChild(title);
+ doc.documentElement.appendChild(child);
+ assert_equals(doc.title, "");
+
+ // Now test that on setting, we create a new element and don't change the
+ // existing one
+ doc.title = "bar";
+ assert_equals(title.textContent, "foo");
+ assertIsSVGTitle(doc.documentElement.firstChild, "bar");
+ assert_equals(doc.title, "bar");
+}, "Title element not child of SVG root");
+
+test(function() {
+ var doc = newSVGDocument();
+ var title = doc.createElementNS(HTML_NAMESPACE, "title");
+ title.textContent = "foo";
+ doc.documentElement.appendChild(title);
+ assert_equals(doc.title, "");
+}, "Title element not in SVG namespace");
+
+test(function() {
+ // "SVG" != "svg"
+ var doc = document.implementation.createDocument(SVG_NAMESPACE, "SVG", null);
+
+ // Per spec, this does nothing
+ doc.title = "foo";
+ assert_equals(doc.documentElement.childNodes.length, 0);
+ assert_equals(doc.title, "");
+
+ // An SVG title is ignored by .title
+ doc.documentElement.appendChild(doc.createElementNS(SVG_NAMESPACE, "title"));
+ doc.documentElement.lastChild.textContent = "foo";
+ assert_equals(doc.title, "");
+
+ // But an HTML title is respected
+ doc.documentElement.appendChild(doc.createElementNS(HTML_NAMESPACE, "title"));
+ doc.documentElement.lastChild.textContent = "bar";
+ assert_equals(doc.title, "bar");
+
+ // Even if it's not a child of the root
+ var div = doc.createElementNS(HTML_NAMESPACE, "div");
+ div.appendChild(doc.documentElement.lastChild);
+ doc.documentElement.appendChild(div);
+ assert_equals(doc.title, "bar");
+}, 'Root element not named "svg"');
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html
new file mode 100644
index 0000000000..40eccd3de3
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<link rel="author" title="Rob Buis" href="mailto:rbuis@igalia.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>
+
+function newXMLDocument() {
+ return document.implementation.createDocument(null, "foo", null);
+}
+
+test(function() {
+ var doc = newXMLDocument();
+ assert_equals(doc.title, "");
+ doc.title = "fail";
+ assert_equals(doc.title, "");
+}, "Should not be able to set document title in XML document");
+
+test(function() {
+ var doc = newXMLDocument();
+ doc.documentElement.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "html:title"));
+ assert_equals(doc.title, "");
+ doc.title = "fail";
+ assert_equals(doc.title, "");
+}, "Should not be able to set document title in XML document with html:title element");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-01.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-01.html
new file mode 100644
index 0000000000..2b428aa65b
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-01.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-02.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-02.html
new file mode 100644
index 0000000000..8c3155e7e4
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-02.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-03.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-03.html
new file mode 100644
index 0000000000..be2ca173b0
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-03.html
@@ -0,0 +1,18 @@
+<!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>
+<applet name=test1></applet>
+<script>
+test(function() {
+ var applet = document.getElementsByTagName("applet")[0];
+ assert_equals(applet.name, undefined);
+
+ assert_false("test1" in document, '"test1" in document should be false');
+ assert_equals(document.test1, undefined);
+}, "applet elements are (mostly) gone");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-04.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-04.html
new file mode 100644
index 0000000000..b7c3ef8e9b
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-04.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-05.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-05.html
new file mode 100644
index 0000000000..843ce35796
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-05.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-06.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-06.html
new file mode 100644
index 0000000000..15a72b5f6b
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-06.html
@@ -0,0 +1,104 @@
+<!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 name="">
+
+<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');
+ assert_equals(document.test4, undefined);
+}, "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>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-07.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-07.html
new file mode 100644
index 0000000000..fc3f06c01b
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-07.html
@@ -0,0 +1,109 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Named items: objects</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/dom.html#dom-document-nameditem">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<div id="test">
+<object name=test1></object>
+
+<object name=test2></object>
+<object name=test2></object>
+
+<object id=test3></object>
+
+<object id=test4></object>
+<object id=test4></object>
+
+<object name=test5></object>
+<object id=test5></object>
+
+<object id=test6></object>
+<object name=test6></object>
+
+<object id=test7 name=fail></object>
+
+<object name=test8 id=fail></object>
+</div>
+<script>
+test(function() {
+ var object = document.getElementsByTagName("object")[0];
+ assert_equals(object.name, "test1");
+
+ assert_true("test1" in document, '"test1" in document should be true');
+ assert_equals(document.test1, object);
+}, "If there is one object, it should be returned (name)");
+
+test(function() {
+ var object1 = document.getElementsByTagName("object")[1];
+ assert_equals(object1.name, "test2");
+ var object2 = document.getElementsByTagName("object")[2];
+ assert_equals(object2.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, [object1, object2]);
+}, "If there are two objects, a collection should be returned. (name)");
+
+test(function() {
+ var object = document.getElementsByTagName("object")[3];
+ assert_equals(object.id, "test3");
+
+ assert_true("test3" in document, '"test3" in document should be true');
+ assert_equals(document.test3, object);
+}, "If there is one object, it should be returned (id)");
+
+test(function() {
+ var object1 = document.getElementsByTagName("object")[4];
+ assert_equals(object1.id, "test4");
+ var object2 = document.getElementsByTagName("object")[5];
+ assert_equals(object2.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, [object1, object2]);
+}, "If there are two objects, a collection should be returned. (id)");
+
+test(function() {
+ var object1 = document.getElementsByTagName("object")[6];
+ assert_equals(object1.name, "test5");
+ var object2 = document.getElementsByTagName("object")[7];
+ assert_equals(object2.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, [object1, object2]);
+}, "If there are two objects, a collection should be returned. (name and id)");
+
+test(function() {
+ var object1 = document.getElementsByTagName("object")[8];
+ assert_equals(object1.id, "test6");
+ var object2 = document.getElementsByTagName("object")[9];
+ assert_equals(object2.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, [object1, object2]);
+}, "If there are two objects, a collection should be returned. (id and name)");
+
+test(function() {
+ var object = document.getElementsByTagName("object")[10];
+ assert_equals(object.id, "test7");
+
+ assert_true("test7" in document, '"test7" in document should be true');
+ assert_equals(document.test7, object);
+}, "A name shouldn't affect getting an object by id");
+
+test(function() {
+ var object = document.getElementsByTagName("object")[11];
+ assert_equals(object.name, "test8");
+
+ assert_true("test8" in document, '"test8" in document should be true');
+ assert_equals(document.test8, object);
+}, "An id shouldn't affect getting an object by name");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-08.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-08.html
new file mode 100644
index 0000000000..bb024d9e78
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-08.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Named items: duplicate id attributes for object and img</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/dom.html#dom-document-nameditem">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<div id="test">
+<div id=test2></div>
+<object id=test2></object>
+
+<div id=test3></div>
+<img id=test3 name=non-empty>
+</div>
+<script>
+test(function() {
+ var object = document.querySelector("object");
+ assert_equals(object.id, "test2");
+
+ assert_true("test2" in document);
+ assert_equals(document.test2, object);
+}, "If there is a div and object with same id, the object should be returned");
+
+test(function() {
+ var img = document.querySelector("img");
+ assert_equals(img.id, "test3");
+
+ assert_true("test3" in document);
+ assert_equals(document.test3, img);
+}, "If there is a div and img with same id, the img should be returned");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-names.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-names.html
new file mode 100644
index 0000000000..3f76d85a1b
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-names.html
@@ -0,0 +1,101 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Named items: supported property names</title>
+<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>
+<embed name="exposed_embed">
+ <embed name="not_exposed_embed">
+ </embed>
+</embed>
+<form name="form">
+</form>
+<iframe name="iframe">
+</iframe>
+<img name="img">
+<object name="exposed_object_with_name">
+ <object name="not_exposed_object_with_name">
+ </object>
+</object>
+<object id="exposed_object_with_id">
+ <object id="not_exposed_object_with_id">
+ </object>
+</object>
+<img name="img_with_id" id="img_id">
+<img id="img_with_just_id">
+<template id="template">
+ <img name="img_in_template">
+</template>
+<img name="42">
+<script>
+var names = Object.getOwnPropertyNames(document);
+
+test(function() {
+ assert_true(names.includes("exposed_embed"))
+}, "An embed name appears in a document's property names if the embed is exposed.");
+
+test(function() {
+ assert_false(names.includes("not_exposed_embed"))
+}, "An embed name does not appears in a document's property names if the embed is inside another embed.");
+
+test(function() {
+ assert_true(names.includes("form"))
+}, "A form name appears in a document's property names.");
+
+test(function() {
+ assert_true(names.includes("iframe"))
+}, "An iframe name appears in a document's property names.");
+
+test(function() {
+ assert_true(names.includes("img"))
+}, "An img name appears in a document's property names when the img has no id.");
+
+test(function() {
+ assert_true(names.includes("exposed_object"))
+}, "An object name appears in a document's property names if the object is exposed.");
+
+test(function() {
+ assert_true(names.includes("exposed_object_with_id"))
+}, "An object id appears in a document's property names if the object is exposed.");
+
+test(function() {
+ assert_false(names.includes("not_exposed_object_with_name"))
+}, "An object name does not appear in a document's property names if the object is inside another object.");
+
+test(function() {
+ assert_false(names.includes("not_exposed_object_with_id"))
+}, "An object id does not appear in a document's property names if the object is inside another object.");
+
+test(function() {
+ assert_true(names.includes("img_with_id"))
+}, "An img name appears in a document's property names when the img has an id.");
+
+test(function() {
+ assert_true(names.includes("img_id"))
+}, "An img id appears in a document's property names when the img has a name.");
+
+test(function() {
+ assert_false(names.includes("img_with_just_id"))
+}, "An img id does not appear in a document's property names when the img has no name.");
+
+test(function() {
+ assert_true(names.includes("42"))
+}, "A document's property names can include integer strings.");
+
+test(function() {
+ assert_false(names.includes("template"))
+}, "A template name does not appear in a document's property names.");
+
+test(function() {
+ assert_false(names.includes("img_in_template"))
+}, "An img name does not appear in a document's property names when the img is in a template's document fragment.");
+
+test(function() {
+ var form_index = names.indexOf("form");
+ assert_equals(names.indexOf("iframe"), form_index + 1);
+ assert_equals(names.indexOf("img"), form_index + 2);
+ assert_greater_than(names.indexOf("img_id"), names.indexOf("img"));
+ assert_greater_than(names.indexOf("42"), names.indexOf("img_id"));
+}, "A document's property names appear in tree order.");
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-01.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-01.html
new file mode 100644
index 0000000000..218a3fe843
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-01.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-02.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-02.html
new file mode 100644
index 0000000000..6da40d61ee
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-02.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-03.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-03.html
new file mode 100644
index 0000000000..3d55d6e835
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-03.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-04.xhtml b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-04.xhtml
new file mode 100644
index 0000000000..a71c1d9dd3
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-04.xhtml
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-05.xhtml b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-05.xhtml
new file mode 100644
index 0000000000..3fde06e5af
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-05.xhtml
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-06.xhtml b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-06.xhtml
new file mode 100644
index 0000000000..eb64dfb90e
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-compatmode-06.xhtml
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-cookie.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-cookie.html
new file mode 100644
index 0000000000..2af65effeb
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-cookie.html
@@ -0,0 +1,41 @@
+<!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>
+
+const TEST_CASES = [
+ {value: "", expected: "", test: "Empty value"},
+ {value: "a=b", expected: "a=b", test: "A simple cookie"},
+ {value: "b=A\0Z", expected: "", test: "A null char"},
+];
+
+test(function(){
+ assert_equals(document.cookie, "");
+}, "document has no cookie");
+
+for (const i in TEST_CASES) {
+ const t = TEST_CASES[i];
+ test(() => {
+ document.cookie = t.value;
+ assert_equals(document.cookie, t.expected);
+
+ // Cleanup
+ if (document.cookie.includes("=")) {
+ document.cookie = document.cookie.split("=")[0] + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
+ assert_equals(document.cookie, "");
+ }
+ }, t.name);
+}
+
+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>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified-01.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified-01.html
new file mode 100644
index 0000000000..81f67390d1
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified-01.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<title>document.lastModified should return current local time</title>
+<meta name="timeout" content="long">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support/document-lastModified-utils.js"></script>
+<div id="log"></div>
+<script>
+ var last_modified = document.lastModified;
+
+ test(function() {
+ assert_regexp_match(last_modified, DOCUMENT_LASTMODIFIED_REGEX,
+ "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\".");
+
+ test(function() {
+ assert_document_lastmodified_string_approximately_now(last_modified);
+ }, "Date returned by lastModified is current at page load");
+
+ var t = async_test("Date returned by lastModified is current after timeout.");
+ t.step_timeout(function() {
+ assert_document_lastmodified_string_approximately_now(document.lastModified);
+ t.done();
+ }, 4000);
+</script>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html
new file mode 100644
index 0000000000..9e0a07d8eb
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html.headers b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html.headers
new file mode 100644
index 0000000000..377e3b52dc
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified.html.headers
@@ -0,0 +1 @@
+Last-Modified: Thu, 01 Jan 1970 01:23:45 GMT
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-readyState.html b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-readyState.html
new file mode 100644
index 0000000000..8c91e0a001
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-readyState.html
@@ -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>
diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/support/document-lastModified-utils.js b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/support/document-lastModified-utils.js
new file mode 100644
index 0000000000..bbcde1894a
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/support/document-lastModified-utils.js
@@ -0,0 +1,78 @@
+const DOCUMENT_LASTMODIFIED_REGEX = /^([0-9]{2})\/([0-9]{2})\/([0-9]{4}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/;
+
+function assert_document_lastmodified_string_approximately_now(str) {
+ // We want to test that |str| was a time in the user's local
+ // timezone generated within a few seconds prior to the present.
+ // This requires some care, since it is possible that:
+ // - the few second difference may have crossed a
+ // year/month/day/hour/minute boundary
+ // - the few second difference may have crossed a change in the
+ // local timezone's UTC offset
+ // - the local time might be one that has multiple valid UTC
+ // representations (for example, because it's in the hour
+ // following a shift from summer time to winter time)
+ // We will make some assumptions to do this:
+ // - local time's UTC offset doesn't change more than once per
+ // minute
+ // - local time's UTC offset only changes by integral numbers of
+ // minutes
+
+ // The date must be equal to or earlier than the present time.
+ var dmax = new Date();
+
+ // The date must be equal to or later than 2.5 seconds ago.
+ var TOLERANCE_MILLISECONDS = 2500;
+ var dmin = new Date();
+ dmin.setTime(dmax.getTime() - TOLERANCE_MILLISECONDS);
+
+ // Extract the year/month/date/hours/minutes/seconds from str. It
+ // is important that we do *not* try to construct a Date object from
+ // these, since the core of the date object is a timestamp in UTC,
+ // and there are cases (such as the hour on each side of a change
+ // from summer time to winter time) where there are multiple
+ // possible UTC timestamps for a given YYYY-MM-DD HH:MM:SS, and
+ // constructing a Date object would pick one of them, which might be
+ // the wrong one. However, we already have the right one in dmin
+ // and dmax, so we should instead extract local time from those
+ // rather than converting these values to UTC.
+ var m = DOCUMENT_LASTMODIFIED_REGEX.exec(str);
+ var syear = Number(m[3]);
+ var smonth = Number(m[1]) - 1; // match Javascript 0-based months
+ var sdate = Number(m[2]);
+ var shours = Number(m[4]);
+ var sminutes = Number(m[5]);
+ var sseconds = Number(m[6]);
+
+ if (dmin.getFullYear() == dmax.getFullYear() &&
+ dmin.getMonth() == dmax.getMonth() &&
+ dmin.getDate() == dmax.getDate() &&
+ dmin.getHours() == dmax.getHours() &&
+ dmin.getMinutes() == dmax.getMinutes()) {
+ // min and max have the same minute
+ assert_equals(smonth, dmin.getMonth(), "month");
+ assert_equals(sdate, dmin.getDate(), "date");
+ assert_equals(syear, dmin.getFullYear(), "year");
+ assert_equals(shours, dmin.getHours(), "hours");
+ assert_equals(sminutes, dmin.getMinutes(), "minutes");
+ assert_true(dmin.getSeconds() <= sseconds &&
+ sseconds <= dmax.getSeconds(), "seconds");
+ } else if (dmin.getFullYear() == syear &&
+ dmin.getMonth() == smonth &&
+ dmin.getDate() == sdate &&
+ dmin.getHours() == shours &&
+ dmin.getMinutes() == sminutes) {
+ // actual value has the same minute as min
+ assert_true(dmin.getSeconds() <= sseconds, "dmin.getSeconds() <= sseconds");
+ assert_true(57 <= dmin.getSeconds(), "unexpected local time rules (dmin match)");
+ } else if (dmax.getFullYear() == syear &&
+ dmax.getMonth() == smonth &&
+ dmax.getDate() == sdate &&
+ dmax.getHours() == shours &&
+ dmax.getMinutes() == sminutes) {
+ // actual value has the same minute as max
+ assert_true(sseconds <= dmax.getSeconds(), "sseconds <= dmax.getSeconds()");
+ assert_true(dmax.getSeconds() <= 2, "unexpected local time rules (dmax match)");
+ } else {
+ assert_unreached("unexpected local time rules (no match)");
+ }
+}