From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- netwerk/test/unit_ipc/test_httpcancel_wrap.js | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 netwerk/test/unit_ipc/test_httpcancel_wrap.js (limited to 'netwerk/test/unit_ipc/test_httpcancel_wrap.js') 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"); +} -- cgit v1.2.3