js/src/tests/js1_5/Object/regress-137000.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  *
     8  * Date:    03 June 2002
     9  * SUMMARY: Function param or local var with same name as a function property
    10  *
    11  * See http://bugzilla.mozilla.org/show_bug.cgi?id=137000
    12  * See http://bugzilla.mozilla.org/show_bug.cgi?id=138708
    13  * See http://bugzilla.mozilla.org/show_bug.cgi?id=150032
    14  * See http://bugzilla.mozilla.org/show_bug.cgi?id=150859
    15  *
    16  */
    17 //-----------------------------------------------------------------------------
    18 var UBound = 0;
    19 var BUGNUMBER = 137000;
    20 var summary = 'Function param or local var with same name as a function prop';
    21 var status = '';
    22 var statusitems = [];
    23 var actual = '';
    24 var actualvalues = [];
    25 var expect= '';
    26 var expectedvalues = [];
    29 /*
    30  * Note use of 'x' both for the parameter to f,
    31  * and as a property name for |f| as an object
    32  */
    33 function f(x)
    34 {
    35 }
    37 status = inSection(1);
    38 f.x = 12;
    39 actual = f.x;
    40 expect = 12;
    41 addThis();
    45 /*
    46  * A more elaborate example, using the call() method
    47  * to chain constructors from child to parent.
    48  *
    49  * The key point is the use of the same name 'p' for both
    50  * the parameter to the constructor, and as a property name
    51  */
    52 function parentObject(p)
    53 {
    54   this.p = 1;
    55 }
    57 function childObject()
    58 {
    59   parentObject.call(this);
    60 }
    61 childObject.prototype = parentObject;
    63 status = inSection(2);
    64 var objParent = new parentObject();
    65 actual = objParent.p;
    66 expect = 1;
    67 addThis();
    69 status = inSection(3);
    70 var objChild = new childObject();
    71 actual = objChild.p;
    72 expect = 1;
    73 addThis();
    77 /*
    78  * A similar set-up. Here the same name is being used for
    79  * the parameter to both the Base and Child constructors,
    80  */
    81 function Base(id)
    82 {
    83 }
    85 function Child(id)
    86 {
    87   this.prop = id;
    88 }
    89 Child.prototype=Base;
    91 status = inSection(4);
    92 var c1 = new Child('child1');
    93 actual = c1.prop;
    94 expect = 'child1';
    95 addThis();
    99 /*
   100  * Use same identifier as a property name, too -
   101  */
   102 function BaseX(id)
   103 {
   104 }
   106 function ChildX(id)
   107 {
   108   this.id = id;
   109 }
   110 ChildX.prototype=BaseX;
   112 status = inSection(5);
   113 c1 = new ChildX('child1');
   114 actual = c1.id;
   115 expect = 'child1';
   116 addThis();
   120 /*
   121  * From http://bugzilla.mozilla.org/show_bug.cgi?id=150032
   122  *
   123  * Here the same name is being used both for a local variable
   124  * declared in g(), and as a property name for |g| as an object
   125  */
   126 function g()
   127 {
   128   var propA = g.propA;
   129   var propB = g.propC;
   131   this.getVarA = function() {return propA;}
   132   this.getVarB = function() {return propB;}
   133 }
   134 g.propA = 'A';
   135 g.propB = 'B';
   136 g.propC = 'C';
   137 var obj = new g();
   139 status = inSection(6);
   140 actual = obj.getVarA(); // this one was returning 'undefined'
   141 expect = 'A';
   142 addThis();
   144 status = inSection(7);
   145 actual = obj.getVarB(); // this one is easy; it never failed
   146 expect = 'C';
   147 addThis();
   151 /*
   152  * By martin.honnen@gmx.de
   153  * From http://bugzilla.mozilla.org/show_bug.cgi?id=150859
   154  *
   155  * Here the same name is being used for a local var in F
   156  * and as a property name for |F| as an object
   157  *
   158  * Twist: the property is added via another function.
   159  */
   160 function setFProperty(val)
   161 {
   162   F.propA = val;
   163 }
   165 function F()
   166 {
   167   var propA = 'Local variable in F';
   168 }
   170 status = inSection(8);
   171 setFProperty('Hello');
   172 actual = F.propA; // this was returning 'undefined'
   173 expect = 'Hello';
   174 addThis();
   179 //-----------------------------------------------------------------------------
   180 test();
   181 //-----------------------------------------------------------------------------
   185 function addThis()
   186 {
   187   statusitems[UBound] = status;
   188   actualvalues[UBound] = actual;
   189   expectedvalues[UBound] = expect;
   190   UBound++;
   191 }
   194 function test()
   195 {
   196   enterFunc('test');
   197   printBugNumber(BUGNUMBER);
   198   printStatus(summary);
   200   for (var i=0; i<UBound; i++)
   201   {
   202     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   203   }
   205   exitFunc ('test');
   206 }

mercurial