aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-04-29 01:49:43 -0700
committerbors-servo <lbergstrom+bors@mozilla.com>2016-04-29 01:49:43 -0700
commit26be403e3c8351af638cce3a2a1ed4d3be8022df (patch)
tree4a4a05573c0633eef22a4078b5753d328597a017
parent78ae9a5da0f8f3dc67c2d0a76507a54bd08b9fba (diff)
parent10eff2f98b06394a5259699aa5c83c37282cd32c (diff)
downloadservo-26be403e3c8351af638cce3a2a1ed4d3be8022df.tar.gz
servo-26be403e3c8351af638cce3a2a1ed4d3be8022df.zip
Auto merge of #10915 - Ms2ger:document-body, r=nox
Consolidate tests for Document::body. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10915) <!-- Reviewable:end -->
-rw-r--r--tests/wpt/metadata/MANIFEST.json13
-rw-r--r--tests/wpt/mozilla/meta/MANIFEST.json6
-rw-r--r--tests/wpt/mozilla/tests/mozilla/document_body.html66
-rw-r--r--tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/Document.body.html (renamed from tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/document.body-getter.html)48
-rw-r--r--tests/wpt/web-platform-tests/html/dom/documents/dom-tree-accessors/document.body-setter-01.html31
5 files changed, 60 insertions, 104 deletions
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/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 @@
-<html>
- <head>
- <script src="/resources/testharness.js"></script>
- <script src="/resources/testharnessreport.js"></script>
- </head>
- <body>
- <script>
- test(function() {
- assert_not_equals(document.body, null, "test1-0, existing document's body");
- assert_true(document.body instanceof HTMLBodyElement, "test1-1, exising document's body: should be HTMLBodyElement");
- assert_equals(document.body && document.body.tagName, "BODY", "test1-2, existing document's body");
- }, "existing document's body");
-
- test(function() {
- var new_body = document.createElement("body");
- assert_not_equals(new_body, null, "test2-0, replace document's body with new body");
- document.body = new_body;
- assert_equals(new_body, document.body, "test2-1, replace document's body with new body");
- }, "replace document's body with new body");
-
- test(function() {
- var new_frameset = document.createElement("frameset");
- assert_not_equals(new_frameset, null, "test2-0, replace document's body with new frameset");
- document.body = new_frameset;
- assert_equals(new_frameset, document.body, "test2-1, replace document's body with new frameset");
- }, "replace document's body with new frameset");
-
- test(function() {
- var new_document = new Document();
- new_document.appendChild(new_document.createElement("html"));
- var new_div = new_document.createElement("div");
-
- assert_not_equals(new_div, null, "test4-0, append an invalid element to a new document");
-
- assert_throws(null, function() {
- new_document.body = new_div;
- });
- assert_equals(new_document.body, null, "test4-1, append an invalid element to a new document");
- }, "append an invalid element to a new document");
-
- test(function() {
- var new_document = document.implementation.createHTMLDocument();
- var new_body = new_document.createElement("body");
-
- assert_not_equals(new_body, null, "test5-0, append body to a new document");
- assert_true(new_body instanceof HTMLBodyElement, "test5-1, append body to a new document: should be HTMLBodyElement");
- assert_equals(new_body && new_body.tagName, "BODY", "test5-2, append body to a new document");
-
- new_document.body = new_body;
- assert_equals(new_document.body, new_body, "test5-3, append body to a new document");
- }, "append body to a new document");
-
- test(function() {
- var new_document = document.implementation.createHTMLDocument();
- var new_frameset = new_document.createElement("frameset");
-
- assert_not_equals(new_frameset, null, "test6-0, append frameset to a new document");
- assert_true(new_frameset instanceof HTMLFrameSetElement, "test6-1, append frameset to a new document: should be HTMLFrameSetElement");
- assert_equals(new_frameset && new_frameset.tagName, "FRAMESET", "test6-2, append frameset to a new document");
-
- new_document.body = new_frameset;
- assert_equals(new_document.body, new_frameset, "test6-3, append frameset to a new document");
- }, "append frameset to a new document");
- </script>
- </body>
-</html>
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
index 90ca7e59a03..07f1edf939c 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,52 @@ test(function() {
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/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 @@
-<!DOCTYPE html>
-<title>Setting document.body to incorrect values</title>
-<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
-<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-body">
-<link rel="help" href="https://heycam.github.io/webidl/#es-interface">
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<script>
-var originalBody = document.body;
-test(function() {
- assert_throws(new TypeError(), function() {
- document.body = "text"
- })
-}, "Should throw a TypeError when trying to set document.body to a string.")
-test(function() {
- assert_throws("HierarchyRequestError", function() {
- document.body = document.createElement("div")
- })
-}, "Should throw a HierarchyRequestError when trying to set document.body to a div element.")
-test(function() {
- var doc = document.implementation.createHTMLDocument("")
- doc.removeChild(doc.documentElement)
- assert_throws("HierarchyRequestError", function() {
- doc.body = document.createElement("body")
- })
-}, "Should throw a HierarchyRequestError when trying to set document.body when there's no root element.")
-test(function() {
- assert_equals(document.body, originalBody);
-}, "document.body has not changed")
-</script>