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 | const Cc = Components.classes; |
michael@0 | 2 | const Ci = Components.interfaces; |
michael@0 | 3 | |
michael@0 | 4 | var timer; |
michael@0 | 5 | |
michael@0 | 6 | // This test XPConnect's ability to deal with a certain type of exception. In |
michael@0 | 7 | // particular, bug 641378 meant that if an exception had both 'message' and |
michael@0 | 8 | // 'result' properties, then it wouldn't successfully read the 'result' field |
michael@0 | 9 | // out of the exception (and sometimes crash). |
michael@0 | 10 | // |
michael@0 | 11 | // In order to make the test not fail completely on a negative result, we use |
michael@0 | 12 | // a timer. The first time through the timer, we throw our special exception. |
michael@0 | 13 | // Then, the second time through, we can test to see if XPConnect properly |
michael@0 | 14 | // dealt with our exception. |
michael@0 | 15 | var exception = { |
michael@0 | 16 | message: "oops, something failed!", |
michael@0 | 17 | |
michael@0 | 18 | tries: 0, |
michael@0 | 19 | get result() { |
michael@0 | 20 | ++this.tries; |
michael@0 | 21 | return 3; |
michael@0 | 22 | } |
michael@0 | 23 | }; |
michael@0 | 24 | |
michael@0 | 25 | var callback = { |
michael@0 | 26 | tries: 0, |
michael@0 | 27 | notify: function (timer) { |
michael@0 | 28 | if (++this.tries === 1) |
michael@0 | 29 | throw exception; |
michael@0 | 30 | |
michael@0 | 31 | try { |
michael@0 | 32 | do_check_true(exception.tries >= 1); |
michael@0 | 33 | } finally { |
michael@0 | 34 | timer.cancel(); |
michael@0 | 35 | timer = null; |
michael@0 | 36 | do_test_finished(); |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | }; |
michael@0 | 40 | |
michael@0 | 41 | function run_test() { |
michael@0 | 42 | do_test_pending(); |
michael@0 | 43 | |
michael@0 | 44 | timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); |
michael@0 | 45 | timer.initWithCallback(callback, 0, timer.TYPE_REPEATING_SLACK); |
michael@0 | 46 | } |