js/src/tests/ecma/ExecutionContexts/10.1.3.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 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 File Name: 10.1.3.js
michael@0 9 ECMA Section: 10.1.3.js Variable Instantiation
michael@0 10 Description:
michael@0 11 Author: christine@netscape.com
michael@0 12 Date: 11 september 1997
michael@0 13 */
michael@0 14
michael@0 15 var SECTION = "10.1.3";
michael@0 16 var VERSION = "ECMA_1";
michael@0 17 var TITLE = "Variable instantiation";
michael@0 18 var BUGNUMBER = "20256";
michael@0 19 startTest();
michael@0 20
michael@0 21 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 22
michael@0 23
michael@0 24 // overriding a variable or function name with a function should succeed
michael@0 25
michael@0 26 new TestCase(SECTION,
michael@0 27 "function t() { return \"first\" };" +
michael@0 28 "function t() { return \"second\" };t() ",
michael@0 29 "second",
michael@0 30 eval("function t() { return \"first\" };" +
michael@0 31 "function t() { return \"second\" };t()"));
michael@0 32
michael@0 33
michael@0 34 new TestCase(SECTION,
michael@0 35 "var t; function t(){}; typeof(t)",
michael@0 36 "function",
michael@0 37 eval("var t; function t(){}; typeof(t)"));
michael@0 38
michael@0 39
michael@0 40 // formal parameter tests
michael@0 41
michael@0 42 new TestCase(SECTION,
michael@0 43 "function t1(a,b) { return b; }; t1( 4 );",
michael@0 44 void 0,
michael@0 45 eval("function t1(a,b) { return b; }; t1( 4 );") );
michael@0 46
michael@0 47 new TestCase(SECTION,
michael@0 48 "function t1(a,b) { return a; }; t1(4);",
michael@0 49 4,
michael@0 50 eval("function t1(a,b) { return a; }; t1(4)"));
michael@0 51
michael@0 52 new TestCase(SECTION,
michael@0 53 "function t1(a,b) { return a; }; t1();",
michael@0 54 void 0,
michael@0 55 eval("function t1(a,b) { return a; }; t1()"));
michael@0 56
michael@0 57 new TestCase(SECTION,
michael@0 58 "function t1(a,b) { return a; }; t1(1,2,4);",
michael@0 59 1,
michael@0 60 eval("function t1(a,b) { return a; }; t1(1,2,4)"));
michael@0 61 /*
michael@0 62
michael@0 63 new TestCase(SECTION, "function t1(a,a) { return a; }; t1( 4 );",
michael@0 64 void 0,
michael@0 65 eval("function t1(a,a) { return a; }; t1( 4 )"));
michael@0 66
michael@0 67 new TestCase(SECTION,
michael@0 68 "function t1(a,a) { return a; }; t1( 1,2 );",
michael@0 69 2,
michael@0 70 eval("function t1(a,a) { return a; }; t1( 1,2 )"));
michael@0 71 */
michael@0 72 // variable declarations
michael@0 73
michael@0 74 new TestCase(SECTION,
michael@0 75 "function t1(a,b) { return a; }; t1( false, true );",
michael@0 76 false,
michael@0 77 eval("function t1(a,b) { return a; }; t1( false, true );"));
michael@0 78
michael@0 79 new TestCase(SECTION,
michael@0 80 "function t1(a,b) { return b; }; t1( false, true );",
michael@0 81 true,
michael@0 82 eval("function t1(a,b) { return b; }; t1( false, true );"));
michael@0 83
michael@0 84 new TestCase(SECTION,
michael@0 85 "function t1(a,b) { return a+b; }; t1( 4, 2 );",
michael@0 86 6,
michael@0 87 eval("function t1(a,b) { return a+b; }; t1( 4, 2 );"));
michael@0 88
michael@0 89 new TestCase(SECTION,
michael@0 90 "function t1(a,b) { return a+b; }; t1( 4 );",
michael@0 91 Number.NaN,
michael@0 92 eval("function t1(a,b) { return a+b; }; t1( 4 );"));
michael@0 93
michael@0 94 // overriding a function name with a variable should fail
michael@0 95
michael@0 96 new TestCase(SECTION,
michael@0 97 "function t() { return 'function' };" +
michael@0 98 "var t = 'variable'; typeof(t)",
michael@0 99 "string",
michael@0 100 eval("function t() { return 'function' };" +
michael@0 101 "var t = 'variable'; typeof(t)"));
michael@0 102
michael@0 103 // function as a constructor
michael@0 104
michael@0 105 new TestCase(SECTION,
michael@0 106 "function t1(a,b) { var a = b; return a; } t1(1,3);",
michael@0 107 3,
michael@0 108 eval("function t1(a, b){ var a = b; return a;}; t1(1,3)"));
michael@0 109
michael@0 110 new TestCase(SECTION,
michael@0 111 "function t2(a,b) { this.a = b; } x = new t2(1,3); x.a",
michael@0 112 3,
michael@0 113 eval("function t2(a,b) { this.a = b; };" +
michael@0 114 "x = new t2(1,3); x.a"));
michael@0 115
michael@0 116 new TestCase(SECTION,
michael@0 117 "function t2(a,b) { this.a = a; } x = new t2(1,3); x.a",
michael@0 118 1,
michael@0 119 eval("function t2(a,b) { this.a = a; };" +
michael@0 120 "x = new t2(1,3); x.a"));
michael@0 121
michael@0 122 new TestCase(SECTION,
michael@0 123 "function t2(a,b) { this.a = b; this.b = a; } " +
michael@0 124 "x = new t2(1,3);x.a;",
michael@0 125 3,
michael@0 126 eval("function t2(a,b) { this.a = b; this.b = a; };" +
michael@0 127 "x = new t2(1,3);x.a;"));
michael@0 128
michael@0 129 new TestCase(SECTION,
michael@0 130 "function t2(a,b) { this.a = b; this.b = a; }" +
michael@0 131 "x = new t2(1,3);x.b;",
michael@0 132 1,
michael@0 133 eval("function t2(a,b) { this.a = b; this.b = a; };" +
michael@0 134 "x = new t2(1,3);x.b;") );
michael@0 135
michael@0 136 test();

mercurial