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:
Valentin Gosu 2019-05-22 13:48:31 +00:00
parent 3a05468aa4
commit 9f3b339e68
4 changed files with 63 additions and 4 deletions

View File

@ -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) {

View File

@ -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);
}

View 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");
}

View File

@ -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]