1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/xpconnect/tests/chrome/test_bug658909.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,92 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?> 1.6 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 1.7 +<!-- 1.8 +https://bugzilla.mozilla.org/show_bug.cgi?id=658909 1.9 +--> 1.10 +<window title="Mozilla Bug 658909" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.13 + 1.14 + <!-- test results are displayed in the html:body --> 1.15 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.16 + <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=658909" 1.17 + target="_blank">Mozilla Bug 658909</a> 1.18 + </body> 1.19 + 1.20 + <!-- test code goes here --> 1.21 + <script type="application/javascript"> 1.22 + <![CDATA[ 1.23 + /** Test for call/apply-ing Xray methods.**/ 1.24 + SimpleTest.waitForExplicitFinish(); 1.25 + 1.26 + gLoadCount = 0; 1.27 + function frameLoaded() { 1.28 + if (++gLoadCount == frames.length) 1.29 + go(); 1.30 + } 1.31 + 1.32 + function msg(a, b, testName) { 1.33 + return "(" + a.name + ", " + b.name + "): " + testName; 1.34 + } 1.35 + 1.36 + var testFunctions = { 1.37 + testDocumentElement: function(a, b, name) { 1.38 + var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement'); 1.39 + is(getter.call(b.document), b.document.documentElement, msg(a, b, name)); 1.40 + }, 1.41 + 1.42 + testInvalidCall: function(a, b, name) { 1.43 + var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement'); 1.44 + var threw = false; 1.45 + try { getter.call(b.document.body); } catch (e) { threw = true; }; 1.46 + ok(threw, msg(a, b, name)); 1.47 + }, 1.48 + 1.49 + testStatus: function(a, b, name) { 1.50 + var setter = Object.prototype.__lookupSetter__.call(a, 'status'); 1.51 + is(b.status, "", "Empty status"); 1.52 + setter.call(b, "foopy"); 1.53 + is(b.status, "foopy", msg(a, b, name)); 1.54 + b.status = ""; 1.55 + }, 1.56 + 1.57 + testCreateElement: function(a, b, name) { 1.58 + is(a.document.createElement.call(b.document, 'div').ownerDocument, b.document, msg(a, b, name)); 1.59 + }, 1.60 + 1.61 + testWindowName: function(a, b, name) { 1.62 + var getter = Object.prototype.__lookupGetter__.call(a, 'name'); 1.63 + is(getter.call(b), b.name, msg(a, b, name)); 1.64 + }, 1.65 + 1.66 + testCanvas: function(a, b, name) { 1.67 + var canvasA = a.document.createElement('canvas'); 1.68 + var canvasB = b.document.createElement('canvas'); 1.69 + var contextA = canvasA.getContext('2d'); 1.70 + var contextB = canvasB.getContext('2d'); 1.71 + var getter = Object.prototype.__lookupGetter__.call(contextA, 'canvas'); 1.72 + is(getter.call(contextB), canvasB, msg(a, b, name)); 1.73 + } 1.74 + }; 1.75 + 1.76 + function go() { 1.77 + for (var i = 0; i < frames.length; ++i) 1.78 + frames[i].name = 'frame' + i; 1.79 + for (var i = 0; i < frames.length; ++i) { 1.80 + for (var j = 0; j < frames.length; ++j) { 1.81 + for (var k in testFunctions) 1.82 + testFunctions[k](frames[i], frames[j], k); 1.83 + } 1.84 + } 1.85 + 1.86 + SimpleTest.finish(); 1.87 + } 1.88 + 1.89 + 1.90 + ]]> 1.91 + </script> 1.92 + <iframe id="frame1" onload="frameLoaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" /> 1.93 + <iframe id="frame2" onload="frameLoaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" /> 1.94 + <iframe id="frame3" onload="frameLoaded();" type="content" src="http://example.com/tests/js/xpconnect/tests/mochitest/file_empty.html" /> 1.95 +</window>