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 | * Jeff Walden <jwalden+code@mit.edu> |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | //----------------------------------------------------------------------------- |
michael@0 | 9 | var BUGNUMBER = 858381; |
michael@0 | 10 | var summary = |
michael@0 | 11 | "Array length redefinition behavior with non-configurable elements"; |
michael@0 | 12 | |
michael@0 | 13 | print(BUGNUMBER + ": " + summary); |
michael@0 | 14 | |
michael@0 | 15 | /************** |
michael@0 | 16 | * BEGIN TEST * |
michael@0 | 17 | **************/ |
michael@0 | 18 | |
michael@0 | 19 | function addDataProperty(obj, prop, value, enumerable, configurable, writable) |
michael@0 | 20 | { |
michael@0 | 21 | var desc = |
michael@0 | 22 | { enumerable: enumerable, |
michael@0 | 23 | configurable: configurable, |
michael@0 | 24 | writable: writable, |
michael@0 | 25 | value: value }; |
michael@0 | 26 | Object.defineProperty(obj, prop, desc); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function nonstrict() |
michael@0 | 30 | { |
michael@0 | 31 | var arr = [0, , 2, , , 5]; |
michael@0 | 32 | |
michael@0 | 33 | addDataProperty(arr, 31415926, "foo", true, true, true); |
michael@0 | 34 | addDataProperty(arr, 123456789, "bar", true, true, false); |
michael@0 | 35 | addDataProperty(arr, 8675309, "qux", false, true, true); |
michael@0 | 36 | addDataProperty(arr, 1735039, "eit", false, true, false); |
michael@0 | 37 | addDataProperty(arr, 987654321, "fun", false, true, false); |
michael@0 | 38 | |
michael@0 | 39 | // non-array indexes to spice things up |
michael@0 | 40 | addDataProperty(arr, "foopy", "sdfsd", false, false, false); |
michael@0 | 41 | addDataProperty(arr, 4294967296, "psych", true, false, false); |
michael@0 | 42 | addDataProperty(arr, 4294967295, "psych", true, false, false); |
michael@0 | 43 | |
michael@0 | 44 | addDataProperty(arr, 27182818, "eep", false, false, false); |
michael@0 | 45 | |
michael@0 | 46 | // Truncate...but only as far as possible. |
michael@0 | 47 | arr.length = 1; |
michael@0 | 48 | |
michael@0 | 49 | assertEq(arr.length, 27182819); |
michael@0 | 50 | |
michael@0 | 51 | var props = Object.getOwnPropertyNames(arr).sort(); |
michael@0 | 52 | var expected = |
michael@0 | 53 | ["0", "2", "5", "1735039", "8675309", "27182818", |
michael@0 | 54 | "foopy", "4294967296", "4294967295", "length"].sort(); |
michael@0 | 55 | |
michael@0 | 56 | assertEq(props.length, expected.length); |
michael@0 | 57 | for (var i = 0; i < props.length; i++) |
michael@0 | 58 | assertEq(props[i], expected[i], "unexpected property: " + props[i]); |
michael@0 | 59 | } |
michael@0 | 60 | nonstrict(); |
michael@0 | 61 | |
michael@0 | 62 | function strict() |
michael@0 | 63 | { |
michael@0 | 64 | "use strict"; |
michael@0 | 65 | |
michael@0 | 66 | var arr = [0, , 2, , , 5]; |
michael@0 | 67 | |
michael@0 | 68 | addDataProperty(arr, 31415926, "foo", true, true, true); |
michael@0 | 69 | addDataProperty(arr, 123456789, "bar", true, true, false); |
michael@0 | 70 | addDataProperty(arr, 8675309, "qux", false, true, true); |
michael@0 | 71 | addDataProperty(arr, 1735039, "eit", false, true, false); |
michael@0 | 72 | addDataProperty(arr, 987654321, "fun", false, true, false); |
michael@0 | 73 | |
michael@0 | 74 | // non-array indexes to spice things up |
michael@0 | 75 | addDataProperty(arr, "foopy", "sdfsd", false, false, false); |
michael@0 | 76 | addDataProperty(arr, 4294967296, "psych", true, false, false); |
michael@0 | 77 | addDataProperty(arr, 4294967295, "psych", true, false, false); |
michael@0 | 78 | |
michael@0 | 79 | addDataProperty(arr, 27182818, "eep", false, false, false); |
michael@0 | 80 | |
michael@0 | 81 | try |
michael@0 | 82 | { |
michael@0 | 83 | arr.length = 1; |
michael@0 | 84 | throw new Error("didn't throw?!"); |
michael@0 | 85 | } |
michael@0 | 86 | catch (e) |
michael@0 | 87 | { |
michael@0 | 88 | assertEq(e instanceof TypeError, true, |
michael@0 | 89 | "non-configurable property should trigger TypeError, got " + e); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | assertEq(arr.length, 27182819); |
michael@0 | 93 | |
michael@0 | 94 | var props = Object.getOwnPropertyNames(arr).sort(); |
michael@0 | 95 | var expected = |
michael@0 | 96 | ["0", "2", "5", "1735039", "8675309", "27182818", |
michael@0 | 97 | "foopy", "4294967296", "4294967295", "length"].sort(); |
michael@0 | 98 | |
michael@0 | 99 | assertEq(props.length, expected.length); |
michael@0 | 100 | for (var i = 0; i < props.length; i++) |
michael@0 | 101 | assertEq(props[i], expected[i], "unexpected property: " + props[i]); |
michael@0 | 102 | } |
michael@0 | 103 | strict(); |
michael@0 | 104 | |
michael@0 | 105 | /******************************************************************************/ |
michael@0 | 106 | |
michael@0 | 107 | if (typeof reportCompare === "function") |
michael@0 | 108 | reportCompare(true, true); |
michael@0 | 109 | |
michael@0 | 110 | print("Tests complete"); |