test_window_element_enumeration.html (2427B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=959992 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 959992</title> 9 <script src="/tests/SimpleTest/SimpleTest.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=959992">Mozilla Bug 959992</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 <img id="one" name="two"> 17 <div id="three" name="four"></div> 18 <div id=""></div> 19 <img name=""> 20 </div> 21 <pre id="test"> 22 <script type="application/javascript"> 23 24 /** Test for Bug 959992 */ 25 var names1 = Object.getOwnPropertyNames(window); 26 var names2 = []; 27 var gsp = Object.getPrototypeOf(Window.prototype); 28 var names3 = Object.getOwnPropertyNames(gsp); 29 for (var i in window) { 30 names2.push(i); 31 } 32 33 is(names1.indexOf(""), -1, 34 "Element with empty id/name should not be in our own prop list"); 35 is(names2.indexOf(""), -1, 36 "Element with empty id/name name should not be in our enumeration list"); 37 is(names3.indexOf(""), -1, 38 "Element with empty id/name should not be in GSP own prop list"); 39 40 is(names1.indexOf("one"), -1, 41 "<img> with id should not be in our own prop list"); 42 is(names2.indexOf("one"), -1, 43 "<img> with id should not be in our enumeration list"); 44 isnot(names3.indexOf("one"), -1, 45 "<img> with id should be in GSP own prop list"); 46 47 is(names1.indexOf("two"), -1, 48 "<img> with name should not be in our own prop list"); 49 is(names2.indexOf("two"), -1, 50 "<img> with name should not be in our enumeration list"); 51 isnot(names3.indexOf("two"), -1, 52 "<img> with name should be in GSP own prop list"); 53 54 is(names1.indexOf("three"), -1, 55 "<div> with id should not be in our own prop list"); 56 is(names2.indexOf("three"), -1, 57 "<div> with id should not be in our enumeration list"); 58 todo_isnot(names3.indexOf("three"), -1, 59 "<div> with id should be in GSP own prop list"); 60 61 is(names1.indexOf("four"), -1, 62 "<div> with name should not be in our own prop list"); 63 is(names2.indexOf("four"), -1, 64 "<div> with name should not be in our enumeration list"); 65 is(names3.indexOf("four"), -1, 66 "<div> with name should not be in GSP own prop list"); 67 </script> 68 </pre> 69 </body> 70 </html>