toolkit/mozapps/update/tests/marionette/update_test_status.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 const TEST_URL = "http://localhost";
michael@0 5
michael@0 6 setPref("b2g.update.apply-idle-timeout", 0);
michael@0 7 setPref("app.update.backgroundErrors", 0);
michael@0 8 setPref("app.update.backgroundMaxErrors", 100);
michael@0 9
michael@0 10 function forceCheckAndTestStatus(status, next) {
michael@0 11 let mozSettings = window.navigator.mozSettings;
michael@0 12 let forceSent = false;
michael@0 13
michael@0 14 mozSettings.addObserver("gecko.updateStatus", function statusObserver(setting) {
michael@0 15 if (!forceSent) {
michael@0 16 return;
michael@0 17 }
michael@0 18
michael@0 19 mozSettings.removeObserver("gecko.updateStatus", statusObserver);
michael@0 20 is(setting.settingValue, status, "gecko.updateStatus");
michael@0 21 next();
michael@0 22 });
michael@0 23
michael@0 24 sendContentEvent("force-update-check");
michael@0 25 forceSent = true;
michael@0 26 }
michael@0 27
michael@0 28 function testBadXml() {
michael@0 29 setPref("app.update.url.override", TEST_URL + "/bad.xml");
michael@0 30 forceCheckAndTestStatus("check-error-http-200", testAccessDenied);
michael@0 31 }
michael@0 32
michael@0 33 function testAccessDenied() {
michael@0 34 setPref("app.update.url.override", TEST_URL + "/cgi-bin/err.cgi?403");
michael@0 35 forceCheckAndTestStatus("check-error-http-403", testNoUpdateXml);
michael@0 36 }
michael@0 37
michael@0 38 function testNoUpdateXml() {
michael@0 39 setPref("app.update.url.override", TEST_URL + "/none.html");
michael@0 40 forceCheckAndTestStatus("check-error-http-404", testInternalServerError);
michael@0 41 }
michael@0 42
michael@0 43 function testInternalServerError() {
michael@0 44 setPref("app.update.url.override", TEST_URL + "/cgi-bin/err.cgi?500");
michael@0 45 forceCheckAndTestStatus("check-error-http-500", testBadHostStatus);
michael@0 46 }
michael@0 47
michael@0 48 function testBadHostStatus() {
michael@0 49 setPref("app.update.url.override", "http://bad-host-doesnt-exist-sorry.com");
michael@0 50 forceCheckAndTestStatus("check-error-" + Cr.NS_ERROR_UNKNOWN_HOST, cleanUp);
michael@0 51 }
michael@0 52
michael@0 53 // Update test functions
michael@0 54 function preUpdate() {
michael@0 55 testBadXml();
michael@0 56 }

mercurial