Sat, 03 Jan 2015 20:18:00 +0100
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 = 384412; |
michael@0 | 8 | var summary = 'Exercise frame handling code'; |
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 | /* |
michael@0 | 24 | * Generators |
michael@0 | 25 | */ |
michael@0 | 26 | |
michael@0 | 27 | /* Generator yields properly */ |
michael@0 | 28 | f = (function(n) { for (var i = 0; i != n; i++) yield i }); |
michael@0 | 29 | g = f(3); |
michael@0 | 30 | expect(0, g.next()); |
michael@0 | 31 | expect(1, g.next()); |
michael@0 | 32 | expect(2, g.next()); |
michael@0 | 33 | s = "no exception"; |
michael@0 | 34 | try { g.next(); } catch (e) { s = e + ""; } |
michael@0 | 35 | expect("[object StopIteration]", s); |
michael@0 | 36 | |
michael@0 | 37 | /* Generator yields properly in finally */ |
michael@0 | 38 | f = (function(n) { |
michael@0 | 39 | try { |
michael@0 | 40 | for (var i = 0; i != n; i++) |
michael@0 | 41 | yield i; |
michael@0 | 42 | } finally { |
michael@0 | 43 | yield "finally"; |
michael@0 | 44 | } |
michael@0 | 45 | }); |
michael@0 | 46 | |
michael@0 | 47 | g = f(3); |
michael@0 | 48 | expect(0, g.next()); |
michael@0 | 49 | expect(1, g.next()); |
michael@0 | 50 | expect(2, g.next()); |
michael@0 | 51 | expect("finally", g.next()); |
michael@0 | 52 | |
michael@0 | 53 | /* Generator throws when closed with yield in finally */ |
michael@0 | 54 | g = f(3); |
michael@0 | 55 | expect(0, g.next()); |
michael@0 | 56 | s = "no exception"; |
michael@0 | 57 | try { g.close(); } catch (e) { s = e + ""; }; |
michael@0 | 58 | expect("TypeError: yield from closing generator " + f.toSource(), s); |
michael@0 | 59 | |
michael@0 | 60 | |
michael@0 | 61 | /* |
michael@0 | 62 | * Calls that have been replaced with js_PushFrame() &c... |
michael@0 | 63 | */ |
michael@0 | 64 | f = (function() { return arguments[(arguments.length - 1) / 2]; }); |
michael@0 | 65 | expect(2, f(1, 2, 3)); |
michael@0 | 66 | expect(2, f.call(null, 1, 2, 3)); |
michael@0 | 67 | expect(2, f.apply(null, [1, 2, 3])); |
michael@0 | 68 | expect("a1c", "abc".replace("b", f)); |
michael@0 | 69 | s = "no exception"; |
michael@0 | 70 | try { |
michael@0 | 71 | "abc".replace("b", (function() { throw "hello" })); |
michael@0 | 72 | } catch (e) { |
michael@0 | 73 | s = e + ""; |
michael@0 | 74 | } |
michael@0 | 75 | expect("hello", s); |
michael@0 | 76 | expect(6, [1, 2, 3].reduce(function(a, b) { return a + b; })); |
michael@0 | 77 | s = "no exception"; |
michael@0 | 78 | try { |
michael@0 | 79 | [1, 2, 3].reduce(function(a, b) { if (b == 2) throw "hello"; }); |
michael@0 | 80 | } catch (e) { |
michael@0 | 81 | s = e + ""; |
michael@0 | 82 | } |
michael@0 | 83 | expect("hello", s); |
michael@0 | 84 | |
michael@0 | 85 | /* |
michael@0 | 86 | * __noSuchMethod__ |
michael@0 | 87 | */ |
michael@0 | 88 | o = {}; |
michael@0 | 89 | s = "no exception"; |
michael@0 | 90 | try { |
michael@0 | 91 | o.hello(); |
michael@0 | 92 | } catch (e) { |
michael@0 | 93 | s = e + ""; |
michael@0 | 94 | } |
michael@0 | 95 | expect("TypeError: o.hello is not a function", s); |
michael@0 | 96 | o.__noSuchMethod__ = (function() { return "world"; }); |
michael@0 | 97 | expect("world", o.hello()); |
michael@0 | 98 | o.__noSuchMethod__ = 1; |
michael@0 | 99 | s = "no exception"; |
michael@0 | 100 | try { |
michael@0 | 101 | o.hello(); |
michael@0 | 102 | } catch (e) { |
michael@0 | 103 | s = e + ""; |
michael@0 | 104 | } |
michael@0 | 105 | expect("TypeError: o.hello is not a function", s); |
michael@0 | 106 | o.__noSuchMethod__ = {}; |
michael@0 | 107 | s = "no exception"; |
michael@0 | 108 | try { |
michael@0 | 109 | o.hello(); |
michael@0 | 110 | } catch (e) { |
michael@0 | 111 | s = e + ""; |
michael@0 | 112 | } |
michael@0 | 113 | expect("TypeError: ({}) is not a function", s); |
michael@0 | 114 | s = "no exception"; |
michael@0 | 115 | try { |
michael@0 | 116 | eval("o.hello()"); |
michael@0 | 117 | } catch (e) { |
michael@0 | 118 | s = e + ""; |
michael@0 | 119 | } |
michael@0 | 120 | expect("TypeError: ({}) is not a function", s); |
michael@0 | 121 | s = "no exception"; |
michael@0 | 122 | try { [2, 3, 0].sort({}); } catch (e) { s = e + ""; } |
michael@0 | 123 | expect("TypeError: ({}) is not a function", s); |
michael@0 | 124 | |
michael@0 | 125 | /* |
michael@0 | 126 | * Generator expressions. |
michael@0 | 127 | */ |
michael@0 | 128 | String.prototype.__iterator__ = (function () { |
michael@0 | 129 | /* |
michael@0 | 130 | * NOTE: |
michael@0 | 131 | * Without the "0 + ", the loop over <x/> does not terminate because |
michael@0 | 132 | * the iterator gets run on a string with an empty length property. |
michael@0 | 133 | */ |
michael@0 | 134 | for (let i = 0; i != 0 + this.length; i++) |
michael@0 | 135 | yield this[i]; |
michael@0 | 136 | }); |
michael@0 | 137 | expect(["a1", "a2", "a3", "b1", "b2", "b3", "c1", "c2", "c3"] + "", |
michael@0 | 138 | ([a + b for (a in 'abc') for (b in '123')]) + ""); |
michael@0 | 139 | |
michael@0 | 140 | print("End of Tests"); |
michael@0 | 141 | |
michael@0 | 142 | /* |
michael@0 | 143 | * Utility functions |
michael@0 | 144 | */ |
michael@0 | 145 | function expect(a, b) { |
michael@0 | 146 | print('expect: ' + a + ', actual: ' + b); |
michael@0 | 147 | reportCompare(a, b, summary); |
michael@0 | 148 | } |
michael@0 | 149 | |
michael@0 | 150 | |
michael@0 | 151 | exitFunc ('test'); |
michael@0 | 152 | } |