Bug 1267493 - Replace isURIPotentiallyTrustworthy usage in Push with a testing pref. r=dragana

MozReview-Commit-ID: LrjAyVeNMyI

--HG--
extra : rebase_source : 7b2f821a80f853986bb196d8fc5e1eae9d77fd48
This commit is contained in:
Kit Cambridge 2016-04-25 20:53:06 -07:00
parent 2e593175f4
commit 91fa002ac4
10 changed files with 23 additions and 25 deletions

View File

@ -31,10 +31,6 @@ const CONNECTION_PROTOCOLS = (function() {
}
})();
XPCOMUtils.defineLazyServiceGetter(this, "gContentSecurityManager",
"@mozilla.org/contentsecuritymanager;1",
"nsIContentSecurityManager");
XPCOMUtils.defineLazyServiceGetter(this, "gPushNotifier",
"@mozilla.org/push/Notifier;1",
"nsIPushNotifier");
@ -400,11 +396,6 @@ this.PushService = {
return [];
}
if (!gContentSecurityManager.isURIPotentiallyTrustworthy(uri)) {
console.warn("findService: Untrusted server URI", uri.spec);
return [];
}
for (let connProtocol of CONNECTION_PROTOCOLS) {
if (connProtocol.validServerURI(uri)) {
service = connProtocol;

View File

@ -71,9 +71,9 @@ this.PushServiceAndroidGCM = {
if (serverURI.scheme == "https") {
return true;
}
if (prefs.get("debug") && serverURI.scheme == "http") {
// Accept HTTP endpoints when debugging.
return true;
if (serverURI.scheme == "http") {
// Allow insecure server URLs for development and testing.
return !!prefs.get("testing.allowInsecureServerURL");
}
console.info("Unsupported Android GCM dom.push.serverURL scheme", serverURI.scheme);
return false;

View File

@ -439,7 +439,10 @@ this.PushServiceHttp2 = {
},
validServerURI: function(serverURI) {
return serverURI.scheme == "http" || serverURI.scheme == "https";
if (serverURI.scheme == "http") {
return !!prefs.get("testing.allowInsecureServerURL");
}
return serverURI.scheme == "https";
},
connect: function(subscriptions) {

View File

@ -257,7 +257,10 @@ this.PushServiceWebSocket = {
},
validServerURI: function(serverURI) {
return serverURI.scheme == "ws" || serverURI.scheme == "wss";
if (serverURI.scheme == "ws") {
return !!prefs.get("testing.allowInsecureServerURL");
}
return serverURI.scheme == "wss";
},
get _UAID() {

View File

@ -9,8 +9,6 @@ const {PushDB, PushService, PushServiceHttp2} = serviceExports;
var prefs;
var tlsProfile;
var pushEnabled;
var pushConnectionEnabled;
var serverPort = -1;
@ -21,12 +19,12 @@ function run_test() {
dump("using port " + serverPort + "\n");
do_get_profile();
setPrefs();
setPrefs({
'testing.allowInsecureServerURL': true,
});
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
tlsProfile = prefs.getBoolPref("network.http.spdy.enforce-tls-profile");
pushEnabled = prefs.getBoolPref("dom.push.enabled");
pushConnectionEnabled = prefs.getBoolPref("dom.push.connection.enabled");
// Set to allow the cert presented by our H2 server
var oldPref = prefs.getIntPref("network.http.speculative-parallel-limit");
@ -42,8 +40,6 @@ function run_test() {
prefs.setIntPref("network.http.speculative-parallel-limit", oldPref);
servicePrefs.set('testing.notifyWorkers', false);
run_next_test();
}
@ -193,6 +189,4 @@ add_task(function* test_pushNotifications() {
add_task(function* test_complete() {
prefs.setBoolPref("network.http.spdy.enforce-tls-profile", tlsProfile);
prefs.setBoolPref("dom.push.enabled", pushEnabled);
prefs.setBoolPref("dom.push.connection.enabled", pushConnectionEnabled);
});

View File

@ -53,6 +53,7 @@ function run_test() {
do_get_profile();
setPrefs({
'testing.allowInsecureServerURL': true,
'http2.retryInterval': 1000,
'http2.maxRetries': 2
});

View File

@ -51,8 +51,11 @@ function run_test() {
do_get_profile();
servicePrefs.set('testing.notifyWorkers', false);
setPrefs();
setPrefs({
'testing.allowInsecureServerURL': true,
'testing.notifyWorkers': false,
'testing.notifyAllObservers': true,
});
run_next_test();
}

View File

@ -55,6 +55,7 @@ function run_test() {
do_get_profile();
setPrefs({
'testing.allowInsecureServerURL': true,
'http2.retryInterval': 1000,
'http2.maxRetries': 2
});

View File

@ -44,6 +44,7 @@ function run_test() {
do_get_profile();
setPrefs({
'testing.allowInsecureServerURL': true,
'http2.retryInterval': 1000,
'http2.maxRetries': 2
});

View File

@ -29,6 +29,7 @@ function run_test() {
do_get_profile();
setPrefs({
'testing.allowInsecureServerURL': true,
'http2.retryInterval': 1000,
'http2.maxRetries': 2
});