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.

michael@0 1 // |reftest| fails -- bug 604301, at a minimum
michael@0 2 // Any copyright is dedicated to the Public Domain.
michael@0 3 // http://creativecommons.org/licenses/publicdomain/
michael@0 4
michael@0 5 //-----------------------------------------------------------------------------
michael@0 6 var BUGNUMBER = 616294;
michael@0 7 var summary =
michael@0 8 "|delete x| inside a function in eval code, where that eval code includes " +
michael@0 9 "|var x| at top level, actually does delete the binding for x";
michael@0 10
michael@0 11 print(BUGNUMBER + ": " + summary);
michael@0 12
michael@0 13 /**************
michael@0 14 * BEGIN TEST *
michael@0 15 **************/
michael@0 16
michael@0 17 var f;
michael@0 18
michael@0 19 function testOuterLet()
michael@0 20 {
michael@0 21 return eval("let x; (function() { return delete x; })");
michael@0 22 }
michael@0 23
michael@0 24 f = testOuterLet();
michael@0 25
michael@0 26 assertEq(f(), true); // configurable, so remove => true
michael@0 27 assertEq(f(), true); // not there => true (only non-configurable => false)
michael@0 28
michael@0 29
michael@0 30 function testOuterForLet()
michael@0 31 {
michael@0 32 return eval("for (let x; false; ); (function() { return delete x; })");
michael@0 33 }
michael@0 34
michael@0 35 f = testOuterForLet();
michael@0 36
michael@0 37 assertEq(f(), true); // not there => true (only non-configurable => false)
michael@0 38
michael@0 39
michael@0 40 function testOuterForInLet()
michael@0 41 {
michael@0 42 return eval("for (let x in {}); (function() { return delete x; })");
michael@0 43 }
michael@0 44
michael@0 45 f = testOuterForInLet();
michael@0 46
michael@0 47 assertEq(f(), true); // configurable, so remove => true
michael@0 48 assertEq(f(), true); // not there => true (only non-configurable => false)
michael@0 49
michael@0 50
michael@0 51 function testOuterNestedVarInLetBlock()
michael@0 52 {
michael@0 53 return eval("let (x = 7) { var x = 9; } (function() { return delete x; })");
michael@0 54 }
michael@0 55
michael@0 56 f = testOuterNestedVarInLetBlock();
michael@0 57
michael@0 58 assertEq(f(), true); // configurable var, so remove => true
michael@0 59 assertEq(f(), true); // let still there, configurable => true
michael@0 60 assertEq(f(), true); // nothing at all => true
michael@0 61
michael@0 62
michael@0 63 function testOuterNestedVarInForLet()
michael@0 64 {
michael@0 65 return eval("for (let q = 0; q < 5; q++) { var x; } (function() { return delete x; })");
michael@0 66 }
michael@0 67
michael@0 68 f = testOuterNestedVarInForLet();
michael@0 69
michael@0 70 assertEq(f(), true); // configurable, so remove => true
michael@0 71 assertEq(f(), true); // there => true
michael@0 72
michael@0 73
michael@0 74 function testArgumentShadowLet()
michael@0 75 {
michael@0 76 return eval("let x; (function(x) { return delete x; })");
michael@0 77 }
michael@0 78
michael@0 79 f = testArgumentShadowLet();
michael@0 80
michael@0 81 assertEq(f(), false); // non-configurable argument => false
michael@0 82
michael@0 83
michael@0 84 function testFunctionLocal()
michael@0 85 {
michael@0 86 return eval("(function() { let x; return delete x; })");
michael@0 87 }
michael@0 88
michael@0 89 f = testFunctionLocal();
michael@0 90
michael@0 91 assertEq(f(), false); // defined by function code => not configurable => false
michael@0 92
michael@0 93
michael@0 94 /******************************************************************************/
michael@0 95
michael@0 96 if (typeof reportCompare === "function")
michael@0 97 reportCompare(true, true);
michael@0 98
michael@0 99 print("All tests passed!");

mercurial