Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | // Needs to be in sync w/ nsUpdateService.js |
michael@0 | 7 | const NETWORK_ERROR_OFFLINE = 111; |
michael@0 | 8 | |
michael@0 | 9 | function run_test() { |
michael@0 | 10 | setupTestCommon(); |
michael@0 | 11 | |
michael@0 | 12 | logTestInfo("testing when an update check fails because the network is " + |
michael@0 | 13 | "offline that we check again when the network comes online " + |
michael@0 | 14 | "(Bug 794211)."); |
michael@0 | 15 | |
michael@0 | 16 | setUpdateURLOverride(); |
michael@0 | 17 | Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO, false); |
michael@0 | 18 | |
michael@0 | 19 | overrideXHR(null); |
michael@0 | 20 | overrideUpdatePrompt(updatePrompt); |
michael@0 | 21 | standardInit(); |
michael@0 | 22 | |
michael@0 | 23 | do_execute_soon(run_test_pt1); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | function run_test_pt1() { |
michael@0 | 27 | gResponseBody = null; |
michael@0 | 28 | gCheckFunc = check_test_pt1; |
michael@0 | 29 | gXHRCallback = xhr_pt1; |
michael@0 | 30 | gUpdateChecker.checkForUpdates(updateCheckListener, true); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | function xhr_pt1() { |
michael@0 | 34 | gXHR.status = AUS_Cr.NS_ERROR_OFFLINE; |
michael@0 | 35 | gXHR.onerror({ target: gXHR }); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function check_test_pt1(request, update) { |
michael@0 | 39 | do_check_eq(gStatusCode, AUS_Cr.NS_ERROR_OFFLINE); |
michael@0 | 40 | do_check_eq(update.errorCode, NETWORK_ERROR_OFFLINE); |
michael@0 | 41 | |
michael@0 | 42 | // Forward the error to AUS, which should register the online observer |
michael@0 | 43 | gAUS.onError(request, update); |
michael@0 | 44 | |
michael@0 | 45 | // Trigger another check by notifying the offline status observer |
michael@0 | 46 | gXHRCallback = xhr_pt2; |
michael@0 | 47 | Services.obs.notifyObservers(gAUS, "network:offline-status-changed", "online"); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | var updatePrompt = { |
michael@0 | 51 | showUpdateAvailable: function(update) { |
michael@0 | 52 | check_test_pt2(update); |
michael@0 | 53 | } |
michael@0 | 54 | }; |
michael@0 | 55 | |
michael@0 | 56 | function xhr_pt2() { |
michael@0 | 57 | var patches = getLocalPatchString(); |
michael@0 | 58 | var updates = getLocalUpdateString(patches); |
michael@0 | 59 | var responseBody = getLocalUpdatesXMLString(updates); |
michael@0 | 60 | |
michael@0 | 61 | gXHR.status = 200; |
michael@0 | 62 | gXHR.responseText = responseBody; |
michael@0 | 63 | try { |
michael@0 | 64 | var parser = AUS_Cc["@mozilla.org/xmlextras/domparser;1"]. |
michael@0 | 65 | createInstance(AUS_Ci.nsIDOMParser); |
michael@0 | 66 | gXHR.responseXML = parser.parseFromString(responseBody, "application/xml"); |
michael@0 | 67 | } catch (e) { |
michael@0 | 68 | } |
michael@0 | 69 | gXHR.onload({ target: gXHR }); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function check_test_pt2(update) { |
michael@0 | 73 | // We just verify that there are updates to know the check succeeded. |
michael@0 | 74 | do_check_neq(update, null); |
michael@0 | 75 | do_check_eq(update.name, "App Update Test"); |
michael@0 | 76 | |
michael@0 | 77 | doTestFinish(); |
michael@0 | 78 | } |