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