diff options
Diffstat (limited to 'testing/web-platform/tests/html/dom/documents')
57 files changed, 2275 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/dom/documents/.gitkeep b/testing/web-platform/tests/html/dom/documents/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/.gitkeep diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/.gitkeep b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/.gitkeep 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 000000000..07f1edf93 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html @@ -0,0 +1,169 @@ +<!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(new TypeError(), function() { + document.body = "text" + }) + assert_equals(document.body, originalBody); +}, "Setting document.body to a string.") +test(function() { + assert_throws("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("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."); +</script> diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.currentScript.sub.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.currentScript.sub.html new file mode 100644 index 000000000..76f1b64de --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.currentScript.sub.html @@ -0,0 +1,211 @@ +<!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-exec" : ["script-exec-before-after","script-exec-before-after"], + "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" : [] +}; + +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> 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 000000000..dc132e5ec --- /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 000000000..b4d924164 --- /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 000000000..32effe3c4 --- /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 000000000..b4fe36d24 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.embeds-document.plugins-01.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<title>document.embeds and document.plugins</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-embeds"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-plugins"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + assert_equals(document.embeds, document.embeds, + "embeds should be constant"); + assert_equals(document.plugins, document.plugins, + "plugins should be constant"); + assert_equals(document.embeds, document.plugins, + "embeds should be the same as plugins"); + assert_equals(document.embeds.length, 0); + assert_equals(document.plugins.length, 0); +}, "No plugins"); + +test(function() { + var embed = document.body.appendChild(document.createElement("embed")); + this.add_cleanup(function() { document.body.removeChild(embed) }); + + assert_array_equals(document.embeds, [embed]); + assert_array_equals(document.plugins, [embed]); + + assert_equals(document.embeds, document.embeds, + "embeds should be constant"); + assert_equals(document.plugins, document.plugins, + "plugins should be constant"); + assert_equals(document.embeds, document.plugins, + "embeds should be the same as plugins"); +}, "One plugin"); + +test(function() { + var embed1 = document.createElement("embed"), + embed2 = document.createElement("embed"); + + document.body.appendChild(embed2); + this.add_cleanup(function() { document.body.removeChild(embed2) }); + document.body.insertBefore(embed1, embed2); + this.add_cleanup(function() { document.body.removeChild(embed1) }); + + assert_array_equals(document.embeds, [embed1, embed2]); + assert_array_equals(document.plugins, [embed1, embed2]); + + assert_equals(document.embeds, document.embeds, + "embeds should be constant"); + assert_equals(document.plugins, document.plugins, + "plugins should be constant"); + assert_equals(document.embeds, document.plugins, + "embeds should be the same as plugins"); +}, "Two plugins"); +</script> 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 000000000..e0689c7c7 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.forms.html @@ -0,0 +1,70 @@ +<!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); + } + // http://heycam.github.io/webidl/#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") +</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 000000000..a91c838d8 --- /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 000000000..f15edb6f1 --- /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 000000000..9a82e6805 --- /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 000000000..51b9e22f8 --- /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 000000000..099215d3a --- /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 000000000..97646e39c --- /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-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 000000000..e09ece7b1 --- /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 000000000..63b626042 --- /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 000000000..c2dc99a55 --- /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 000000000..2ab42b973 --- /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 000000000..9e79c84da --- /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://heycam.github.io/webidl/#es-DOMString"/> +<link rel="help" href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf#page=57"/> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id="log"></div> +<script> +test(function() { + var n = document.createElement("div"); + n.setAttribute("name", "null"); + + document.body.appendChild(n); + this.add_cleanup(function() { document.body.removeChild(n) }); + + assert_equals(document.getElementsByName(null)[0], n); +}, "getElementsByName(null)"); + +test(function() { + var u = document.createElement("div"); + u.setAttribute("name", "undefined"); + + document.body.appendChild(u); + this.add_cleanup(function() { document.body.removeChild(u) }); + + assert_equals(document.getElementsByName(undefined)[0], u); +}, "getElementsByName(undefined)"); +</script> +</body> +</html> 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 000000000..72734aeda --- /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://heycam.github.io/webidl/#es-DOMString"> +<link rel="help" href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf#page=57"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + var n = document.createElement("div"); + n.setAttribute("name", "null"); + + document.body.appendChild(n); + this.add_cleanup(function() { document.body.removeChild(n) }); + + assert_equals(document.getElementsByName(null)[0], n); +}, "getElementsByName(null)"); + +test(function() { + var u = document.createElement("div"); + u.setAttribute("name", "undefined"); + + document.body.appendChild(u); + this.add_cleanup(function() { document.body.removeChild(u) }); + + assert_equals(document.getElementsByName(undefined)[0], u); +}, "getElementsByName(undefined)"); +</script> 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 000000000..e57e9d5c0 --- /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 000000000..aa1bb01bf --- /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 000000000..f122857a2 --- /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 000000000..f919d79a3 --- /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 000000000..d0189574e --- /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 000000000..558fdebc3 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/document.images.html @@ -0,0 +1,105 @@ +<!doctype html> +<meta charset=utf-8> +<title>Document.images</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id=log></div> +<div id=test> +<img> +<img id=x><img name=y><img id=z1 name=z2> +<img id=a><img id=a> +<img name=b><img name=b> +<img id=><img name=> +<input type=image name=input> +</div> +<script> +function assert_all(aAssertFunc, aCollection) { + for (var i = 0; i < aCollection.length; ++i) { + aAssertFunc(aCollection[i]); + } +} + +var XHTML = "http://www.w3.org/1999/xhtml"; +var div, images, c; + +setup(function() { + div = document.getElementById("test"); + var foreign = + div.appendChild(document.createElementNS("http://example.org", "img")); + foreign.setAttribute("id", "f"); + + images = [].slice.call(div.getElementsByTagNameNS(XHTML, "img")); + + c = document.images; +}); + +test(function() { + assert_equals(c.length, 10); + assert_array_equals(c, images); + + assert_all(function (aElement) { + assert_equals(aElement.namespaceURI, XHTML); + }, c); +}, "document.images should contain all HTML img elements"); + +test(function() { + assert_equals(c.x, images[1]); + assert_equals(c.namedItem("x"), images[1]); + assert_true("x" in c, '"x" in c'); +}, "img with id"); + +test(function() { + assert_equals(c.y, images[2]); + assert_equals(c.namedItem("y"), images[2]); + assert_true("y" in c, '"y" in c'); +}, "img with name"); + +test(function() { + assert_equals(c.z1, images[3]); + assert_equals(c.namedItem("z1"), images[3]); + assert_true("z1" in c, '"z1" in c'); + assert_equals(c.z2, images[3]); + assert_equals(c.namedItem("z2"), images[3]); + assert_true("z2" in c, '"z2" in c'); +}, "img with id and name"); + +test(function() { + assert_equals(c.a, images[4]); + assert_equals(c.namedItem("a"), images[4]); + assert_true("a" in c, '"a" in c'); +}, "Two img elements with the same id"); + +test(function() { + assert_equals(c.b, images[6]); + assert_equals(c.namedItem("b"), images[6]); + assert_true("b" in c, '"b" in c'); +}, "Two img elements with the same name"); + +test(function() { + assert_equals(c.c, undefined); + assert_equals(c.namedItem("c"), null); + assert_false("c" in c, '"c" in c'); +}, "Unknown name should not be in the collection"); + +test(function() { + assert_equals(c.f, undefined); + assert_equals(c.namedItem("f"), null); + assert_false("f" in c, '"f" in c'); +}, "Foreign element should not be in the collection"); + +test(function() { + assert_equals(c.input, undefined); + assert_equals(c.namedItem("input"), null); + assert_false("input" in c, '"input" in c'); + var input = div.getElementsByTagName("input")[0]; + assert_all(function (aElement) { + assert_not_equals(aElement.namespaceURI, input); + }, c); +}, "Input elements should not be in the collection"); + +test(function() { + assert_equals(c[""], undefined); + assert_equals(c.namedItem(""), null); + assert_false("" in c, '"" in c'); +}, "The empty string should not be in the collections"); +</script> 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 000000000..05ddab9ca --- /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 000000000..917b8787d --- /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 000000000..952c29db5 --- /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 000000000..fbe891650 --- /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 000000000..df6ffc30f --- /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 000000000..a80723f23 --- /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 000000000..9723d3f81 --- /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 000000000..a643b75f4 --- /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 000000000..a3273f626 --- /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/nameditem-01.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-01.html new file mode 100644 index 000000000..2b428aa65 --- /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 & 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 000000000..8c3155e7e --- /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 000000000..4c330b6a3 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/nameditem-03.html @@ -0,0 +1,110 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Named items: applets</title> +<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-nameditem"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<div id="test"> +<applet name=test1></applet> + +<applet name=test2></applet> +<applet name=test2></applet> + +<applet id=test3></applet> + +<applet id=test4></applet> +<applet id=test4></applet> + +<applet name=test5></applet> +<applet id=test5></applet> + +<applet id=test6></applet> +<applet name=test6></applet> + +<applet id=test7 name=fail></applet> + +<applet name=test8 id=fail></applet> +</div> +<script> +test(function() { + var applet = document.getElementsByTagName("applet")[0]; + assert_equals(applet.name, "test1"); + + assert_true("test1" in document, '"test1" in document should be true'); + assert_equals(document.test1, applet); +}, "If there is one applet, it should be returned (name)"); + +test(function() { + var applet1 = document.getElementsByTagName("applet")[1]; + assert_equals(applet1.name, "test2"); + var applet2 = document.getElementsByTagName("applet")[2]; + assert_equals(applet2.name, "test2"); + + assert_true("test2" in document, '"test2" in document should be true'); + var collection = document.test2; + assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection"); + assert_array_equals(collection, [applet1, applet2]); +}, "If there are two applets, a collection should be returned. (name)"); + +test(function() { + var applet = document.getElementsByTagName("applet")[3]; + assert_equals(applet.id, "test3"); + + assert_true("test3" in document, '"test3" in document should be true'); + assert_equals(document.test3, applet); +}, "If there is one applet, it should be returned (id)"); + +test(function() { + var applet1 = document.getElementsByTagName("applet")[4]; + assert_equals(applet1.id, "test4"); + var applet2 = document.getElementsByTagName("applet")[5]; + assert_equals(applet2.id, "test4"); + + assert_true("test4" in document, '"test4" in document should be true'); + var collection = document.test4; + assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection"); + assert_array_equals(collection, [applet1, applet2]); +}, "If there are two applets, a collection should be returned. (id)"); + +test(function() { + var applet1 = document.getElementsByTagName("applet")[6]; + assert_equals(applet1.name, "test5"); + var applet2 = document.getElementsByTagName("applet")[7]; + assert_equals(applet2.id, "test5"); + + assert_true("test5" in document, '"test5" in document should be true'); + var collection = document.test5; + assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection"); + assert_array_equals(collection, [applet1, applet2]); +}, "If there are two applets, a collection should be returned. (name and id)"); + +test(function() { + var applet1 = document.getElementsByTagName("applet")[8]; + assert_equals(applet1.id, "test6"); + var applet2 = document.getElementsByTagName("applet")[9]; + assert_equals(applet2.name, "test6"); + + assert_true("test6" in document, '"test6" in document should be true'); + var collection = document.test6; + assert_class_string(collection, "HTMLCollection", "collection should be an HTMLCollection"); + assert_array_equals(collection, [applet1, applet2]); +}, "If there are two applets, a collection should be returned. (id and name)"); + +test(function() { + var applet = document.getElementsByTagName("applet")[10]; + assert_equals(applet.id, "test7"); + + assert_true("test7" in document, '"test7" in document should be true'); + assert_equals(document.test7, applet); +}, "A name shouldn't affect getting an applet by id"); + +test(function() { + var applet = document.getElementsByTagName("applet")[11]; + assert_equals(applet.name, "test8"); + + assert_true("test8" in document, '"test8" in document should be true'); + assert_equals(document.test8, applet); +}, "An id shouldn't affect getting an applet by name"); +</script> 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 000000000..b7c3ef8e9 --- /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 000000000..843ce3579 --- /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 000000000..15a72b5f6 --- /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/loading-xml-documents/.gitkeep b/testing/web-platform/tests/html/dom/documents/loading-xml-documents/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/loading-xml-documents/.gitkeep diff --git a/testing/web-platform/tests/html/dom/documents/resource-metadata-management/.gitkeep b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/.gitkeep 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 000000000..218a3fe84 --- /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 000000000..6da40d61e --- /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 000000000..3d55d6e83 --- /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 000000000..a71c1d9dd --- /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 000000000..3fde06e5a --- /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 000000000..eb64dfb90 --- /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 000000000..802e2d5ad --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-cookie.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>document.cookie</title> +<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> +<link rel=help href="https://html.spec.whatwg.org/multipage/#resource-metadata-management"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function(){ + assert_equals(document.cookie, ""); +}, "document has no cookie"); + +test(function(){ + var doc = document.implementation.createHTMLDocument("doc"); + assert_equals(doc.cookie, ""); + doc.cookie = "test=foobar"; + assert_equals(doc.cookie, ""); +}, "getting cookie for a cookie-averse document returns empty string, setting does nothing"); +</script> 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 000000000..e67c04fc8 --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/resource-metadata-management/document-lastModified-01.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<title>document.lastModified should return current local time</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + var d = new Date(); + var last_modified = document.lastModified; + var initial_modified = Date.parse(last_modified) / 1000; + var expected = Math.round(d / 1000); + + test(function() { + assert_approx_equals(initial_modified, expected, 2.5); + }, "Date returned by lastModified is current at page load"); + + var pattern = /[0-9]{2}\/[0-9]{2}\/[0-9]{4} ([0-9]{2}):([0-9]{2}):([0-9]{2})/ + + test(function() { + assert_regexp_match(last_modified, pattern, + "Format should match the pattern \"NN/NN/NNNN NN:NN:NN\"."); + }, "Date returned by lastModified is in the form \"MM/DD/YYYY hh:mm:ss\"."); + + + var hours = d.getHours() + var minutes = d.getMinutes() + var seconds = d.getSeconds() + + // Checking whether d and and new instance of Date have the same timezone. + // Do not run the time zone test in the case daylight saving occurs. + var d2 = new Date(); + if (d2.getTimezoneOffset() == d.getTimezoneOffset()) { + test(function() { + var local_time = hours * 60 * 60 + minutes * 60 + seconds; + var m = pattern.exec(last_modified); + var last_modified_time = parseInt(m[1]) * 60 * 60 + parseInt(m[2]) * 60 + parseInt(m[3]); + assert_approx_equals(last_modified_time, local_time, 2, + "Hours and minutes should match local time."); + }, "Date returned by lastModified is in the user's local time zone."); + } + var t = async_test("Date returned by lastModified is current after timeout."); + + setTimeout(function() { + t.step(function() { + var new_modified = Date.parse(document.lastModified) / 1000; + var new_expected = Math.round(new Date() / 1000); + assert_approx_equals(new_modified, new_expected, 2.5, + "(initial value was " + initial_modified + ")"); + t.done(); + }); + }, 4000); +</script> 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 000000000..9e0a07d8e --- /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 000000000..377e3b52d --- /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 000000000..8c91e0a00 --- /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/security-document/.gitkeep b/testing/web-platform/tests/html/dom/documents/security-document/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/security-document/.gitkeep diff --git a/testing/web-platform/tests/html/dom/documents/the-document-object/.gitkeep b/testing/web-platform/tests/html/dom/documents/the-document-object/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/dom/documents/the-document-object/.gitkeep |