OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <title>Fragment Mutation Tests</title> | 3 <title>Fragment Mutation Tests</title> |
4 <script> | 4 <script> |
5 | 5 |
6 if (window.testRunner) | 6 if (window.testRunner) |
7 testRunner.dumpAsText(); | 7 testRunner.dumpAsText(); |
8 | 8 |
9 var log = []; | 9 var log = []; |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 { | 29 { |
30 var node = nodes.firstChild; | 30 var node = nodes.firstChild; |
31 var result = ""; | 31 var result = ""; |
32 while(node) { | 32 while(node) { |
33 result += node.nodeName; | 33 result += node.nodeName; |
34 node = node.nextSibling; | 34 node = node.nextSibling; |
35 } | 35 } |
36 return result; | 36 return result; |
37 } | 37 } |
38 | 38 |
39 function expectException(code) | 39 function expectException(error) |
40 { | 40 { |
41 return function(stash, exception) { | 41 return function(stash, exception) { |
42 if (!exception) | 42 if (!exception) |
43 return "FAIL, expected exception with code " + code + ". The resulti
ng fragment was: \"" + produceNodeNameString(stash) + "\"."; | 43 return "FAIL, expected exception with code " + code + ". The resulti
ng fragment was: \"" + produceNodeNameString(stash) + "\"."; |
44 | 44 |
45 if (code == exception.code) | 45 if (exception instanceof error) |
46 return "PASS"; | 46 return "PASS"; |
47 return "FAIL, expected exception code: " + code + ", was: " + exception
+ "."; | 47 return "FAIL, expected exception code: " + code + ", was: " + exception
+ "."; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 function expectNodes(nodes) | 51 function expectNodes(nodes) |
52 { | 52 { |
53 return function(stash, exception) { | 53 return function(stash, exception) { |
54 if (exception) | 54 if (exception) |
55 return "FAIL, unexpected exception thrown: " + exception; | 55 return "FAIL, unexpected exception thrown: " + exception; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 var extra = document.body.appendChild(document.createElement("em")); | 116 var extra = document.body.appendChild(document.createElement("em")); |
117 testFragment(method, "Appending an element at the end of the fragment should
not affect the result", function(evt, frag) | 117 testFragment(method, "Appending an element at the end of the fragment should
not affect the result", function(evt, frag) |
118 { | 118 { |
119 frag.appendChild(extra); | 119 frag.appendChild(extra); |
120 }, expectNodes("BUP")); | 120 }, expectNodes("BUP")); |
121 | 121 |
122 testFragment(method, "Continually re-appending removed element to the fragme
nt should eventually throw NOT_FOUND_ERR", function(evt, frag, stash) | 122 testFragment(method, "Continually re-appending removed element to the fragme
nt should eventually throw NOT_FOUND_ERR", function(evt, frag, stash) |
123 { | 123 { |
124 stash.insertBefore(frag.lastChild, stash.firstChild); | 124 stash.insertBefore(frag.lastChild, stash.firstChild); |
125 }, expectException(8), true); | 125 }, expectException(TypeError), true); |
126 printLog(methodName); | 126 printLog(methodName); |
127 } | 127 } |
128 function runTests() | 128 function runTests() |
129 { | 129 { |
130 runTest("appendChild", appendChildMethod); | 130 runTest("appendChild", appendChildMethod); |
131 runTest("insertBefore", insertBeforeMethod); | 131 runTest("insertBefore", insertBeforeMethod); |
132 } | 132 } |
133 | 133 |
134 </script> | 134 </script> |
135 </head> | 135 </head> |
136 <body onload="runTests()"> | 136 <body onload="runTests()"> |
137 </body> | 137 </body> |
138 </html> | 138 </html> |
OLD | NEW |