js/src/jit-test/tests/collections/Map-get.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 // Map.prototype.get and .has basically work
michael@0 2 var m = new Map;
michael@0 3
michael@0 4 function rope() {
michael@0 5 var s = "s";
michael@0 6 for (var i = 0; i < 16; i++)
michael@0 7 s += s;
michael@0 8 return s;
michael@0 9 }
michael@0 10
michael@0 11 var keys = [undefined, null, true, false,
michael@0 12 0, 1, 65535, 65536, 2147483647, 2147483648, 4294967295, 4294967296,
michael@0 13 -1, -65536, -2147483648,
michael@0 14 0.5, Math.sqrt(81), Math.PI,
michael@0 15 Number.MAX_VALUE, -Number.MAX_VALUE, Number.MIN_VALUE, -Number.MIN_VALUE,
michael@0 16 NaN, Infinity, -Infinity,
michael@0 17 "", "\0", "a", "ab", "abcdefg", rope(),
michael@0 18 {}, [], /a*b/, Object.prototype, Object];
michael@0 19
michael@0 20 for (var i = 0; i < keys.length; i++) {
michael@0 21 // without being set
michael@0 22 var key = keys[i];
michael@0 23 assertEq(m.has(key), false);
michael@0 24 assertEq(m.get(key), undefined);
michael@0 25
michael@0 26 // after being set
michael@0 27 var v = {};
michael@0 28 assertEq(m.set(key, v), undefined);
michael@0 29 assertEq(m.has(key), true);
michael@0 30 assertEq(m.get(key), v);
michael@0 31
michael@0 32 // after being deleted
michael@0 33 assertEq(m.delete(key), true);
michael@0 34 assertEq(m.has(key), false);
michael@0 35 assertEq(m.get(key), undefined);
michael@0 36
michael@0 37 m.set(key, v);
michael@0 38 }
michael@0 39
michael@0 40 for (var i = 0; i < keys.length; i++)
michael@0 41 assertEq(m.has(keys[i]), true);

mercurial