js/src/tests/js1_5/Function/regress-222029-001.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:    13 Oct 2003
     9  * SUMMARY: Make our f.caller property match IE's wrt f.apply and f.call
    10  * See http://bugzilla.mozilla.org/show_bug.cgi?id=222029
    11  *
    12  * Below, when gg calls f via |f.call|, we have this call chain:
    13  *
    14  *          calls                                  calls
    15  *   gg() --------->  Function.prototype.call()  --------->  f()
    16  *
    17  *
    18  * The question this bug addresses is, "What should we say |f.caller| is?"
    19  *
    20  * Before this fix, SpiderMonkey said it was |Function.prototype.call|.
    21  * After this fix, SpiderMonkey emulates IE and says |gg| instead.
    22  *
    23  */
    24 //-----------------------------------------------------------------------------
    25 var UBound = 0;
    26 var BUGNUMBER = 222029;
    27 var summary = "Make our f.caller property match IE's wrt f.apply and f.call";
    28 var status = '';
    29 var statusitems = [];
    30 var actual = '';
    31 var actualvalues = [];
    32 var expect= '';
    33 var expectedvalues = [];
    36 function f()
    37 {
    38   return f.caller.p ;
    39 }
    42 /*
    43  * Call |f| directly
    44  */
    45 function g()
    46 {
    47   return f();
    48 }
    49 g.p = "hello";
    52 /*
    53  * Call |f| via |f.call|
    54  */
    55 function gg()
    56 {
    57   return f.call(this);
    58 }
    59 gg.p = "hello";
    62 /*
    63  * Call |f| via |f.apply|
    64  */
    65 function ggg()
    66 {
    67   return f.apply(this);
    68 }
    69 ggg.p = "hello";
    72 /*
    73  * Shadow |p| on |Function.prototype.call|, |Function.prototype.apply|.
    74  * In Sections 2 and 3 below, we no longer expect to recover this value -
    75  */
    76 Function.prototype.call.p = "goodbye";
    77 Function.prototype.apply.p = "goodbye";
    81 status = inSection(1);
    82 actual = g();
    83 expect = "hello";
    84 addThis();
    86 status = inSection(2);
    87 actual = gg();
    88 expect = "hello";
    89 addThis();
    91 status = inSection(3);
    92 actual = ggg();
    93 expect = "hello";
    94 addThis();
    99 //-----------------------------------------------------------------------------
   100 test();
   101 //-----------------------------------------------------------------------------
   105 function addThis()
   106 {
   107   statusitems[UBound] = status;
   108   actualvalues[UBound] = actual;
   109   expectedvalues[UBound] = expect;
   110   UBound++;
   111 }
   114 function test()
   115 {
   116   enterFunc('test');
   117   printBugNumber(BUGNUMBER);
   118   printStatus(summary);
   120   for (var i=0; i<UBound; i++)
   121   {
   122     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   123   }
   125   exitFunc ('test');
   126 }

mercurial