| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script type="text/javascript" charset="utf-8"> | 3 <script type="text/javascript" charset="utf-8"> |
| 4 function log(msg) | 4 function log(msg) |
| 5 { | 5 { |
| 6 document.getElementById('console').appendChild(document.createTextNo
de(msg + '\n')); | 6 document.getElementById('console').appendChild(document.createTextNo
de(msg + '\n')); |
| 7 } | 7 } |
| 8 | 8 |
| 9 function test(element, name) | 9 function test(element, name) |
| 10 { | 10 { |
| 11 var didPass = true; | 11 var didPass = true; |
| 12 for (prop in element) { | 12 for (prop in element) { |
| 13 if (prop == "toString") | 13 if (prop == "toString") |
| 14 didPass = false; | 14 didPass = false; |
| 15 } | 15 } |
| 16 if (didPass) | 16 if (didPass) |
| 17 log("PASS: the toString function is not enumerable for " + name
+ "."); | 17 log("PASS: the toString function is not enumerable for " + name
+ "."); |
| 18 else | 18 else |
| 19 log("FAIL: the toString function is enumerable for " + name + "
and should not be."); | 19 log("FAIL: the toString function is enumerable for " + name + "
and should not be."); |
| 20 } | 20 } |
| 21 | 21 |
| 22 function runTests() | 22 function runTests() |
| 23 { | 23 { |
| 24 if (window.testRunner) | 24 if (window.testRunner) |
| 25 testRunner.dumpAsText(); | 25 testRunner.dumpAsText(); |
| 26 | 26 |
| 27 // DOM objects with custom toString() functions | 27 // DOM objects with custom toString() functions |
| 28 test(window.location, "Location"); | 28 test(window.location, "Location"); |
| 29 test(window.getSelection(), "Selection"); | |
| 30 | 29 |
| 31 // Other DOM objects | 30 // Other DOM objects |
| 32 test(document.createElement('div'), "HTMLDivElement"); | 31 test(document.createElement('div'), "HTMLDivElement"); |
| 33 test(document, "HTMLDocument"); | 32 test(document, "HTMLDocument"); |
| 34 | 33 |
| 35 // JS objects | 34 // JS objects |
| 36 test({}, "Object"); | 35 test({}, "Object"); |
| 37 test([], "Array"); | 36 test([], "Array"); |
| 38 } | 37 } |
| 39 </script> | 38 </script> |
| 40 </head> | 39 </head> |
| 41 <body onload="runTests();"> | 40 <body onload="runTests();"> |
| 42 <p>This tests that the toString() function does not enumerate.</p> | 41 <p>This tests that the toString() function does not enumerate.</p> |
| 43 <pre id="console"></pre> | 42 <pre id="console"></pre> |
| 44 </body> | 43 </body> |
| 45 </html> | 44 </html> |
| OLD | NEW |