test_xrayic.xhtml (2771B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?> 3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 4 <!-- 5 https://bugzilla.mozilla.org/show_bug.cgi?id=1355109 6 --> 7 <window title="Mozilla Bug 1355109" 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 10 11 <!-- test results are displayed in the html:body --> 12 <body xmlns="http://www.w3.org/1999/xhtml"> 13 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=758415" 14 target="_blank">Mozilla Bug 758415</a> 15 </body> 16 17 <!-- test code goes here --> 18 <script type="application/javascript"> 19 <![CDATA[ 20 21 SimpleTest.waitForExplicitFinish(); 22 23 // Wait for all child frames to load. 24 var gLoadCount = 0; 25 function frameLoaded() { 26 if (++gLoadCount == window.frames.length) 27 go(); 28 } 29 30 function go() { 31 testSandbox(1); 32 testSandbox(100); 33 testSandbox(1000); 34 SimpleTest.finish(); 35 } 36 37 function testSandbox(iterations) { 38 // Create an expanded principal sandbox to get xrays with exclusive 39 // expandos. 40 var sandbox = new Cu.Sandbox(["https://test1.example.org", 41 "https://test2.example.org"]); 42 sandbox.iframeWindows = new sandbox.Array(); 43 for (let iframe of document.getElementsByTagName('iframe')) { 44 sandbox.iframeWindows.push(iframe.contentWindow); 45 } 46 Cu.evalInSandbox(testClassName.toSource(), sandbox); 47 Cu.evalInSandbox(testIC.toSource(), sandbox); 48 is(Cu.evalInSandbox("testIC(" + iterations + ");", sandbox), true, "sandbox test"); 49 } 50 51 // This is in a separate function to provide a common source location for ICs. 52 function testClassName(obj, expected) { 53 var className = obj.className; 54 if (className != expected) 55 throw new Error("Got " + className + ", expected " + expected); 56 } 57 58 function testIC(iterations) { 59 for (var i = 0; i < this.iframeWindows.length; i++) { 60 var win = this.iframeWindows[i]; 61 var spans = win.document.getElementsByTagName('span'); 62 for (var j = 0; j < spans.length; j++) { 63 var span = spans[j]; 64 for (var k = 0; k < iterations; k++) 65 testClassName(span, "iamaspan"); 66 Object.defineProperty(span, "className", { value: "what" }); 67 testClassName(span, "what"); 68 } 69 } 70 return true; 71 } 72 ]]> 73 </script> 74 <iframe id="inlineFrame1" onload="frameLoaded();" type="content" src="https://test1.example.org/tests/js/xpconnect/tests/mochitest/file_xrayic.html" /> 75 <iframe id="inlineFrame2" onload="frameLoaded();" type="content" src="https://test1.example.org/tests/js/xpconnect/tests/mochitest/file_xrayic.html" /> 76 </window>