js/src/tests/js1_5/extensions/regress-350312-03.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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 //-----------------------------------------------------------------------------
michael@0 7 var BUGNUMBER = 350312;
michael@0 8 var summary = 'Accessing wrong stack slot with nested catch/finally';
michael@0 9 var actual = '';
michael@0 10 var expect = '';
michael@0 11
michael@0 12
michael@0 13 //-----------------------------------------------------------------------------
michael@0 14 test();
michael@0 15 //-----------------------------------------------------------------------------
michael@0 16
michael@0 17 function test()
michael@0 18 {
michael@0 19 enterFunc ('test');
michael@0 20 printBugNumber(BUGNUMBER);
michael@0 21 printStatus (summary);
michael@0 22
michael@0 23 var pfx = "(function (x) {try {if (x > 41) throw x}",
michael@0 24 cg1a = " catch (e if e === 42) {var v = 'catch guard 1 ' + e; actual += v + ',';print(v);}"
michael@0 25 cg1b = " catch (e if e === 42) {var v = 'catch guard 1 + throw ' + e; actual += v + ',';print(v); throw e;}"
michael@0 26 cg2 = " catch (e if e === 43) {var v = 'catch guard 2 ' + e; actual += v + ',';print(v)}"
michael@0 27 cat = " catch (e) {var v = 'catch all ' + e; print(v); if (e == 44) throw e}"
michael@0 28 fin = " finally{var v = 'fin'; actual += v + ',';print(v)}",
michael@0 29 end = "})";
michael@0 30
michael@0 31 var exphash = {
michael@0 32 pfx: "(function (y) { var result = ''; y = y + ',';",
michael@0 33 cg1a: " result += (y === '42,') ? ('catch guard 1 ' + y):'';",
michael@0 34 cg1b: " result += (y === '42,') ? ('catch guard 1 + throw ' + y):'';",
michael@0 35 cg2: " result += (y === '43,') ? ('catch guard 2 ' + y):'';",
michael@0 36 cat: " result += (y > 41) ? ('catch all ' + y):'';",
michael@0 37 fin: " result += 'fin,';",
michael@0 38 end: "return result;})"
michael@0 39 };
michael@0 40
michael@0 41 var src = [
michael@0 42 pfx + fin + end,
michael@0 43 pfx + cat + end,
michael@0 44 pfx + cat + fin + end,
michael@0 45 pfx + cg1a + end,
michael@0 46 pfx + cg1a + fin + end,
michael@0 47 pfx + cg1a + cat + end,
michael@0 48 pfx + cg1a + cat + fin + end,
michael@0 49 pfx + cg1a + cg2 + end,
michael@0 50 pfx + cg1a + cg2 + fin + end,
michael@0 51 pfx + cg1a + cg2 + cat + end,
michael@0 52 pfx + cg1a + cg2 + cat + fin + end,
michael@0 53 pfx + cg1b + end,
michael@0 54 pfx + cg1b + fin + end,
michael@0 55 pfx + cg1b + cat + end,
michael@0 56 pfx + cg1b + cat + fin + end,
michael@0 57 pfx + cg1b + cg2 + end,
michael@0 58 pfx + cg1b + cg2 + fin + end,
michael@0 59 pfx + cg1b + cg2 + cat + end,
michael@0 60 pfx + cg1b + cg2 + cat + fin + end,
michael@0 61 ];
michael@0 62
michael@0 63 var expsrc = [
michael@0 64 exphash.pfx + exphash.fin + exphash.end,
michael@0 65 exphash.pfx + exphash.cat + exphash.end,
michael@0 66 exphash.pfx + exphash.cat + exphash.fin + exphash.end,
michael@0 67 exphash.pfx + exphash.cg1a + exphash.end,
michael@0 68 exphash.pfx + exphash.cg1a + exphash.fin + exphash.end,
michael@0 69 exphash.pfx + exphash.cg1a + exphash.cat + exphash.end,
michael@0 70 exphash.pfx + exphash.cg1a + exphash.cat + exphash.fin + exphash.end,
michael@0 71 exphash.pfx + exphash.cg1a + exphash.cg2 + exphash.end,
michael@0 72 exphash.pfx + exphash.cg1a + exphash.cg2 + exphash.fin + exphash.end,
michael@0 73 exphash.pfx + exphash.cg1a + exphash.cg2 + exphash.cat + exphash.end,
michael@0 74 exphash.pfx + exphash.cg1a + exphash.cg2 + exphash.cat + exphash.fin + exphash.end,
michael@0 75 exphash.pfx + exphash.cg1b + exphash.end,
michael@0 76 exphash.pfx + exphash.cg1b + exphash.fin + exphash.end,
michael@0 77 exphash.pfx + exphash.cg1b + exphash.cat + exphash.end,
michael@0 78 exphash.pfx + exphash.cg1b + exphash.cat + exphash.fin + exphash.end,
michael@0 79 exphash.pfx + exphash.cg1b + exphash.cg2 + exphash.end,
michael@0 80 exphash.pfx + exphash.cg1b + exphash.cg2 + exphash.fin + exphash.end,
michael@0 81 exphash.pfx + exphash.cg1b + exphash.cg2 + exphash.cat + exphash.end,
michael@0 82 exphash.pfx + exphash.cg1b + exphash.cg2 + exphash.cat + exphash.fin + exphash.end,
michael@0 83 ];
michael@0 84
michael@0 85 for (var i in src) {
michael@0 86 print("\n=== " + i + ": " + src[i]);
michael@0 87 var f = eval(src[i]);
michael@0 88 var exp = eval(expsrc[i]);
michael@0 89 // dis(f);
michael@0 90 print('decompiling: ' + f);
michael@0 91 //print('decompiling exp: ' + exp);
michael@0 92
michael@0 93 actual = '';
michael@0 94 try { expect = exp(41); f(41) } catch (e) { print('tried f(41), caught ' + e) }
michael@0 95 reportCompare(expect, actual, summary);
michael@0 96
michael@0 97 actual = '';
michael@0 98 try { expect = exp(42); f(42) } catch (e) { print('tried f(42), caught ' + e) }
michael@0 99 reportCompare(expect, actual, summary);
michael@0 100
michael@0 101 actual = '';
michael@0 102 try { expect = exp(43); f(43) } catch (e) { print('tried f(43), caught ' + e) }
michael@0 103 reportCompare(expect, actual, summary);
michael@0 104
michael@0 105 actual = '';
michael@0 106 try { expect = exp(44); f(44) } catch (e) { print('tried f(44), caught ' + e) }
michael@0 107 reportCompare(expect, actual, summary);
michael@0 108
michael@0 109 actual = '';
michael@0 110 try { expect = exp(45); f(45) } catch (e) { print('tried f(44), caught ' + e) }
michael@0 111 reportCompare(expect, actual, summary);
michael@0 112
michael@0 113 }
michael@0 114
michael@0 115 exitFunc ('test');
michael@0 116 }

mercurial