Bug 1311739 - Fail push tests with an informative error if the H/2 server port is missing. r=dragana

MozReview-Commit-ID: 97rOKjbDlTu

--HG--
extra : rebase_source : 62c385b7317a3d9d3a7ad807eca6667ae25a255b
This commit is contained in:
Kit Cambridge 2016-10-20 09:25:36 -07:00
parent d83be5fb40
commit ee288ff7bb
6 changed files with 16 additions and 16 deletions

View File

@ -1,3 +1,14 @@
// Returns the test H/2 server port, throwing if it's missing or invalid.
function getTestServerPort() {
let portEnv = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment).get("MOZHTTP2_PORT");
let port = parseInt(portEnv, 10);
if (!Number.isFinite(port) || port < 1 || port > 65535) {
throw new Error(`Invalid port in MOZHTTP2_PORT env var: ${portEnv}`);
}
do_print(`Using HTTP/2 server on port ${port}`);
return port;
}
// Support for making sure we can talk to the invalid cert the server presents
var CertOverrideListener = function(host, port, bits) {

View File

@ -13,10 +13,7 @@ var tlsProfile;
var serverPort = -1;
function run_test() {
var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
serverPort = env.get("MOZHTTP2_PORT");
do_check_neq(serverPort, null);
dump("using port " + serverPort + "\n");
serverPort = getTestServerPort();
do_get_profile();
setPrefs({

View File

@ -14,9 +14,7 @@ var serverURL;
var serverPort = -1;
function run_test() {
var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
serverPort = env.get("MOZHTTP2_PORT");
do_check_neq(serverPort, null);
serverPort = getTestServerPort();
do_get_profile();
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);

View File

@ -16,9 +16,7 @@ var pushConnectionEnabled;
var db;
function run_test() {
var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
serverPort = env.get("MOZHTTP2_PORT");
do_check_neq(serverPort, null);
serverPort = getTestServerPort();
do_get_profile();
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);

View File

@ -21,9 +21,7 @@ var prefs;
var serverPort = -1;
function run_test() {
var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
serverPort = env.get("MOZHTTP2_PORT");
do_check_neq(serverPort, null);
serverPort = getTestServerPort();
do_get_profile();
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);

View File

@ -24,9 +24,7 @@ var pushConnectionEnabled;
var serverPort = -1;
function run_test() {
var env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
serverPort = env.get("MOZHTTP2_PORT");
do_check_neq(serverPort, null);
serverPort = getTestServerPort();
do_get_profile();
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);