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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | // Test the basic functionality of the nsIJSInspector component. |
michael@0 | 5 | var gCount = 0; |
michael@0 | 6 | const MAX = 10; |
michael@0 | 7 | var inspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector); |
michael@0 | 8 | var tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager); |
michael@0 | 9 | |
michael@0 | 10 | // Emulate 10 simultaneously-debugged windows from 3 separate client connections. |
michael@0 | 11 | var requestor = (count) => ({ |
michael@0 | 12 | url:"http://foo/bar/" + count, |
michael@0 | 13 | connection: "conn" + (count % 3) |
michael@0 | 14 | }); |
michael@0 | 15 | |
michael@0 | 16 | function run_test() |
michael@0 | 17 | { |
michael@0 | 18 | test_nesting(); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function test_nesting() |
michael@0 | 22 | { |
michael@0 | 23 | do_check_eq(inspector.eventLoopNestLevel, 0); |
michael@0 | 24 | |
michael@0 | 25 | tm.currentThread.dispatch({ run: enterEventLoop}, 0); |
michael@0 | 26 | |
michael@0 | 27 | do_check_eq(inspector.enterNestedEventLoop(requestor(gCount)), 0); |
michael@0 | 28 | do_check_eq(inspector.eventLoopNestLevel, 0); |
michael@0 | 29 | do_check_eq(inspector.lastNestRequestor, null); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function enterEventLoop() { |
michael@0 | 33 | if (gCount++ < MAX) { |
michael@0 | 34 | tm.currentThread.dispatch({ run: enterEventLoop}, 0); |
michael@0 | 35 | |
michael@0 | 36 | let r = Object.create(requestor(gCount)); |
michael@0 | 37 | |
michael@0 | 38 | do_check_eq(inspector.eventLoopNestLevel, gCount); |
michael@0 | 39 | do_check_eq(inspector.lastNestRequestor.url, requestor(gCount - 1).url); |
michael@0 | 40 | do_check_eq(inspector.lastNestRequestor.connection, requestor(gCount - 1).connection); |
michael@0 | 41 | do_check_eq(inspector.enterNestedEventLoop(requestor(gCount)), gCount); |
michael@0 | 42 | } else { |
michael@0 | 43 | do_check_eq(gCount, MAX + 1); |
michael@0 | 44 | tm.currentThread.dispatch({ run: exitEventLoop}, 0); |
michael@0 | 45 | } |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function exitEventLoop() { |
michael@0 | 49 | if (inspector.lastNestRequestor != null) { |
michael@0 | 50 | do_check_eq(inspector.lastNestRequestor.url, requestor(gCount - 1).url); |
michael@0 | 51 | do_check_eq(inspector.lastNestRequestor.connection, requestor(gCount - 1).connection); |
michael@0 | 52 | if (gCount-- > 1) { |
michael@0 | 53 | tm.currentThread.dispatch({ run: exitEventLoop}, 0); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | do_check_eq(inspector.exitNestedEventLoop(), gCount); |
michael@0 | 57 | do_check_eq(inspector.eventLoopNestLevel, gCount); |
michael@0 | 58 | } |
michael@0 | 59 | } |