Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Fix the insertAdjacentHTML tests for parentless nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Sep 18, 2011
1 parent 2f45adc commit fe3f603
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions tests/insert_adjacent_html.html
Expand Up @@ -57,15 +57,16 @@
var child = document.createElement("div");

test (function() {
assert_throws("NO_MODIFICATION_ALLOWED_ERR", function() {child.insertAdjacentHTML("Beforebegin", "foo")});
assert_throws("NO_MODIFICATION_ALLOWED_ERR", function() {child.insertAdjacentHTML("AfterEnd", "foo")})
});
child.insertAdjacentHTML("Beforebegin", "foo");
child.insertAdjacentHTML("AfterEnd", "foo");
assert_false(child.hasChildNodes());
}, "When the parent node is null, insertAdjacentHTML should do nothing for beforebegin and afterend");


test(function() {
child.insertAdjacentHTML("afterBegin", "foo"); // mustn't throw
child.insertAdjacentHTML("beforeend", "foo"); // mustn't throw

child.insertAdjacentHTML("afterBegin", "foo");
child.insertAdjacentHTML("beforeend", "bar");
assert_equals(child.textContent, "foobar");
parent.appendChild(child);
});

Expand Down
13 changes: 7 additions & 6 deletions tests/insert_adjacent_html.xhtml
Expand Up @@ -56,15 +56,16 @@ var parent = document.createElement("div");
var child = document.createElement("div");

test (function() {
assert_throws("NO_MODIFICATION_ALLOWED_ERR", function() {child.insertAdjacentHTML("Beforebegin", "foo")});
assert_throws("NO_MODIFICATION_ALLOWED_ERR", function() {child.insertAdjacentHTML("AfterEnd", "foo")})
});
child.insertAdjacentHTML("Beforebegin", "foo");
child.insertAdjacentHTML("AfterEnd", "foo");
assert_false(child.hasChildNodes());
}, "When the parent node is null, insertAdjacentHTML should do nothing for beforebegin and afterend");


test(function() {
child.insertAdjacentHTML("afterBegin", "foo"); // mustn't throw
child.insertAdjacentHTML("beforeend", "foo"); // mustn't throw

child.insertAdjacentHTML("afterBegin", "foo");
child.insertAdjacentHTML("beforeend", "bar");
assert_equals(child.textContent, "foobar");
parent.appendChild(child);
});

Expand Down

0 comments on commit fe3f603

Please sign in to comment.