test_barewordGetsWindow.html (2160B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=936056 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 936056</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script type="application/javascript"> 12 13 /** Test for Bug 936056 */ 14 SimpleTest.waitForExplicitFinish(); 15 window.onload = function() { 16 var desc = Object.getOwnPropertyDescriptor(frames[0], "document"); 17 if (!desc || !desc.get) { 18 todo(false, "This test does nothing so far, but will once Window is on WebIDL bindings"); 19 SimpleTest.finish(); 20 return; 21 } 22 var get = desc.get; 23 ok(get, "Couldn't find document getter"); 24 Object.defineProperty(frames[0], "foo", { get, configurable: true }); 25 26 var barewordFunc = frames[0].eval("(function (count) { var doc; for (var i = 0; i < count; ++i) doc = foo; return doc.documentElement; })"); 27 var qualifiedFunc = frames[0].eval("(function (count) { var doc; for (var i = 0; i < count; ++i) doc = window.document; return doc.documentElement; })"); 28 document.querySelector("iframe").onload = function() { 29 // interp 30 is(barewordFunc(1).innerText, "OLD", "Bareword should see own inner 1"); 31 is(qualifiedFunc(1).innerText, "NEW", 32 "Qualified should see current inner 1"); 33 // baseline 34 is(barewordFunc(100).innerText, "OLD", "Bareword should see own inner 2"); 35 is(qualifiedFunc(100).innerText, "NEW", 36 "Qualified should see current inner 2"); 37 // ion 38 is(barewordFunc(10000).innerText, "OLD", "Bareword should see own inner 3"); 39 is(qualifiedFunc(10000).innerText, "NEW", 40 "Qualified should see current inner 2"); 41 SimpleTest.finish(); 42 }; 43 frames[0].location = "file_barewordGetsWindow_frame2.html"; 44 }; 45 46 47 48 49 </script> 50 </head> 51 <body> 52 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=936056">Mozilla Bug 936056</a> 53 <p id="display"></p> 54 <div id="content" style="display: none"> 55 <iframe src="file_barewordGetsWindow_frame1.html"></iframe> 56 </div> 57 <pre id="test"> 58 </pre> 59 </body> 60 </html>