js/src/tests/ecma_5/extensions/nested-delete-name-in-evalcode.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 // |reftest| fails -- bug 604301, at a minimum
     2 // Any copyright is dedicated to the Public Domain.
     3 // http://creativecommons.org/licenses/publicdomain/
     5 //-----------------------------------------------------------------------------
     6 var BUGNUMBER = 616294;
     7 var summary =
     8   "|delete x| inside a function in eval code, where that eval code includes " +
     9   "|var x| at top level, actually does delete the binding for x";
    11 print(BUGNUMBER + ": " + summary);
    13 /**************
    14  * BEGIN TEST *
    15  **************/
    17 var f;
    19 function testOuterLet()
    20 {
    21   return eval("let x; (function() { return delete x; })");
    22 }
    24 f = testOuterLet();
    26 assertEq(f(), true); // configurable, so remove => true
    27 assertEq(f(), true); // not there => true (only non-configurable => false)
    30 function testOuterForLet()
    31 {
    32   return eval("for (let x; false; ); (function() { return delete x; })");
    33 }
    35 f = testOuterForLet();
    37 assertEq(f(), true); // not there => true (only non-configurable => false)
    40 function testOuterForInLet()
    41 {
    42   return eval("for (let x in {}); (function() { return delete x; })");
    43 }
    45 f = testOuterForInLet();
    47 assertEq(f(), true); // configurable, so remove => true
    48 assertEq(f(), true); // not there => true (only non-configurable => false)
    51 function testOuterNestedVarInLetBlock()
    52 {
    53   return eval("let (x = 7) { var x = 9; } (function() { return delete x; })");
    54 }
    56 f = testOuterNestedVarInLetBlock();
    58 assertEq(f(), true); // configurable var, so remove => true
    59 assertEq(f(), true); // let still there, configurable => true
    60 assertEq(f(), true); // nothing at all => true
    63 function testOuterNestedVarInForLet()
    64 {
    65   return eval("for (let q = 0; q < 5; q++) { var x; } (function() { return delete x; })");
    66 }
    68 f = testOuterNestedVarInForLet();
    70 assertEq(f(), true); // configurable, so remove => true
    71 assertEq(f(), true); // there => true
    74 function testArgumentShadowLet()
    75 {
    76   return eval("let x; (function(x) { return delete x; })");
    77 }
    79 f = testArgumentShadowLet();
    81 assertEq(f(), false); // non-configurable argument => false
    84 function testFunctionLocal()
    85 {
    86   return eval("(function() { let x; return delete x; })");
    87 }
    89 f = testFunctionLocal();
    91 assertEq(f(), false); // defined by function code => not configurable => false
    94 /******************************************************************************/
    96 if (typeof reportCompare === "function")
    97   reportCompare(true, true);
    99 print("All tests passed!");

mercurial