js/src/tests/ecma_5/strict/15.4.5.1.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 var out = {};
    10 function arr() {
    11   return Object.defineProperty([1, 2, 3, 4], 2, {configurable: false});
    12 }
    14 function nonStrict1(out)
    15 {
    16   var a = out.array = arr();
    17   a.length = 2;
    18 }
    20 function strict1(out)
    21 {
    22   "use strict";
    23   var a = out.array = arr();
    24   a.length = 2;
    25   return a;
    26 }
    28 out.array = null;
    29 nonStrict1(out);
    30 assertEq(deepEqual(out.array, [1, 2, 3]), true);
    32 out.array = null;
    33 try
    34 {
    35   strict1(out);
    36   throw "no error";
    37 }
    38 catch (e)
    39 {
    40   assertEq(e instanceof TypeError, true, "expected TypeError, got " + e);
    41 }
    42 assertEq(deepEqual(out.array, [1, 2, 3]), true);
    44 // Internally, SpiderMonkey has two representations for arrays:
    45 // fast-but-inflexible, and slow-but-flexible. Adding a non-index property
    46 // to an array turns it into the latter. We should test on both kinds.
    47 function addx(obj) {
    48   obj.x = 5;
    49   return obj;
    50 }
    52 function nonStrict2(out)
    53 {
    54   var a = out.array = addx(arr());
    55   a.length = 2;
    56 }
    58 function strict2(out)
    59 {
    60   "use strict";
    61   var a = out.array = addx(arr());
    62   a.length = 2;
    63 }
    65 out.array = null;
    66 nonStrict2(out);
    67 assertEq(deepEqual(out.array, addx([1, 2, 3])), true);
    69 out.array = null;
    70 try
    71 {
    72   strict2(out);
    73   throw "no error";
    74 }
    75 catch (e)
    76 {
    77   assertEq(e instanceof TypeError, true, "expected TypeError, got " + e);
    78 }
    79 assertEq(deepEqual(out.array, addx([1, 2, 3])), true);
    81 if (typeof reportCompare === "function")
    82   reportCompare(true, true);
    84 print("Tests complete");

mercurial