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.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     3 /*
     4  * Any copyright is dedicated to the Public Domain.
     5  * http://creativecommons.org/licenses/publicdomain/
     6  */
     8 /* Test JSOP_UNBRANDTHIS's behavior on object and non-object |this| values. */
    10 function strict() {
    11   "use strict";
    12   this.insert = function(){ bar(); };
    13   function bar() {}
    14 }
    16 var exception;
    18 // Try 'undefined' as a |this| value.
    19 exception = null;
    20 try {
    21   strict.call(undefined);
    22 } catch (x) {
    23   exception = x;
    24 }
    25 assertEq(exception instanceof TypeError, true);
    27 // Try 'null' as a |this| value.
    28 exception = null;
    29 try {
    30   strict.call(null);
    31 } catch (x) {
    32   exception = x;
    33 }
    34 assertEq(exception instanceof TypeError, true);
    36 // An object as a |this| value should be fine.
    37 exception = null;
    38 try {
    39   strict.call({});
    40 } catch (x) {
    41   exception = x;
    42 }
    43 assertEq(exception, null);
    45 reportCompare(true, true);

mercurial