From cfe2c6b5049aec01274011a5f848bff1d09307a8 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 29 Apr 2016 09:56:38 +0200 Subject: [PATCH 1/2] Merge existing wpt Document::body tests. --- tests/wpt/metadata/MANIFEST.json | 13 +++++++- ...nt.body-getter.html => Document.body.html} | 22 +++++++++++++ .../document.body-setter-01.html | 31 ------------------- 3 files changed, 34 insertions(+), 32 deletions(-) rename tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/{document.body-getter.html => Document.body.html} (87%) delete mode 100644 tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/document.body-setter-01.html diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index eba0da0ecf0..4fbeada837c 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -35238,7 +35238,10 @@ "wdspec": [] }, "local_changes": { - "deleted": [], + "deleted": [ + "html/dom/documents/dom-tree-accessors/document.body-getter.html", + "html/dom/documents/dom-tree-accessors/document.body-setter-01.html" + ], "deleted_reftests": {}, "items": { "reftest": { @@ -35254,6 +35257,14 @@ "url": "/html/rendering/replaced-elements/embedded-content-rendering-rules/canvas_without_context_a.html" } ] + }, + "testharness": { + "html/dom/documents/dom-tree-accessors/Document.body.html": [ + { + "path": "html/dom/documents/dom-tree-accessors/Document.body.html", + "url": "/html/dom/documents/dom-tree-accessors/Document.body.html" + } + ] } }, "reftest_nodes": { diff --git a/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/document.body-getter.html b/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/Document.body.html similarity index 87% rename from tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/document.body-getter.html rename to tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/Document.body.html index 90ca7e59a03..150ab50bee1 100644 --- a/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/document.body-getter.html +++ b/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/Document.body.html @@ -118,4 +118,26 @@ test(function() { doc.appendChild(doc.createElementNS("http://example.org/test", "frameset")); assert_equals(doc.body, null); }, "Non-HTML frameset as the root node"); + + +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.") diff --git a/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/document.body-setter-01.html b/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/document.body-setter-01.html deleted file mode 100644 index f3a1638116c..00000000000 --- a/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/document.body-setter-01.html +++ /dev/null @@ -1,31 +0,0 @@ - -Setting document.body to incorrect values - - - - - -
- From 10eff2f98b06394a5259699aa5c83c37282cd32c Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 29 Apr 2016 10:32:43 +0200 Subject: [PATCH 2/2] Submit legacy Document::body tests to wpt. --- tests/wpt/mozilla/meta/MANIFEST.json | 6 -- .../mozilla/tests/mozilla/document_body.html | 66 ------------------- .../dom-tree-accessors/Document.body.html | 26 ++++++++ 3 files changed, 26 insertions(+), 72 deletions(-) delete mode 100644 tests/wpt/mozilla/tests/mozilla/document_body.html diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 3091ab85f53..bc31d8c61a5 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6088,12 +6088,6 @@ "url": "/_mozilla/mozilla/document_activeElement.html" } ], - "mozilla/document_body.html": [ - { - "path": "mozilla/document_body.html", - "url": "/_mozilla/mozilla/document_body.html" - } - ], "mozilla/document_characterSet.html": [ { "path": "mozilla/document_characterSet.html", diff --git a/tests/wpt/mozilla/tests/mozilla/document_body.html b/tests/wpt/mozilla/tests/mozilla/document_body.html deleted file mode 100644 index c77da6cda15..00000000000 --- a/tests/wpt/mozilla/tests/mozilla/document_body.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - diff --git a/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/Document.body.html b/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/Document.body.html index 150ab50bee1..07f1edf939c 100644 --- a/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/Document.body.html +++ b/tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/Document.body.html @@ -119,6 +119,12 @@ test(function() { 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() { @@ -140,4 +146,24 @@ test(function() { }) 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.");