js/src/tests/js1_5/Scope/scope-004.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/. */
     6 /*
     7  * Date: 2001-07-16
     8  *
     9  * SUMMARY:  Testing visiblity of variables from within a with block.
    10  * See http://bugzilla.mozilla.org/show_bug.cgi?id=90325
    11  */
    12 //-----------------------------------------------------------------------------
    13 var UBound = 0;
    14 var BUGNUMBER = 90325;
    15 var summary = 'Testing visiblity of variables from within a with block';
    16 var status = '';
    17 var statusitems = [];
    18 var actual = '';
    19 var actualvalues = [];
    20 var expect= '';
    21 var expectedvalues = [];
    23 // (compare local definitions which follow) -
    24 var A = 'global A';
    25 var B = 'global B';
    26 var C = 'global C';
    27 var D = 'global D';
    29 // an object with 'C' and 'D' properties -
    30 var objTEST = new Object();
    31 objTEST.C = C;
    32 objTEST.D = D;
    35 status = 'Section 1 of test';
    36 with (new Object())
    37 {
    38   actual = A;
    39   expect = 'global A';
    40 }
    41 addThis();
    44 status = 'Section 2 of test';
    45 with (Function)
    46 {
    47   actual = B;
    48   expect = 'global B';
    49 }
    50 addThis();
    53 status = 'Section 3 of test';
    54 with (this)
    55 {
    56   actual = C;
    57   expect = 'global C';
    58 }
    59 addThis();
    62 status = 'Section 4 of test';
    63 localA();
    64 addThis();
    66 status = 'Section 5 of test';
    67 localB();
    68 addThis();
    70 status = 'Section 6 of test';
    71 localC();
    72 addThis();
    74 status = 'Section 7 of test';
    75 localC(new Object());
    76 addThis();
    78 status = 'Section 8 of test';
    79 localC.apply(new Object());
    80 addThis();
    82 status = 'Section 9 of test';
    83 localC.apply(new Object(), [objTEST]);
    84 addThis();
    86 status = 'Section 10 of test';
    87 localC.apply(objTEST, [objTEST]);
    88 addThis();
    90 status = 'Section 11 of test';
    91 localD(new Object());
    92 addThis();
    94 status = 'Section 12 of test';
    95 localD.apply(new Object(), [objTEST]);
    96 addThis();
    98 status = 'Section 13 of test';
    99 localD.apply(objTEST, [objTEST]);
   100 addThis();
   104 //-------------------------------------------------------------------------------------------------
   105 test();
   106 //-------------------------------------------------------------------------------------------------
   110 // contains a with(new Object()) block -
   111 function localA()
   112 {
   113   var A = 'local A';
   115   with(new Object())
   116   {
   117     actual = A;
   118     expect = 'local A';
   119   }
   120 }
   123 // contains a with(Number) block -
   124 function localB()
   125 {
   126   var B = 'local B';
   128   with(Number)
   129   {
   130     actual = B;
   131     expect = 'local B';
   132   }
   133 }
   136 // contains a with(this) block -
   137 function localC(obj)
   138 {
   139   var C = 'local C';
   141   with(this)
   142   {
   143     actual = C;
   144   }
   146   if ('C' in this)
   147     expect = this.C;
   148   else
   149     expect = 'local C';
   150 }
   153 // contains a with(obj) block -
   154 function localD(obj)
   155 {
   156   var D = 'local D';
   158   with(obj)
   159   {
   160     actual = D;
   161   }
   163   if ('D' in obj)
   164     expect = obj.D;
   165   else
   166     expect = 'local D';
   167 }
   170 function addThis()
   171 {
   172   statusitems[UBound] = status;
   173   actualvalues[UBound] = actual;
   174   expectedvalues[UBound] = expect;
   175   UBound++;
   176 }
   179 function test()
   180 {
   181   enterFunc ('test');
   182   printBugNumber(BUGNUMBER);
   183   printStatus (summary);
   185   for (var i = 0; i < UBound; i++)
   186   {
   187     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   188   }
   190   exitFunc ('test');
   191 }

mercurial