js/src/tests/js1_8_1/extensions/strict-warning.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 // Turn on strict mode and warnings-as-errors mode.
michael@0 2 if (options().split().indexOf('strict') == -1)
michael@0 3 options('strict');
michael@0 4 if (options().split().indexOf('werror') == -1)
michael@0 5 options('werror');
michael@0 6
michael@0 7 function expectSyntaxError(stmt) {
michael@0 8 print(stmt);
michael@0 9 var result = 'no error';
michael@0 10 try {
michael@0 11 Function(stmt);
michael@0 12 } catch (exc) {
michael@0 13 result = exc.constructor.name;
michael@0 14 }
michael@0 15 assertEq(result, 'SyntaxError');
michael@0 16 }
michael@0 17
michael@0 18 function test(expr) {
michael@0 19 // Without extra parentheses, expect an error.
michael@0 20 expectSyntaxError('if (' + expr + ') {};');
michael@0 21
michael@0 22 // Extra parentheses silence the warning/error.
michael@0 23 Function('if ((' + expr + ')) {};');
michael@0 24 }
michael@0 25
michael@0 26 // Overparenthesized assignment in a condition should not be a strict error.
michael@0 27 test('a = 0');
michael@0 28 test('a = (f(), g)');
michael@0 29 test('a = b || c > d');
michael@0 30 expectSyntaxError('if (a == 0);');
michael@0 31 reportCompare('passed', 'passed', 'Overparenthesized assignment in a condition should not be a strict error.');
michael@0 32

mercurial