js/src/tests/js1_5/extensions/regress-225831.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:    15 Nov 2003
     9  * SUMMARY: Stressing the byte code generator
    10  *
    11  * See http://bugzilla.mozilla.org/show_bug.cgi?id=225831
    12  *
    13  */
    14 //-----------------------------------------------------------------------------
    15 var UBound = 0;
    16 var BUGNUMBER = 225831;
    17 var summary = 'Stressing the byte code generator';
    18 var status = '';
    19 var statusitems = [];
    20 var actual = '';
    21 var actualvalues = [];
    22 var expect= '';
    23 var expectedvalues = [];
    26 function f() { return {x: 0}; }
    28 var N = 300;
    29 var a = new Array(N + 1);
    30 a[N] = 10;
    31 a[0] = 100;
    34 status = inSection(1);
    36 // build string of the form ++(a[++f().x + ++f().x + ... + ++f().x]) which
    37 // gives ++a[N]
    38 var str = "".concat("++(a[", repeat_str("++f().x + ", (N - 1)), "++f().x])");
    40 // Use Script constructor instead of simple eval to test Rhino optimizer mode
    41 // because in Rhino, eval always uses interpreted mode.
    42 if (typeof Script == 'undefined')
    43 {
    44   print('Test skipped. Script not defined.');
    45 }
    46 else
    47 {
    48   var script = new Script(str);
    49   script();
    51   actual = a[N];
    52   expect = 11;
    53 }
    54 addThis();
    56 status = inSection(2);
    59 // build string of the form (a[f().x-- + f().x-- + ... + f().x--])--
    60 // which should give (a[0])--
    61 if (typeof Script == 'undefined')
    62 {
    63   print('Test skipped. Script not defined.');
    64 }
    65 else
    66 {
    67   str = "".concat("(a[", repeat_str("f().x-- + ", (N - 1)), "f().x--])--");
    68   script = new Script(str);
    69   script();
    71   actual = a[0];
    72   expect = 99;
    73 }
    74 addThis();
    77 status = inSection(3);
    79 // build string of the form [[1], [1], ..., [1]]
    80 if (typeof Script == 'undefined')
    81 {
    82   print('Test skipped. Script not defined.');
    83 }
    84 else
    85 {
    86   str = "".concat("[", repeat_str("[1], ", (N - 1)), "[1]]");
    87   script = new Script(str);
    88   script();
    90   actual = uneval(script());
    91   expect = str;
    92 }
    93 addThis();
    96 status = inSection(4);
    98 // build string of the form ({1:{a:1}, 2:{a:1}, ... N:{a:1}})
    99 if (typeof Script == 'undefined')
   100 {
   101   print('Test skipped. Script not defined.');
   102 }
   103 else
   104 {
   105   str = function() {
   106     var arr = new Array(N+1);
   107     arr[0] = "({";
   108     for (var i = 1; i < N; ++i) {
   109       arr[i] = i+":{a:1}, ";
   110     }
   111     arr[N] = N+":{a:1}})";
   112     return "".concat.apply("", arr);
   113   }();
   115   script = new Script(str);
   116   script();
   118   actual = uneval(script());
   119   expect = str;
   120 }
   121 addThis();
   126 //-----------------------------------------------------------------------------
   127 test();
   128 //-----------------------------------------------------------------------------
   132 function repeat_str(str, repeat_count)
   133 {
   134   var arr = new Array(--repeat_count);
   135   while (repeat_count != 0)
   136     arr[--repeat_count] = str;
   137   return str.concat.apply(str, arr);
   138 }
   141 function addThis()
   142 {
   143   statusitems[UBound] = status;
   144   actualvalues[UBound] = actual;
   145   expectedvalues[UBound] = expect;
   146   UBound++;
   147 }
   150 function test()
   151 {
   152   enterFunc('test');
   153   printBugNumber(BUGNUMBER);
   154   printStatus(summary);
   156   for (var i=0; i<UBound; i++)
   157   {
   158     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   159   }
   161   exitFunc ('test');
   162 }

mercurial