tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug658909.xhtml (3245B)


      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=658909
      6 -->
      7 <window title="Mozilla Bug 658909"
      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=658909"
     14     target="_blank">Mozilla Bug 658909</a>
     15  </body>
     16 
     17  <!-- test code goes here -->
     18  <script type="application/javascript">
     19  <![CDATA[
     20  /** Test for call/apply-ing Xray methods.*/
     21  SimpleTest.waitForExplicitFinish();
     22 
     23  let gLoadCount = 0;
     24  function frameLoaded() {
     25    if (++gLoadCount == frames.length)
     26      go();
     27  }
     28 
     29  function msg(a, b, testName) {
     30    return "(" + a.name + ", " + b.name + "): " + testName;
     31  }
     32 
     33  var testFunctions = {
     34    testDocumentElement(a, b, name) {
     35      var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement');
     36      is(getter.call(b.document), b.document.documentElement, msg(a, b, name));
     37    },
     38 
     39    testInvalidCall(a, b, name) {
     40      var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement');
     41      var threw = false;
     42      try { getter.call(b.document.body); } catch (e) { threw = true; };
     43      ok(threw, msg(a, b, name));
     44    },
     45 
     46    testStatus(a, b, name) {
     47      var setter = Object.prototype.__lookupSetter__.call(a, 'status');
     48      is(b.status, "", "Empty status");
     49      setter.call(b, "foopy");
     50      is(b.status, "foopy", msg(a, b, name));
     51      b.status = "";
     52    },
     53 
     54    testCreateElement(a, b, name) {
     55      is(a.document.createElement.call(b.document, 'div').ownerDocument, b.document, msg(a, b, name));
     56    },
     57 
     58    testWindowName(a, b, name) {
     59      var getter = Object.prototype.__lookupGetter__.call(a, 'name');
     60      is(getter.call(b), b.name, msg(a, b, name));
     61    },
     62 
     63    testCanvas(a, b, name) {
     64      var canvasA = a.document.createElement('canvas');
     65      var canvasB = b.document.createElement('canvas');
     66      var contextA = canvasA.getContext('2d');
     67      var contextB = canvasB.getContext('2d');
     68      var getter = Object.prototype.__lookupGetter__.call(contextA, 'canvas');
     69      is(getter.call(contextB), canvasB, msg(a, b, name));
     70    }
     71  };
     72 
     73  function go() {
     74    for (let i = 0; i < frames.length; ++i)
     75        frames[i].name = 'frame' + i;
     76    for (let i = 0; i < frames.length; ++i) {
     77      for (let j = 0; j < frames.length; ++j) {
     78        for (let k in testFunctions)
     79          testFunctions[k](frames[i], frames[j], k);
     80      }
     81    }
     82 
     83    SimpleTest.finish();
     84  }
     85 
     86 
     87  ]]>
     88  </script>
     89  <iframe id="frame1" onload="frameLoaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
     90  <iframe id="frame2" onload="frameLoaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
     91  <iframe id="frame3" onload="frameLoaded();" type="content" src="http://example.com/tests/js/xpconnect/tests/mochitest/file_empty.html" />
     92 </window>