tor-browser

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

test_bug503926.xhtml (2019B)


      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=503926
      6 -->
      7 <window title="Mozilla Bug 503926"
      8        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     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=503926"
     14     target="_blank">Mozilla Bug 503926</a>
     15 
     16  <iframe id="ifr" type="content" onload="loaded()" src="bug503926.xhtml#iframe"/>
     17  <iframe id="ifrContent" type="content" onload="loaded()" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"/>
     18  </body>
     19 
     20  <!-- test code goes here -->
     21  <script type="application/javascript">
     22  <![CDATA[
     23 
     24  SimpleTest.expectAssertions(0, 1);
     25 
     26  var gLoadCount = 0;
     27  function loaded() {
     28    if (++gLoadCount == 2)
     29      go();
     30  }
     31 
     32  /** Test for Bug 503926 */
     33  function go() {
     34    var gWindowUtils = window.windowUtils;
     35 
     36    // Try with a chrome object.
     37    var passed = false;
     38    // eslint-disable-next-line mozilla/use-chromeutils-generateqi
     39    var obj = { QueryInterface() { passed = true; } };
     40    gWindowUtils.xpconnectArgument(obj);
     41    ok(passed, "trusted QIs should be called");
     42 
     43    // Try with a content object.
     44    var contentWin = $('ifrContent').contentWindow.wrappedJSObject;
     45    contentWin.passed = false;
     46    var contentObj = contentWin.eval('({ QueryInterface: function() { passed = true; } })');
     47    gWindowUtils.xpconnectArgument(contentObj);
     48    ok(!contentWin.passed, "untrusted QI should not be called");
     49 
     50    // Try with a dialog.
     51    window.browsingContext.topChromeWindow.openDialog("bug503926.xhtml", "chromeDialog", "modal", window);
     52    SimpleTest.finish();
     53  }
     54 
     55  SimpleTest.waitForExplicitFinish();
     56  ]]>
     57  </script>
     58 </window>