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 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | |
michael@0 | 3 | /* |
michael@0 | 4 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 5 | * http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | function isSyntaxError(code) { |
michael@0 | 9 | try { |
michael@0 | 10 | eval(code); |
michael@0 | 11 | return false; |
michael@0 | 12 | } catch (exception) { |
michael@0 | 13 | if (SyntaxError.prototype.isPrototypeOf(exception)) |
michael@0 | 14 | return true; |
michael@0 | 15 | throw exception; |
michael@0 | 16 | }; |
michael@0 | 17 | }; |
michael@0 | 18 | |
michael@0 | 19 | /* |
michael@0 | 20 | * Duplicate parameter names must be tolerated (as per ES3), unless |
michael@0 | 21 | * the parameter list uses destructuring, in which case we claim the |
michael@0 | 22 | * user has opted in to a modicum of sanity, and we forbid duplicate |
michael@0 | 23 | * parameter names. |
michael@0 | 24 | */ |
michael@0 | 25 | assertEq(isSyntaxError("function f(x,x){}"), false); |
michael@0 | 26 | |
michael@0 | 27 | assertEq(isSyntaxError("function f(x,[x]){})"), true); |
michael@0 | 28 | assertEq(isSyntaxError("function f(x,{y:x}){})"), true); |
michael@0 | 29 | assertEq(isSyntaxError("function f(x,{x}){})"), true); |
michael@0 | 30 | |
michael@0 | 31 | assertEq(isSyntaxError("function f([x],x){})"), true); |
michael@0 | 32 | assertEq(isSyntaxError("function f({y:x},x){})"), true); |
michael@0 | 33 | assertEq(isSyntaxError("function f({x},x){})"), true); |
michael@0 | 34 | |
michael@0 | 35 | assertEq(isSyntaxError("function f([x,x]){}"), true); |
michael@0 | 36 | assertEq(isSyntaxError("function f({x,x}){}"), true); |
michael@0 | 37 | assertEq(isSyntaxError("function f({y:x,z:x}){}"), true); |
michael@0 | 38 | |
michael@0 | 39 | assertEq(isSyntaxError("function f(x,x,[y]){}"), true); |
michael@0 | 40 | assertEq(isSyntaxError("function f(x,x,{y}){}"), true); |
michael@0 | 41 | assertEq(isSyntaxError("function f([y],x,x){}"), true); |
michael@0 | 42 | assertEq(isSyntaxError("function f({y},x,x){}"), true); |
michael@0 | 43 | |
michael@0 | 44 | assertEq(isSyntaxError("function f(a,b,c,d,e,f,g,h,b,[y]){}"), true); |
michael@0 | 45 | assertEq(isSyntaxError("function f([y],a,b,c,d,e,f,g,h,a){}"), true); |
michael@0 | 46 | assertEq(isSyntaxError("function f([a],b,c,d,e,f,g,h,i,a){}"), true); |
michael@0 | 47 | assertEq(isSyntaxError("function f(a,b,c,d,e,f,g,h,i,[a]){}"), true); |
michael@0 | 48 | assertEq(isSyntaxError("function f(a,b,c,d,e,f,g,h,i,[a]){}"), true); |
michael@0 | 49 | |
michael@0 | 50 | reportCompare(true, true); |