|
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 type="application/javascript" 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 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
22 |
|
23 SimpleTest.waitForExplicitFinish(); |
|
24 |
|
25 var triedForwarding = false; |
|
26 var forwardFailed = false; |
|
27 |
|
28 var xhr = new XMLHttpRequest; |
|
29 var eventSink = xhr.getInterface(Components.interfaces.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: function(aIID) { |
|
36 if (aIID.equals(Components.interfaces.nsIProgressEventSink)) { |
|
37 triedForwarding = true; |
|
38 try { |
|
39 return xhr.getInterface(aIID); |
|
40 } catch (e) { |
|
41 forwardFailed = true; |
|
42 } |
|
43 } |
|
44 throw Components.results.NS_ERROR_NO_INTERFACE; |
|
45 }, |
|
46 |
|
47 QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports, |
|
48 Components.interfaces.nsIInterfaceRequestor]) |
|
49 }; |
|
50 |
|
51 // HTTP URI so that we get progress callbacks |
|
52 xhr.open("GET", "http://mochi.test:8888/", false); |
|
53 xhr.channel.notificationCallbacks = requestor; |
|
54 xhr.onreadystatechange = function() { |
|
55 if (xhr.readyState == 4) { |
|
56 ok(triedForwarding, |
|
57 "Should have had an attempt to treat us as a progress event sink"); |
|
58 ok(!forwardFailed, |
|
59 "Should have been able to forward getInterface on to the XHR"); |
|
60 SimpleTest.finish(); |
|
61 } |
|
62 } |
|
63 xhr.send(); |
|
64 ]]> |
|
65 </script> |
|
66 </window> |