js/src/tests/js1_8_5/extensions/destructure-accessor.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 // Any copyright is dedicated to the Public Domain.
michael@0 2 // http://creativecommons.org/licenses/publicdomain/
michael@0 3
michael@0 4 var gTestfile = 'destructure-accessor.js';
michael@0 5 //-----------------------------------------------------------------------------
michael@0 6 var BUGNUMBER = 536472;
michael@0 7 var summary =
michael@0 8 'ES5: { get x(v) { } } and { set x(v, v2) { } } should be syntax errors';
michael@0 9
michael@0 10 print(BUGNUMBER + ": " + summary);
michael@0 11
michael@0 12 //-----------------------------------------------------------------------------
michael@0 13
michael@0 14 function expectOk(s)
michael@0 15 {
michael@0 16 try
michael@0 17 {
michael@0 18 eval(s);
michael@0 19 return;
michael@0 20 }
michael@0 21 catch (e)
michael@0 22 {
michael@0 23 assertEq(true, false,
michael@0 24 "expected no error parsing '" + "', got : " + e);
michael@0 25 }
michael@0 26 }
michael@0 27
michael@0 28 function expectSyntaxError(s)
michael@0 29 {
michael@0 30 try
michael@0 31 {
michael@0 32 eval(s);
michael@0 33 throw new Error("no error thrown");
michael@0 34 }
michael@0 35 catch (e)
michael@0 36 {
michael@0 37 assertEq(e instanceof SyntaxError, true,
michael@0 38 "expected syntax error parsing '" + s + "', got: " + e);
michael@0 39 }
michael@0 40 }
michael@0 41
michael@0 42 expectSyntaxError("({ get x([]) { } })");
michael@0 43 expectSyntaxError("({ get x({}) { } })");
michael@0 44 expectSyntaxError("({ get x(a, []) { } })");
michael@0 45 expectSyntaxError("({ get x(a, {}) { } })");
michael@0 46 expectSyntaxError("({ get x([], a) { } })");
michael@0 47 expectSyntaxError("({ get x({}, a) { } })");
michael@0 48 expectSyntaxError("({ get x([], a, []) { } })");
michael@0 49 expectSyntaxError("({ get x([], a, {}) { } })");
michael@0 50 expectSyntaxError("({ get x({}, a, []) { } })");
michael@0 51 expectSyntaxError("({ get x({}, a, {}) { } })");
michael@0 52
michael@0 53 expectOk("({ get x() { } })");
michael@0 54
michael@0 55
michael@0 56 expectSyntaxError("({ set x() { } })");
michael@0 57 expectSyntaxError("({ set x(a, []) { } })");
michael@0 58 expectSyntaxError("({ set x(a, b, c) { } })");
michael@0 59
michael@0 60 expectOk("({ set x([]) { } })");
michael@0 61 expectOk("({ set x({}) { } })");
michael@0 62 expectOk("({ set x([a]) { } })");
michael@0 63 expectOk("({ set x([a, b]) { } })");
michael@0 64 expectOk("({ set x([a,]) { } })");
michael@0 65 expectOk("({ set x([a, b,]) { } })");
michael@0 66 expectOk("({ set x([, b]) { } })");
michael@0 67 expectOk("({ set x([, b,]) { } })");
michael@0 68 expectOk("({ set x([, b, c]) { } })");
michael@0 69 expectOk("({ set x([, b, c,]) { } })");
michael@0 70 expectOk("({ set x({ a: a }) { } })");
michael@0 71 expectOk("({ set x({ a: a, b: b }) { } })");
michael@0 72
michael@0 73 //-----------------------------------------------------------------------------
michael@0 74
michael@0 75 reportCompare(true, true);

mercurial