Bug 1023638 - fix test_captive_portal_found_303.js to not redirect to example.org; r=schien

This commit is contained in:
Nathan Froyd 2014-06-10 20:24:05 -04:00
parent 4bfe09e6ca
commit 2ec75a1a96

View File

@ -6,10 +6,12 @@
const kInterfaceName = 'wifi';
var server;
var step = 0;
var loginFinished = false;
var gRedirectServer;
var gRedirectServerURL;
function xhr_handler(metadata, response) {
if (loginFinished) {
response.setStatusLine(metadata.httpVersion, 200, 'OK');
@ -18,7 +20,7 @@ function xhr_handler(metadata, response) {
response.write('true');
} else {
response.setStatusLine(metadata.httpVersion, 303, "See Other");
response.setHeader("Location", "http://example.org/", false);
response.setHeader("Location", gRedirectServerURL, false);
response.setHeader("Content-Type", "text/html", false);
}
}
@ -38,7 +40,9 @@ function fakeUIResponse() {
Services.obs.addObserver(function observe(subject, topic, data) {
if (topic === 'captive-portal-login-success') {
do_check_eq(++step, 4);
gServer.stop(do_test_finished);
gServer.stop(function () {
gRedirectServer.stop(do_test_finished);
});
}
}, 'captive-portal-login-success', false);
}
@ -62,5 +66,9 @@ function test_portal_found() {
}
function run_test() {
gRedirectServer = new HttpServer();
gRedirectServer.start(-1);
gRedirectServerURL = 'http://localhost:' + gRedirectServer.identity.primaryPort;
run_captivedetect_test(xhr_handler, fakeUIResponse, test_portal_found);
}