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 | // Pref management. |
michael@0 | 7 | // |
michael@0 | 8 | |
michael@0 | 9 | const Cc = Components.classes; |
michael@0 | 10 | const Ci = Components.interfaces; |
michael@0 | 11 | const Cu = Components.utils; |
michael@0 | 12 | |
michael@0 | 13 | var gPrefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); |
michael@0 | 14 | |
michael@0 | 15 | function setWatchdogEnabled(enabled) { |
michael@0 | 16 | gPrefs.setBoolPref("dom.use_watchdog", enabled); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | function isWatchdogEnabled() { |
michael@0 | 20 | return gPrefs.getBoolPref("dom.use_watchdog"); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | // |
michael@0 | 24 | // Utilities. |
michael@0 | 25 | // |
michael@0 | 26 | |
michael@0 | 27 | function busyWait(ms) { |
michael@0 | 28 | var start = new Date(); |
michael@0 | 29 | while ((new Date()) - start < ms) {} |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function do_log_info(aMessage) |
michael@0 | 33 | { |
michael@0 | 34 | print("TEST-INFO | " + _TEST_FILE + " | " + aMessage); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | // We don't use do_execute_soon, because that inserts a |
michael@0 | 38 | // do_test_{pending,finished} pair that gets screwed up when we terminate scripts |
michael@0 | 39 | // from the operation callback. |
michael@0 | 40 | function executeSoon(fn) { |
michael@0 | 41 | var tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager); |
michael@0 | 42 | tm.mainThread.dispatch({run: fn}, Ci.nsIThread.DISPATCH_NORMAL); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | // |
michael@0 | 46 | // Asynchronous watchdog diagnostics. |
michael@0 | 47 | // |
michael@0 | 48 | // When running, the watchdog wakes up every second, and fires the operation |
michael@0 | 49 | // callback if the script has been running for >= one second. As such, a script |
michael@0 | 50 | // should never be able to run for two seconds or longer without servicing the |
michael@0 | 51 | // operation callback. We wait 3 seconds, just to be safe. |
michael@0 | 52 | // |
michael@0 | 53 | |
michael@0 | 54 | function checkWatchdog(expectInterrupt, continuation) { |
michael@0 | 55 | var lastWatchdogWakeup = Cu.getWatchdogTimestamp("WatchdogWakeup"); |
michael@0 | 56 | setInterruptCallback(function() { |
michael@0 | 57 | // If the watchdog didn't actually trigger the operation callback, ignore |
michael@0 | 58 | // this call. This allows us to test the actual watchdog behavior without |
michael@0 | 59 | // interference from other sites where we trigger the operation callback. |
michael@0 | 60 | if (lastWatchdogWakeup == Cu.getWatchdogTimestamp("WatchdogWakeup")) { |
michael@0 | 61 | return true; |
michael@0 | 62 | } |
michael@0 | 63 | do_check_true(expectInterrupt); |
michael@0 | 64 | setInterruptCallback(undefined); |
michael@0 | 65 | // Schedule our continuation before we kill this script. |
michael@0 | 66 | executeSoon(continuation); |
michael@0 | 67 | return false; |
michael@0 | 68 | }); |
michael@0 | 69 | executeSoon(function() { |
michael@0 | 70 | busyWait(3000); |
michael@0 | 71 | do_check_true(!expectInterrupt); |
michael@0 | 72 | setInterruptCallback(undefined); |
michael@0 | 73 | continuation(); |
michael@0 | 74 | }); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | var gGenerator; |
michael@0 | 78 | function continueTest() { |
michael@0 | 79 | gGenerator.next(); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | function run_test() { |
michael@0 | 83 | |
michael@0 | 84 | // Run async. |
michael@0 | 85 | do_test_pending(); |
michael@0 | 86 | |
michael@0 | 87 | // Instantiate the generator and kick it off. |
michael@0 | 88 | gGenerator = testBody(); |
michael@0 | 89 | gGenerator.next(); |
michael@0 | 90 | } |
michael@0 | 91 |