mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1529911 - Make the httpcancel unit test run in e10s r=mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D20501 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
3a05468aa4
commit
9f3b339e68
@ -3721,7 +3721,10 @@ nsresult HttpChannelChild::AsyncCallImpl(
|
||||
}
|
||||
|
||||
nsresult HttpChannelChild::SetReferrerHeader(const nsACString& aReferrer) {
|
||||
ENSURE_CALLED_BEFORE_CONNECT();
|
||||
// Normally this would be ENSURE_CALLED_BEFORE_CONNECT, but since the
|
||||
// "connect" is done in the main process, and mRequestObserversCalled is never
|
||||
// set in the ChannelChild, before connect basically means before asyncOpen.
|
||||
ENSURE_CALLED_BEFORE_ASYNC_OPEN();
|
||||
|
||||
// remove old referrer if any, loop backwards
|
||||
for (int i = mClientSetRequestHeaders.Length() - 1; i >= 0; --i) {
|
||||
|
@ -6,6 +6,12 @@
|
||||
|
||||
const {HttpServer} = ChromeUtils.import("resource://testing-common/httpd.js");
|
||||
|
||||
function inChildProcess() {
|
||||
return Cc["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService);
|
||||
var ReferrerInfo = Components.Constructor("@mozilla.org/referrer-info;1",
|
||||
@ -90,9 +96,11 @@ function execute_test() {
|
||||
var chan = makeChan("http://localhost:" +
|
||||
httpserv.identity.primaryPort + "/failtest");
|
||||
|
||||
var obs = Cc["@mozilla.org/observer-service;1"].getService();
|
||||
obs = obs.QueryInterface(Ci.nsIObserverService);
|
||||
obs.addObserver(observer, "http-on-modify-request");
|
||||
if (!inChildProcess()) {
|
||||
var obs = Cc["@mozilla.org/observer-service;1"].getService();
|
||||
obs = obs.QueryInterface(Ci.nsIObserverService);
|
||||
obs.addObserver(observer, "http-on-modify-request");
|
||||
}
|
||||
|
||||
chan.asyncOpen(listener);
|
||||
}
|
||||
|
46
netwerk/test/unit_ipc/test_httpcancel_wrap.js
Normal file
46
netwerk/test/unit_ipc/test_httpcancel_wrap.js
Normal file
@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
const {HttpServer} = ChromeUtils.import("resource://testing-common/httpd.js");
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const ReferrerInfo = Components.Constructor("@mozilla.org/referrer-info;1",
|
||||
"nsIReferrerInfo",
|
||||
"init");
|
||||
|
||||
let observer = {
|
||||
QueryInterface: function eventsink_qi(iid) {
|
||||
if (iid.equals(Ci.nsISupports) ||
|
||||
iid.equals(Ci.nsIObserver))
|
||||
return this;
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
|
||||
observe: function(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.nsIHttpChannel.REFERRER_POLICY_UNSET, true, uri);
|
||||
} catch (ex) {
|
||||
do_throw("Exception: " + ex);
|
||||
}
|
||||
|
||||
let obs = Cc["@mozilla.org/observer-service;1"].getService();
|
||||
obs = obs.QueryInterface(Ci.nsIObserverService);
|
||||
obs.removeObserver(observer, "http-on-modify-request");
|
||||
}
|
||||
};
|
||||
|
||||
function run_test() {
|
||||
|
||||
let obs = Cc["@mozilla.org/observer-service;1"].getService();
|
||||
obs = obs.QueryInterface(Ci.nsIObserverService);
|
||||
obs.addObserver(observer, "http-on-modify-request");
|
||||
|
||||
run_test_in_child("../unit/test_httpcancel.js");
|
||||
}
|
@ -58,6 +58,7 @@ support-files =
|
||||
!/netwerk/test/unit/test_multipart_streamconv.js
|
||||
!/netwerk/test/unit/test_original_sent_received_head.js
|
||||
!/netwerk/test/unit/test_alt-data_cross_process.js
|
||||
!/netwerk/test/unit/test_httpcancel.js
|
||||
child_cookie_header.js
|
||||
|
||||
[test_bug528292_wrap.js]
|
||||
@ -106,3 +107,4 @@ skip-if = true
|
||||
[test_channel_priority_wrap.js]
|
||||
[test_multipart_streamconv_wrap.js]
|
||||
[test_alt-data_cross_process_wrap.js]
|
||||
[test_httpcancel_wrap.js]
|
||||
|
Loading…
Reference in New Issue
Block a user