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 | function testBody() { |
michael@0 | 6 | |
michael@0 | 7 | setWatchdogEnabled(true); |
michael@0 | 8 | |
michael@0 | 9 | // It's unlikely that we've ever hibernated at this point, but the timestamps |
michael@0 | 10 | // default to 0, so this should always be true. |
michael@0 | 11 | var now = Date.now() * 1000; |
michael@0 | 12 | var startHibernation = Cu.getWatchdogTimestamp("WatchdogHibernateStart"); |
michael@0 | 13 | var stopHibernation = Cu.getWatchdogTimestamp("WatchdogHibernateStop"); |
michael@0 | 14 | do_log_info("Pre-hibernation statistics:"); |
michael@0 | 15 | do_log_info("now: " + now / 1000000); |
michael@0 | 16 | do_log_info("startHibernation: " + startHibernation / 1000000); |
michael@0 | 17 | do_log_info("stopHibernation: " + stopHibernation / 1000000); |
michael@0 | 18 | do_check_true(startHibernation < now); |
michael@0 | 19 | do_check_true(stopHibernation < now); |
michael@0 | 20 | |
michael@0 | 21 | // When the watchdog runs, it hibernates if there's been no activity for the |
michael@0 | 22 | // last 2 seconds, otherwise it sleeps for 1 second. As such, given perfect |
michael@0 | 23 | // scheduling, we should never have more than 3 seconds of inactivity without |
michael@0 | 24 | // hibernating. To add some padding for automation, we mandate that hibernation |
michael@0 | 25 | // must begin between 2 and 5 seconds from now. |
michael@0 | 26 | var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); |
michael@0 | 27 | timer.initWithCallback(continueTest, 10000, Ci.nsITimer.TYPE_ONE_SHOT); |
michael@0 | 28 | simulateActivityCallback(false); |
michael@0 | 29 | yield; |
michael@0 | 30 | |
michael@0 | 31 | simulateActivityCallback(true); |
michael@0 | 32 | busyWait(1000); // Give the watchdog time to wake up on the condvar. |
michael@0 | 33 | var stateChange = Cu.getWatchdogTimestamp("RuntimeStateChange"); |
michael@0 | 34 | startHibernation = Cu.getWatchdogTimestamp("WatchdogHibernateStart"); |
michael@0 | 35 | stopHibernation = Cu.getWatchdogTimestamp("WatchdogHibernateStop"); |
michael@0 | 36 | do_log_info("Post-hibernation statistics:"); |
michael@0 | 37 | do_log_info("stateChange: " + stateChange / 1000000); |
michael@0 | 38 | do_log_info("startHibernation: " + startHibernation / 1000000); |
michael@0 | 39 | do_log_info("stopHibernation: " + stopHibernation / 1000000); |
michael@0 | 40 | // XPCOM timers, JS times, and PR_Now() are apparently not directly |
michael@0 | 41 | // comparable, as evidenced by certain seemingly-impossible timing values |
michael@0 | 42 | // that occasionally get logged in windows automation. We're really just |
michael@0 | 43 | // making sure this behavior is roughly as expected on the macro scale, |
michael@0 | 44 | // so we add a 1 second fuzz factor here. |
michael@0 | 45 | const FUZZ_FACTOR = 1 * 1000 * 1000; |
michael@0 | 46 | do_check_true(stateChange > now + 10*1000*1000 - FUZZ_FACTOR); |
michael@0 | 47 | do_check_true(startHibernation > now + 2*1000*1000 - FUZZ_FACTOR); |
michael@0 | 48 | do_check_true(startHibernation < now + 5*1000*1000 + FUZZ_FACTOR); |
michael@0 | 49 | do_check_true(stopHibernation > now + 10*1000*1000 - FUZZ_FACTOR); |
michael@0 | 50 | |
michael@0 | 51 | do_test_finished(); |
michael@0 | 52 | yield; |
michael@0 | 53 | } |