tor-browser

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

test_bug800386.xhtml (2029B)


      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=800386
      6 -->
      7 <window title="Mozilla Bug 800386"
      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=800386"
     14     target="_blank">Mozilla Bug 800386</a>
     15  </body>
     16 
     17  <!-- test code goes here -->
     18  <script type="application/javascript">
     19  <![CDATA[
     20  /** Test for Bug 800386 */
     21  SimpleTest.waitForExplicitFinish();
     22 
     23  var triedForwarding = false;
     24  var forwardFailed = false;
     25 
     26  var xhr = new XMLHttpRequest;
     27  var xhr2 = new XMLHttpRequest;
     28 
     29  var eventSink = xhr.getInterface(Ci.nsIProgressEventSink);
     30  isnot(eventSink, null, "Should get event sink directly!");
     31 
     32  // Now jump through some hoops to get us a getInterface call from C++
     33 
     34  var requestor = {
     35    getInterface(aIID) {
     36      if (aIID.equals(Ci.nsIProgressEventSink)) {
     37        triedForwarding = true;
     38        try {
     39          return xhr2.getInterface(aIID);
     40        } catch (e) {
     41          forwardFailed = true;
     42        }
     43      }
     44      throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
     45    },
     46 
     47    QueryInterface: ChromeUtils.generateQI(["nsIInterfaceRequestor"])
     48  };
     49 
     50  // HTTP URI so that we get progress callbacks
     51  xhr.open("GET", "http://mochi.test:8888/", false);
     52  xhr.channel.notificationCallbacks = requestor;
     53  xhr.onreadystatechange = function() {
     54    if (xhr.readyState == 4) {
     55      ok(triedForwarding,
     56         "Should have had an attempt to treat us as a progress event sink");
     57      ok(!forwardFailed,
     58         "Should have been able to forward getInterface on to the XHR");
     59      SimpleTest.finish();
     60    }
     61  }
     62  xhr.send();
     63  ]]>
     64  </script>
     65 </window>