js/src/tests/js1_8/extensions/simple-tree.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 // |reftest| skip
     2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     3 /*
     4  * Any copyright is dedicated to the Public Domain.
     5  * http://creativecommons.org/licenses/publicdomain/
     6  * Contributor: Jason Orendorff
     7  */
     9 //-----------------------------------------------------------------------------
    11 var summary = "Create a tree of threads";
    13 var N = 50;  // number of threads to create
    15 printStatus (summary);
    17 function range(start, stop) {
    18   var a = [];
    19   for (var i = start; i < stop; i++)
    20     a.push(i);
    21   return a;
    22 }
    24 function tree(start, stop) {
    25   sleep(0.001);
    27   if (start >= stop)
    28     return [];
    29   else if (start + 1 >= stop)
    30     return [start];
    32   sleep(0.001);
    34   let mid = start + Math.floor((stop - start) / 2);
    35   let halves = scatter([function () { return tree(start, mid); },
    36                         function () { return tree(mid, stop); }]);
    37   sleep(0.001);
    38   return Array.prototype.concat.apply([], halves);
    39 }
    41 var expect;
    42 var actual;
    44 if (typeof scatter == 'undefined' || typeof sleep == 'undefined') {
    45   print('Test skipped. scatter or sleep not defined.');
    46   expect = actual = 'Test skipped.';
    47 } else {
    48   expect = range(0, N).toSource();
    49   actual = tree(0, N).toSource();
    50 }
    52 reportCompare(expect, actual, summary);

mercurial