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.

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

mercurial