Bug 1115186: prevent network connections during loop module tests. r=MattN

This commit is contained in:
Paul Kerr [:pkerr] 2014-12-26 12:30:01 -08:00
Родитель 56391efa3c
Коммит f632c8537d
1 изменённых файлов: 19 добавлений и 14 удалений

Просмотреть файл

@ -7,7 +7,7 @@
"use strict";
const BASE_URL = "http://mochi.test:8888/browser/browser/components/loop/test/mochitest/loop_fxa.sjs?";
const BASE_URL = Services.prefs.getCharPref("loop.server");
function* checkFxA401() {
let err = MozLoopService.errors.get("login");
@ -23,7 +23,7 @@ function* checkFxA401() {
"state of loop button should be error after a 401 with login");
let loopPanel = document.getElementById("loop-notification-panel");
yield loadLoopPanel({loopURL: BASE_URL });
yield loadLoopPanel();
let loopDoc = document.getElementById("loop").contentDocument;
is(loopDoc.querySelector(".alert-error .message").textContent,
getLoopString("could_not_authenticate"),
@ -132,17 +132,22 @@ add_task(function* params_no_hawk_session() {
add_task(function* params_nonJSON() {
let loopServerUrl = Services.prefs.getCharPref("loop.server");
Services.prefs.setCharPref("loop.server", "https://localhost:3000/invalid");
// Reset after changing the server so a new HawkClient is created
yield resetFxA();
try {
// Reset after changing the server so a new HawkClient is created
yield resetFxA();
let loginPromise = MozLoopService.logInToFxA();
let caught = false;
yield loginPromise.catch(() => {
ok(true, "The login promise should be rejected due to non-JSON params");
caught = true;
});
ok(caught, "Should have caught the rejection");
Services.prefs.setCharPref("loop.server", loopServerUrl);
let loginPromise = MozLoopService.logInToFxA();
let caught = false;
yield loginPromise.catch(() => {
ok(true, "The login promise should be rejected due to non-JSON params");
caught = true;
});
ok(caught, "Should have caught the rejection");
} catch (err) {
throw err;
} finally {
Services.prefs.setCharPref("loop.server", loopServerUrl);
}
});
add_task(function* invalidState() {
@ -286,7 +291,7 @@ add_task(function* basicAuthorizationAndRegistration() {
yield MozLoopService.promiseRegisteredWithServers();
let statusChangedPromise = promiseObserverNotified("loop-status-changed");
yield loadLoopPanel({loopURL: BASE_URL, stayOnline: true});
yield loadLoopPanel({stayOnline: true});
yield statusChangedPromise;
let loopDoc = document.getElementById("loop").contentDocument;
let visibleEmail = loopDoc.getElementsByClassName("user-identity")[0];
@ -316,7 +321,7 @@ add_task(function* basicAuthorizationAndRegistration() {
let loopPanel = document.getElementById("loop-notification-panel");
loopPanel.hidePopup();
statusChangedPromise = promiseObserverNotified("loop-status-changed");
yield loadLoopPanel({loopURL: BASE_URL, stayOnline: true});
yield loadLoopPanel({stayOnline: true});
yield statusChangedPromise;
is(loopButton.getAttribute("state"), "", "state of loop button should return to empty after panel is opened");
loopPanel.hidePopup();