tor-browser

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

test_bug533596.xhtml (2184B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
      4                 type="text/css"?>
      5 <!--
      6 https://bugzilla.mozilla.org/show_bug.cgi?id=533596
      7 -->
      8 <window title="Mozilla Bug 533596"
      9  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     10  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     11 
     12  <!-- test results are displayed in the html:body -->
     13  <body xmlns="http://www.w3.org/1999/xhtml">
     14  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=533596"
     15     target="_blank">Mozilla Bug 533596</a>
     16  </body>
     17 
     18  <!-- test code goes here -->
     19  <script type="application/javascript"><![CDATA[
     20 
     21  // XPCNativeWrapper is not defined globally in ESLint as it may be going away.
     22  // See bug 1481337.
     23  /* global XPCNativeWrapper */
     24 
     25  /** Test for Bug 533596 */
     26 
     27  function go() {
     28    try { XPCNativeWrapper.unwrap(); } catch (e) {}
     29    try { XPCNativeWrapper.unwrap(0); } catch (e) {}
     30    try { XPCNativeWrapper.unwrap(null); } catch (e) {}
     31 
     32    var o = {};
     33    is(o, XPCNativeWrapper.unwrap(o), "unwrap on a random object returns it");
     34 
     35    var win = $('ifr').contentWindow;
     36    var utils = window.windowUtils;
     37    is(utils.getClassName(win), "Proxy", "win is a Proxy");
     38    ok("x" in XPCNativeWrapper.unwrap(win), "actually unwrapped");
     39    is(utils.getClassName(XPCNativeWrapper.unwrap(win)), "Proxy",
     40       "unwrap on an Proxy returns the same object");
     41    is(utils.getClassName(XPCNativeWrapper.unwrap(new XPCNativeWrapper(win))), "Proxy",
     42       "unwrap on an explicit NW works too");
     43 
     44    ok(utils.getClassName(window) !== "XPCNativeWrapper", "window is not a native wrapper");
     45    ok(utils.getClassName(XPCNativeWrapper.unwrap(new XPCNativeWrapper(window))) !== "XPCSafeJSObjectWrapper",
     46       "unwrapping a chrome object returns the object itself");
     47    SimpleTest.finish();
     48  }
     49 
     50  SimpleTest.waitForExplicitFinish();
     51 
     52  ]]></script>
     53  <iframe type="content"
     54          src="http://example.org/tests/js/xpconnect/tests/mochitest/bug500931_helper.html"
     55          onload="go()"
     56          id="ifr">
     57  </iframe>
     58 </window>