summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-01 15:08:37 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:07 -0500
commitce285b6f2d48ce945b194fd7982cd6a5a306e939 (patch)
treec772c2ce051f12afd4c1879d0c7b1dbc0db282c4 /testing
parent32f3f8826f396fd17c1c77770d073d0abf15c904 (diff)
downloadUXP-ce285b6f2d48ce945b194fd7982cd6a5a306e939.tar
UXP-ce285b6f2d48ce945b194fd7982cd6a5a306e939.tar.gz
UXP-ce285b6f2d48ce945b194fd7982cd6a5a306e939.tar.lz
UXP-ce285b6f2d48ce945b194fd7982cd6a5a306e939.tar.xz
UXP-ce285b6f2d48ce945b194fd7982cd6a5a306e939.zip
Bug 1276438 part 3. Align the .body setter with the spec a bit better.
There are two changes here: 1) We allow setting .body even if the root element is not an <html:html>. This is what the spec says to do, and what we used to do before the changes in bug 366200. No tests for this yet, pending https://github.com/whatwg/html/issues/3403 getting resolved. 2) We use GetBody(), not GetBodyElement(), to look for an existing thing to replace. This matters if there are <frameset>s involved. Tag UXP Issue #1344 Tag UXP Issue #252
Diffstat (limited to 'testing')
-rw-r--r--testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html50
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html
index 07f1edf93..7d8548885 100644
--- 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
@@ -166,4 +166,54 @@ test(function() {
doc.body = new_frameset;
assert_equals(doc.body, new_frameset, "test6-3, append frameset to a new document");
}, "Setting document.body to a new frameset element.");
+
+test(function() {
+ var doc = createDocument();
+ var html = doc.appendChild(doc.createElement("html"));
+ var f =
+ html.appendChild(doc.createElement("frameset"));
+ assert_equals(doc.body, f);
+
+ var b = doc.createElement("body");
+ doc.body = b;
+
+ assert_equals(f.parentNode, null,
+ "Frameset should have been removed from the tree");
+ assert_equals(doc.body, b, "Body should be the new doc.body");
+}, "Setting document.body to a body will replace an existing frameset if there is one.");
+
+test(function() {
+ var doc = createDocument();
+ var html = doc.appendChild(doc.createElement("html"));
+ var b =
+ html.appendChild(doc.createElement("body"));
+ assert_equals(doc.body, b);
+
+ var f = doc.createElement("frameset");
+ doc.body = f;
+
+ assert_equals(b.parentNode, null,
+ "Body should have been removed from the tree");
+ assert_equals(doc.body, f, "Frameset should be the new doc.body");
+}, "Setting document.body to a frameset will replace an existing body if there is one.");
+
+test(function() {
+ var doc = createDocument();
+ var html = doc.appendChild(doc.createElement("html"));
+ var b =
+ html.appendChild(doc.createElement("body"));
+ var f1 = html.appendChild(doc.createElement("frameset"));
+ assert_equals(doc.body, b);
+
+ var f2 = doc.createElement("frameset");
+ doc.body = f2;
+
+ assert_equals(b.parentNode, null,
+ "Body should have been removed from the tree");
+ assert_equals(f1.parentNode, html,
+ "Frameset following body should still be in the tree.");
+ assert_equals(doc.body, f2, "New frameset should be the new doc.body");
+ assert_equals(f2.nextSibling, f1, "New frameset should have replaced the body");
+}, "Setting document.body to a frameset will replace the first existing body/frameset.");
+
</script>