js/src/tests/js1_7/regress/regress-363040-01.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 var BUGNUMBER = 363040;
     8 var summary = 'Array.prototype.reduce, Array.prototype.reduceRight';
     9 var actual = '';
    10 var expect = '';
    13 //-----------------------------------------------------------------------------
    14 test();
    15 //-----------------------------------------------------------------------------
    17 function test()
    18 {
    19   enterFunc ('test');
    20   printBugNumber(BUGNUMBER);
    21   printStatus (summary);
    23   function f(x,y) { return '(' + x + '+' + y + ')';}
    25   var testdesc;
    26   var arr0elms  = [];
    27   var arr1elms = [1];
    28   var arr2elms  = [1, 2];
    30   testdesc = 'Test reduce of empty array without initializer.';
    31   try
    32   {
    33     expect = 'TypeError: reduce of empty array with no initial value';
    34     arr0elms.reduce(f);
    35   }
    36   catch(ex)
    37   {
    38     actual = ex + '';
    39   }
    40   reportCompare(expect + '', actual + '', testdesc + ' : ' + expect);
    42   testdesc = 'Test reduceRight of empty array without initializer.';
    43   try
    44   {
    45     expect = 'TypeError: reduce of empty array with no initial value';
    46     arr0elms.reduceRight(f);
    47   }
    48   catch(ex)
    49   {
    50     actual = ex + '';
    51   }
    52   reportCompare(expect + '', actual + '', testdesc + ' : ' + expect);
    54   testdesc = 'Test reduce of empty array with initial value.';
    55   expect = 'a';
    56   actual = arr0elms.reduce(f, 'a');
    57   reportCompare(expect + '', actual + '', testdesc + ' : ' + expect);
    59   testdesc = 'Test reduceRight of empty array with initial value.';
    60   expect = 'a';
    61   actual = arr0elms.reduceRight(f, 'a');
    62   reportCompare(expect + '', actual + '', testdesc +' : ' + expect);
    64   testdesc = 'Test reduce of 1 element array with no initializer.';
    65   expect = '1';
    66   actual = arr1elms.reduce(f);
    67   reportCompare(expect + '', actual + '', testdesc + ' : ' + expect);
    69   testdesc = 'Test reduceRight of 1 element array with no initializer.';
    70   expect = '1';
    71   actual = arr1elms.reduceRight(f);
    72   reportCompare(expect + '', actual + '', testdesc + ' : ' + expect);
    74   testdesc = 'Test reduce of 2 element array with no initializer.';
    75   expect = '(1+2)';
    76   actual = arr2elms.reduce(f);
    77   reportCompare(expect + '', actual + '', testdesc + ' : ' + expect);
    79   testdesc = 'Test reduce of 2 element array with initializer.';
    80   expect = '((a+1)+2)';
    81   actual = arr2elms.reduce(f,'a');
    82   reportCompare(expect + '', actual + '', testdesc + ' : ' + expect);
    84   testdesc = 'Test reduceRight of 2 element array with no initializer.';
    85   expect = '(2+1)';
    86   actual = arr2elms.reduceRight(f);
    87   reportCompare(expect + '', actual + '', testdesc + ' : ' + expect);
    89   testdesc = 'Test reduceRight of 2 element array with no initializer.';
    90   expect = '((a+2)+1)';
    91   actual = arr2elms.reduceRight(f,'a');
    92   reportCompare(expect + '', actual + '', testdesc + ' : ' + expect);
    94   exitFunc ('test');
    95 }

mercurial