js/src/tests/ecma_5/strict/unbrand-this.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 /* -*- 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 /* Test JSOP_UNBRANDTHIS's behavior on object and non-object |this| values. */
michael@0 9
michael@0 10 function strict() {
michael@0 11 "use strict";
michael@0 12 this.insert = function(){ bar(); };
michael@0 13 function bar() {}
michael@0 14 }
michael@0 15
michael@0 16 var exception;
michael@0 17
michael@0 18 // Try 'undefined' as a |this| value.
michael@0 19 exception = null;
michael@0 20 try {
michael@0 21 strict.call(undefined);
michael@0 22 } catch (x) {
michael@0 23 exception = x;
michael@0 24 }
michael@0 25 assertEq(exception instanceof TypeError, true);
michael@0 26
michael@0 27 // Try 'null' as a |this| value.
michael@0 28 exception = null;
michael@0 29 try {
michael@0 30 strict.call(null);
michael@0 31 } catch (x) {
michael@0 32 exception = x;
michael@0 33 }
michael@0 34 assertEq(exception instanceof TypeError, true);
michael@0 35
michael@0 36 // An object as a |this| value should be fine.
michael@0 37 exception = null;
michael@0 38 try {
michael@0 39 strict.call({});
michael@0 40 } catch (x) {
michael@0 41 exception = x;
michael@0 42 }
michael@0 43 assertEq(exception, null);
michael@0 44
michael@0 45 reportCompare(true, true);

mercurial