test_document_scripts.html (1591B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=685774 5 --> 6 <head> 7 <title>Test for document.scripts (Bug 685774)</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=685774">Mozilla Bug 685774</a> 14 <script type="application/javascript"> 15 16 /** Test for Bug 685774 */ 17 18 function testSameCollection(a, b, c) { 19 is(a.length, c, "unexpected count of script elements"); 20 is(b.length, c, "unexpected count of script elements"); 21 for (var i = 0; i < a.length; i++) { 22 is(a[i], b[i], "document.scripts is not supported"); 23 } 24 } 25 26 SimpleTest.waitForExplicitFinish(); 27 28 testSameCollection(document.scripts, document.getElementsByTagName("script"), 3); 29 30 </script> 31 <script type="application/javascript"> 32 33 testSameCollection(document.scripts, document.getElementsByTagName("script"), 4); 34 35 function start() { 36 testSameCollection(document.scripts, document.getElementsByTagName("script"), 5); 37 38 var e = document.createElement("script"); 39 testSameCollection(document.scripts, document.getElementsByTagName("script"), 5); 40 document.body.appendChild(e); 41 testSameCollection(document.scripts, document.getElementsByTagName("script"), 6); 42 43 SimpleTest.finish(); 44 } 45 46 addLoadEvent(start); 47 48 </script> 49 <script type="application/javascript"> 50 51 testSameCollection(document.scripts, document.getElementsByTagName("script"), 5); 52 53 </script> 54 </body> 55 </html>