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.

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

mercurial