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 | // Errors tested: |
michael@0 | 7 | // 200, 403, 404, 500, 2152398849, 2152398862, 2152398864, 2152398867, |
michael@0 | 8 | // 2152398868, 2152398878, 2152398890, 2152398919, 2152398920, 2153390069, |
michael@0 | 9 | // 2152398918, 2152398861 |
michael@0 | 10 | |
michael@0 | 11 | var gNextRunFunc; |
michael@0 | 12 | var gExpectedStatusCode; |
michael@0 | 13 | var gExpectedStatusText; |
michael@0 | 14 | |
michael@0 | 15 | function run_test() { |
michael@0 | 16 | setupTestCommon(); |
michael@0 | 17 | |
michael@0 | 18 | logTestInfo("testing nsIUpdateCheckListener onload and onerror error code " + |
michael@0 | 19 | "and statusText values"); |
michael@0 | 20 | |
michael@0 | 21 | setUpdateURLOverride(); |
michael@0 | 22 | standardInit(); |
michael@0 | 23 | // The mock XMLHttpRequest is MUCH faster |
michael@0 | 24 | overrideXHR(callHandleEvent); |
michael@0 | 25 | do_execute_soon(run_test_pt1); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | // Callback function used by the custom XMLHttpRequest implementation to |
michael@0 | 29 | // call the nsIDOMEventListener's handleEvent method for onload. |
michael@0 | 30 | function callHandleEvent() { |
michael@0 | 31 | gXHR.status = gExpectedStatusCode; |
michael@0 | 32 | var e = { target: gXHR }; |
michael@0 | 33 | gXHR.onload(e); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | // Helper functions for testing nsIUpdateCheckListener statusText |
michael@0 | 37 | function run_test_helper(aNextRunFunc, aExpectedStatusCode, aMsg) { |
michael@0 | 38 | gStatusCode = null; |
michael@0 | 39 | gStatusText = null; |
michael@0 | 40 | gCheckFunc = check_test_helper; |
michael@0 | 41 | gNextRunFunc = aNextRunFunc; |
michael@0 | 42 | gExpectedStatusCode = aExpectedStatusCode; |
michael@0 | 43 | logTestInfo(aMsg, Components.stack.caller); |
michael@0 | 44 | gUpdateChecker.checkForUpdates(updateCheckListener, true); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | function check_test_helper() { |
michael@0 | 48 | do_check_eq(gStatusCode, gExpectedStatusCode); |
michael@0 | 49 | var expectedStatusText = getStatusText(gExpectedStatusCode); |
michael@0 | 50 | do_check_eq(gStatusText, expectedStatusText); |
michael@0 | 51 | gNextRunFunc(); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * The following tests use a custom XMLHttpRequest to return the status codes |
michael@0 | 56 | */ |
michael@0 | 57 | |
michael@0 | 58 | // default onerror error message (error code 399 is not defined) |
michael@0 | 59 | function run_test_pt1() { |
michael@0 | 60 | gStatusCode = null; |
michael@0 | 61 | gStatusText = null; |
michael@0 | 62 | gCheckFunc = check_test_pt1; |
michael@0 | 63 | gExpectedStatusCode = 399; |
michael@0 | 64 | logTestInfo("testing default onerror error message"); |
michael@0 | 65 | gUpdateChecker.checkForUpdates(updateCheckListener, true); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | function check_test_pt1() { |
michael@0 | 69 | do_check_eq(gStatusCode, gExpectedStatusCode); |
michael@0 | 70 | var expectedStatusText = getStatusText(404); |
michael@0 | 71 | do_check_eq(gStatusText, expectedStatusText); |
michael@0 | 72 | run_test_pt2(); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | // file malformed - 200 |
michael@0 | 76 | function run_test_pt2() { |
michael@0 | 77 | run_test_helper(run_test_pt3, 200, |
michael@0 | 78 | "testing file malformed"); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | // access denied - 403 |
michael@0 | 82 | function run_test_pt3() { |
michael@0 | 83 | run_test_helper(run_test_pt4, 403, |
michael@0 | 84 | "testing access denied"); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | // file not found - 404 |
michael@0 | 88 | function run_test_pt4() { |
michael@0 | 89 | run_test_helper(run_test_pt5, 404, |
michael@0 | 90 | "testing file not found"); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | // internal server error - 500 |
michael@0 | 94 | function run_test_pt5() { |
michael@0 | 95 | run_test_helper(run_test_pt6, 500, |
michael@0 | 96 | "testing internal server error"); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | // failed (unknown reason) - NS_BINDING_FAILED (2152398849) |
michael@0 | 100 | function run_test_pt6() { |
michael@0 | 101 | run_test_helper(run_test_pt7, AUS_Cr.NS_BINDING_FAILED, |
michael@0 | 102 | "testing failed (unknown reason)"); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | // connection timed out - NS_ERROR_NET_TIMEOUT (2152398862) |
michael@0 | 106 | function run_test_pt7() { |
michael@0 | 107 | run_test_helper(run_test_pt8, AUS_Cr.NS_ERROR_NET_TIMEOUT, |
michael@0 | 108 | "testing connection timed out"); |
michael@0 | 109 | } |
michael@0 | 110 | |
michael@0 | 111 | // network offline - NS_ERROR_OFFLINE (2152398864) |
michael@0 | 112 | function run_test_pt8() { |
michael@0 | 113 | run_test_helper(run_test_pt9, AUS_Cr.NS_ERROR_OFFLINE, |
michael@0 | 114 | "testing network offline"); |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | // port not allowed - NS_ERROR_PORT_ACCESS_NOT_ALLOWED (2152398867) |
michael@0 | 118 | function run_test_pt9() { |
michael@0 | 119 | run_test_helper(run_test_pt10, AUS_Cr.NS_ERROR_PORT_ACCESS_NOT_ALLOWED, |
michael@0 | 120 | "testing port not allowed"); |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | // no data was received - NS_ERROR_NET_RESET (2152398868) |
michael@0 | 124 | function run_test_pt10() { |
michael@0 | 125 | run_test_helper(run_test_pt11, AUS_Cr.NS_ERROR_NET_RESET, |
michael@0 | 126 | "testing no data was received"); |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | // update server not found - NS_ERROR_UNKNOWN_HOST (2152398878) |
michael@0 | 130 | function run_test_pt11() { |
michael@0 | 131 | run_test_helper(run_test_pt12, AUS_Cr.NS_ERROR_UNKNOWN_HOST, |
michael@0 | 132 | "testing update server not found"); |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | // proxy server not found - NS_ERROR_UNKNOWN_PROXY_HOST (2152398890) |
michael@0 | 136 | function run_test_pt12() { |
michael@0 | 137 | run_test_helper(run_test_pt13, AUS_Cr.NS_ERROR_UNKNOWN_PROXY_HOST, |
michael@0 | 138 | "testing proxy server not found"); |
michael@0 | 139 | } |
michael@0 | 140 | |
michael@0 | 141 | // data transfer interrupted - NS_ERROR_NET_INTERRUPT (2152398919) |
michael@0 | 142 | function run_test_pt13() { |
michael@0 | 143 | run_test_helper(run_test_pt14, AUS_Cr.NS_ERROR_NET_INTERRUPT, |
michael@0 | 144 | "testing data transfer interrupted"); |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | // proxy server connection refused - NS_ERROR_PROXY_CONNECTION_REFUSED (2152398920) |
michael@0 | 148 | function run_test_pt14() { |
michael@0 | 149 | run_test_helper(run_test_pt15, AUS_Cr.NS_ERROR_PROXY_CONNECTION_REFUSED, |
michael@0 | 150 | "testing proxy server connection refused"); |
michael@0 | 151 | } |
michael@0 | 152 | |
michael@0 | 153 | // server certificate expired - 2153390069 |
michael@0 | 154 | function run_test_pt15() { |
michael@0 | 155 | run_test_helper(run_test_pt16, 2153390069, |
michael@0 | 156 | "testing server certificate expired"); |
michael@0 | 157 | } |
michael@0 | 158 | |
michael@0 | 159 | // network is offline - NS_ERROR_DOCUMENT_NOT_CACHED (2152398918) |
michael@0 | 160 | function run_test_pt16() { |
michael@0 | 161 | run_test_helper(run_test_pt17, AUS_Cr.NS_ERROR_DOCUMENT_NOT_CACHED, |
michael@0 | 162 | "testing network is offline"); |
michael@0 | 163 | } |
michael@0 | 164 | |
michael@0 | 165 | // connection refused - NS_ERROR_CONNECTION_REFUSED (2152398861) |
michael@0 | 166 | function run_test_pt17() { |
michael@0 | 167 | run_test_helper(doTestFinish, AUS_Cr.NS_ERROR_CONNECTION_REFUSED, |
michael@0 | 168 | "testing connection refused"); |
michael@0 | 169 | } |