content/base/test/chrome/test_bug800386.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/chrome/test_bug800386.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     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=800386
     1.9 +-->
    1.10 +<window title="Mozilla Bug 800386"
    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=800386"
    1.17 +     target="_blank">Mozilla Bug 800386</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 Bug 800386 **/
    1.24 +  Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
    1.25 +
    1.26 +  SimpleTest.waitForExplicitFinish();
    1.27 +
    1.28 +  var triedForwarding = false;
    1.29 +  var forwardFailed = false;
    1.30 +
    1.31 +  var xhr = new XMLHttpRequest;
    1.32 +  var eventSink = xhr.getInterface(Components.interfaces.nsIProgressEventSink);
    1.33 +  isnot(eventSink, null, "Should get event sink directly!");
    1.34 +
    1.35 +  // Now jump through some hoops to get us a getInterface call from C++
    1.36 +
    1.37 +  var requestor = {
    1.38 +    getInterface: function(aIID) {
    1.39 +      if (aIID.equals(Components.interfaces.nsIProgressEventSink)) {
    1.40 +        triedForwarding = true;
    1.41 +        try {
    1.42 +          return xhr.getInterface(aIID);
    1.43 +        } catch (e) {
    1.44 +          forwardFailed = true;
    1.45 +        }
    1.46 +      }
    1.47 +      throw Components.results.NS_ERROR_NO_INTERFACE;
    1.48 +    },
    1.49 +
    1.50 +    QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports,
    1.51 +                                           Components.interfaces.nsIInterfaceRequestor])
    1.52 +  };
    1.53 +
    1.54 +  // HTTP URI so that we get progress callbacks
    1.55 +  xhr.open("GET", "http://mochi.test:8888/", false);
    1.56 +  xhr.channel.notificationCallbacks = requestor;
    1.57 +  xhr.onreadystatechange = function() {
    1.58 +    if (xhr.readyState == 4) {
    1.59 +      ok(triedForwarding,
    1.60 +         "Should have had an attempt to treat us as a progress event sink");
    1.61 +      ok(!forwardFailed,
    1.62 +         "Should have been able to forward getInterface on to the XHR");
    1.63 +      SimpleTest.finish();
    1.64 +    }
    1.65 +  }
    1.66 +  xhr.send();
    1.67 +  ]]>
    1.68 +  </script>
    1.69 +</window>

mercurial