summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit_ipc/test_httpcancel_wrap.js
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk/test/unit_ipc/test_httpcancel_wrap.js')
-rw-r--r--netwerk/test/unit_ipc/test_httpcancel_wrap.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/netwerk/test/unit_ipc/test_httpcancel_wrap.js b/netwerk/test/unit_ipc/test_httpcancel_wrap.js
new file mode 100644
index 0000000000..f56d0e198b
--- /dev/null
+++ b/netwerk/test/unit_ipc/test_httpcancel_wrap.js
@@ -0,0 +1,48 @@
+"use strict";
+
+const ReferrerInfo = Components.Constructor(
+ "@mozilla.org/referrer-info;1",
+ "nsIReferrerInfo",
+ "init"
+);
+
+let observer = null;
+
+function run_test() {
+ do_await_remote_message("register-observer").then(() => {
+ observer = {
+ QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
+
+ observe(subject, topic, data) {
+ subject = subject.QueryInterface(Ci.nsIRequest);
+ subject.cancel(Cr.NS_BINDING_ABORTED);
+
+ // ENSURE_CALLED_BEFORE_CONNECT: setting values should still work
+ try {
+ subject.QueryInterface(Ci.nsIHttpChannel);
+ let currentReferrer = subject.getRequestHeader("Referer");
+ Assert.equal(currentReferrer, "http://site1.com/");
+ let uri = Services.io.newURI("http://site2.com");
+ subject.referrerInfo = new ReferrerInfo(
+ Ci.nsIReferrerInfo.EMPTY,
+ true,
+ uri
+ );
+ } catch (ex) {
+ do_throw("Exception: " + ex);
+ }
+ },
+ };
+
+ Services.obs.addObserver(observer, "http-on-modify-request");
+ do_send_remote_message("register-observer-done");
+ });
+
+ do_await_remote_message("unregister-observer").then(() => {
+ Services.obs.removeObserver(observer, "http-on-modify-request");
+
+ do_send_remote_message("unregister-observer-done");
+ });
+
+ run_test_in_child("../unit/test_httpcancel.js");
+}