js/src/tests/js1_5/extensions/regress-346494-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 = 346494;
     8 var summary = 'various try...catch tests';
     9 var actual = '';
    10 var expect = '';
    13 //-----------------------------------------------------------------------------
    14 test();
    15 //-----------------------------------------------------------------------------
    17 function test()
    18 {
    19   enterFunc ('test');
    20   printBugNumber(BUGNUMBER);
    21   printStatus (summary);
    23   var pfx = "(function (x) {try {throw x}",
    24     cg1 = " catch (e if e === 42) {var v = 'catch guard 1 ' + e; actual += v + ','; print(v);}"
    25     cg2 = " catch (e if e === 43) {var v = 'catch guard 2 ' + e; actual += v + ','; print(v);}"
    26     cat = " catch (e) {var v = 'catch all ' + e; actual += v + ','; print(v);}"
    27     fin = " finally{var v = 'fin'; actual += v + ','; print(v)}",
    28     end = "})";
    30   var exphash = {
    31     pfx: "(function (y) { var result = ''; y = y + ',';",
    32     cg1: "result += (y === '42,') ? ('catch guard 1 ' + y):'';",
    33     cg2: "result += (y === '43,') ? ('catch guard 2 ' + y):'';",
    34     cat: "result += /catch guard/.test(result) ? '': ('catch all ' + y);",
    35     fin: "result += 'fin,';",
    36     end: "return result;})"
    37   };
    39   var src = [
    40     pfx + fin + end,
    41     pfx + cat + end,
    42     pfx + cat + fin + end,
    43     pfx + cg1 + end,
    44     pfx + cg1 + fin + end,
    45     pfx + cg1 + cat + end,
    46     pfx + cg1 + cat + fin + end,
    47     pfx + cg1 + cg2 + end,
    48     pfx + cg1 + cg2 + fin + end,
    49     pfx + cg1 + cg2 + cat + end,
    50     pfx + cg1 + cg2 + cat + fin + end,
    51     ];
    53   var expsrc = [
    54     exphash.pfx + exphash.fin + exphash.end,
    55     exphash.pfx + exphash.cat + exphash.end,
    56     exphash.pfx + exphash.cat + exphash.fin + exphash.end,
    57     exphash.pfx + exphash.cg1 + exphash.end,
    58     exphash.pfx + exphash.cg1 + exphash.fin + exphash.end,
    59     exphash.pfx + exphash.cg1 + exphash.cat + exphash.end,
    60     exphash.pfx + exphash.cg1 + exphash.cat + exphash.fin + exphash.end,
    61     exphash.pfx + exphash.cg1 + exphash.cg2 + exphash.end,
    62     exphash.pfx + exphash.cg1 + exphash.cg2 + exphash.fin + exphash.end,
    63     exphash.pfx + exphash.cg1 + exphash.cg2 + exphash.cat + exphash.end,
    64     exphash.pfx + exphash.cg1 + exphash.cg2 + exphash.cat + exphash.fin + exphash.end,
    65     ];
    67   for (var i in src) {
    68     print("\n=== " + src[i]);
    69     var f = eval(src[i]);
    70     print(src[i]);
    71     var exp = eval(expsrc[i]);
    72     // dis(f);
    73     print('decompiling: ' + f);
    75     actual = '';
    76     try { expect = exp(42); f(42) } catch (e) { print('tried f(42), caught ' + e) }
    77     reportCompare(expect, actual, summary);
    79     actual = '';
    80     try { expect = exp(43); f(43) } catch (e) { print('tried f(43), caught ' + e) }
    81     reportCompare(expect, actual, summary);
    83     actual = '';
    84     try { expect = exp(44); f(44) } catch (e) { print('tried f(44), caught ' + e) }
    85     reportCompare(expect, actual, summary);
    86   }
    89   exitFunc ('test');
    90 }

mercurial