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 | /* |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 4 | * Contributor: |
michael@0 | 5 | * Andreas Gal <gal@mozilla.com> |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | //----------------------------------------------------------------------------- |
michael@0 | 9 | var BUGNUMBER = 547941; |
michael@0 | 10 | var summary = 'js weak maps'; |
michael@0 | 11 | var actual = ''; |
michael@0 | 12 | var expect = ''; |
michael@0 | 13 | |
michael@0 | 14 | //----------------------------------------------------------------------------- |
michael@0 | 15 | test(); |
michael@0 | 16 | //----------------------------------------------------------------------------- |
michael@0 | 17 | |
michael@0 | 18 | function test() |
michael@0 | 19 | { |
michael@0 | 20 | enterFunc ('test'); |
michael@0 | 21 | printBugNumber(BUGNUMBER); |
michael@0 | 22 | printStatus(summary); |
michael@0 | 23 | |
michael@0 | 24 | var TestPassCount = 0; |
michael@0 | 25 | var TestFailCount = 0; |
michael@0 | 26 | var TestTodoCount = 0; |
michael@0 | 27 | |
michael@0 | 28 | var TODO = 1; |
michael@0 | 29 | |
michael@0 | 30 | function check(fun, todo) { |
michael@0 | 31 | var thrown = null; |
michael@0 | 32 | var success = false; |
michael@0 | 33 | try { |
michael@0 | 34 | success = fun(); |
michael@0 | 35 | } catch (x) { |
michael@0 | 36 | thrown = x; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | if (thrown) |
michael@0 | 40 | success = false; |
michael@0 | 41 | |
michael@0 | 42 | if (todo) { |
michael@0 | 43 | TestTodoCount++; |
michael@0 | 44 | |
michael@0 | 45 | if (success) { |
michael@0 | 46 | var ex = new Error; |
michael@0 | 47 | print ("=== TODO but PASSED? ==="); |
michael@0 | 48 | print (ex.stack); |
michael@0 | 49 | print ("========================"); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | return; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | if (success) { |
michael@0 | 56 | TestPassCount++; |
michael@0 | 57 | } else { |
michael@0 | 58 | TestFailCount++; |
michael@0 | 59 | |
michael@0 | 60 | var ex = new Error; |
michael@0 | 61 | print ("=== FAILED ==="); |
michael@0 | 62 | print (ex.stack); |
michael@0 | 63 | if (thrown) { |
michael@0 | 64 | print (" threw exception:"); |
michael@0 | 65 | print (thrown); |
michael@0 | 66 | } |
michael@0 | 67 | print ("=============="); |
michael@0 | 68 | } |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | function checkThrows(fun, todo) { |
michael@0 | 72 | let thrown = false; |
michael@0 | 73 | try { |
michael@0 | 74 | fun(); |
michael@0 | 75 | } catch (x) { |
michael@0 | 76 | thrown = true; |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | check(function() thrown, todo); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | var key = {}; |
michael@0 | 83 | var map = WeakMap(); |
michael@0 | 84 | |
michael@0 | 85 | check(function() !map.has(key)); |
michael@0 | 86 | map.set(key, 42); |
michael@0 | 87 | check(function() map.get(key) == 42); |
michael@0 | 88 | check(function() typeof map.get({}) == "undefined"); |
michael@0 | 89 | check(function() map.get({}, "foo") == "foo"); |
michael@0 | 90 | |
michael@0 | 91 | gc(); gc(); gc(); |
michael@0 | 92 | |
michael@0 | 93 | check(function() map.get(key) == 42); |
michael@0 | 94 | map.delete(key); |
michael@0 | 95 | check(function() typeof map.get(key) == "undefined"); |
michael@0 | 96 | check(function() !map.has(key)); |
michael@0 | 97 | |
michael@0 | 98 | var value = { }; |
michael@0 | 99 | map.set(new Object(), value); |
michael@0 | 100 | gc(); gc(); gc(); |
michael@0 | 101 | |
michael@0 | 102 | print ("done"); |
michael@0 | 103 | |
michael@0 | 104 | reportCompare(0, TestFailCount, "weak map tests"); |
michael@0 | 105 | |
michael@0 | 106 | exitFunc ('test'); |
michael@0 | 107 | } |