OLD | NEW |
| (Empty) |
1 <!doctype html> | |
2 <meta charset=utf-8> | |
3 <title></title> | |
4 <script src=../../../../resources/testharness.js></script> | |
5 <script src=../../../../resources/testharnessreport.js></script> | |
6 <body style="visibility:hidden"> | |
7 <div id="target"></div> | |
8 <div id="parent"><span id=target2></span></div> | |
9 <div id="log" style="visibility:visible"></div> | |
10 </body> | |
11 <script> | |
12 var target = document.getElementById("target"); | |
13 var target2 = document.getElementById("target2"); | |
14 | |
15 test(function() { | |
16 assert_throws("SyntaxError", function() { | |
17 target.insertAdjacentText("test", "text") | |
18 }); | |
19 | |
20 assert_throws("SyntaxError", function() { | |
21 target2.insertAdjacentText("test", "test") | |
22 }); | |
23 }, "Inserting to an invalid location should cause a Syntax Error exception") | |
24 | |
25 test(function() { | |
26 target.insertAdjacentText("beforebegin", "test1"); | |
27 assert_equals(target.previousSibling.nodeValue, "test1"); | |
28 | |
29 target2.insertAdjacentText("beforebegin", "test1"); | |
30 assert_equals(target2.previousSibling.nodeValue, "test1"); | |
31 }, "Inserted text node should be target element's previous sibling for 'beforebe
gin' case") | |
32 | |
33 test(function() { | |
34 target.insertAdjacentText("afterbegin", "test2"); | |
35 assert_equals(target.firstChild.nodeValue, "test2"); | |
36 | |
37 target2.insertAdjacentText("afterbegin", "test2"); | |
38 assert_equals(target2.firstChild.nodeValue, "test2"); | |
39 }, "Inserted text node should be target element's first child for 'afterbegin' c
ase") | |
40 | |
41 test(function() { | |
42 target.insertAdjacentText("beforeend", "test3"); | |
43 assert_equals(target.lastChild.nodeValue, "test3"); | |
44 | |
45 target2.insertAdjacentText("beforeend", "test3"); | |
46 assert_equals(target2.lastChild.nodeValue, "test3"); | |
47 }, "Inserted text node should be target element's last child for 'beforeend' cas
e") | |
48 | |
49 test(function() { | |
50 target.insertAdjacentText("afterend", "test4"); | |
51 assert_equals(target.nextSibling.nodeValue, "test4"); | |
52 | |
53 target2.insertAdjacentText("afterend", "test4"); | |
54 assert_equals(target.nextSibling.nodeValue, "test4"); | |
55 }, "Inserted text node should be target element's next sibling for 'afterend' ca
se") | |
56 | |
57 test(function() { | |
58 var docElement = document.documentElement; | |
59 docElement.style.visibility="hidden"; | |
60 | |
61 assert_throws("HierarchyRequestError", function() { | |
62 docElement.insertAdjacentText("beforebegin", "text1") | |
63 }); | |
64 | |
65 docElement.insertAdjacentText("afterbegin", "test2"); | |
66 assert_equals(docElement.firstChild.nodeValue, "test2"); | |
67 | |
68 docElement.insertAdjacentText("beforeend", "test3"); | |
69 assert_equals(docElement.lastChild.nodeValue, "test3"); | |
70 | |
71 assert_throws("HierarchyRequestError", function() { | |
72 docElement.insertAdjacentText("afterend", "test4") | |
73 }); | |
74 }, "Adding more than one child to document should cause a HierarchyRequestError
exception") | |
75 | |
76 </script> | |
OLD | NEW |