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.
1 // |reftest| skip-if(!xulRuntime.shell)
2 // -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 // Any copyright is dedicated to the Public Domain.
4 // http://creativecommons.org/licenses/publicdomain/
6 function assertThrows(f) {
7 var ok = false;
8 try {
9 f();
10 } catch (exc) {
11 ok = true;
12 }
13 if (!ok)
14 throw new TypeError("Assertion failed: " + f + " did not throw as expected");
15 }
17 function byteArray(str) {
18 return [ c.charCodeAt(0) for (c of str.split('')) ];
19 }
21 // Don't allow forging bogus Date objects.
22 var mutated = byteArray(serialize(new Date(NaN)).clonebuffer);
24 var a = [1/0, -1/0,
25 Number.MIN_VALUE, -Number.MIN_VALUE,
26 Math.PI, 1286523948674.5,
27 Number.MAX_VALUE, -Number.MAX_VALUE,
28 8.64e15 + 1, -(8.64e15 + 1)];
29 for (var i = 0; i < a.length; i++) {
30 var n = a[i];
31 var nbuf = serialize(n);
32 var data = byteArray(nbuf.clonebuffer);
33 for (var j = 0; j < 8; j++)
34 mutated[j+8] = data[j];
35 nbuf.clonebuffer = String.fromCharCode.apply(null, mutated);
36 assertThrows(function () { deserialize(nbuf); });
37 }
39 reportCompare(0, 0);