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 // |reftest| fails
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 305064;
9 var summary = 'Tests the trim, trimRight and trimLeft methods';
10 var actual = '';
11 var expect = '';
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
16 var trimMethods = ['trim', 'trimLeft', 'trimRight'];
18 /** List from ES 3.1 Recommendation for String.trim (bug 305064) **/
19 var whitespace = [
20 {s : '\u0009', t : 'HORIZONTAL TAB'},
21 {s : '\u000B', t : 'VERTICAL TAB'},
22 {s : '\u000C', t : 'FORMFEED'},
23 {s : '\u0020', t : 'SPACE'},
24 {s : '\u00A0', t : 'NO-BREAK SPACE'},
25 {s : '\u1680', t : 'OGHAM SPACE MARK'},
26 {s : '\u180E', t : 'MONGOLIAN VOWEL SEPARATOR'},
27 {s : '\u2000', t : 'EN QUAD'},
28 {s : '\u2001', t : 'EM QUAD'},
29 {s : '\u2002', t : 'EN SPACE'},
30 {s : '\u2003', t : 'EM SPACE'},
31 {s : '\u2004', t : 'THREE-PER-EM SPACE'},
32 {s : '\u2005', t : 'FOUR-PER-EM SPACE'},
33 {s : '\u2006', t : 'SIX-PER-EM SPACE'},
34 {s : '\u2007', t : 'FIGURE SPACE'},
35 {s : '\u2008', t : 'PUNCTUATION SPACE'},
36 {s : '\u2009', t : 'THIN SPACE'},
37 {s : '\u200A', t : 'HAIR SPACE'},
38 {s : '\u202F', t : 'NARROW NO-BREAK SPACE'},
39 {s : '\u205F', t : 'MEDIUM MATHEMATICAL SPACE'},
40 {s : '\u3000', t : 'IDEOGRAPHIC SPACE'},
41 {s : '\u000A', t : 'LINE FEED OR NEW LINE'},
42 {s : '\u000D', t : 'CARRIAGE RETURN'},
43 {s : '\u2028', t : 'LINE SEPARATOR'},
44 {s : '\u2029', t : 'PARAGRAPH SEPARATOR'},
45 {s : '\u200B', t : 'ZERO WIDTH SPACE (category Cf)'}
46 ];
48 for (var j = 0; j < trimMethods.length; ++j)
49 {
50 var str;
52 var method = trimMethods[j];
54 if (typeof String.prototype[method] == 'undefined')
55 {
56 reportCompare(true, true, 'Test skipped. String.prototype.' + method + ' is not supported');
57 continue;
58 }
60 print('Test empty string.');
61 str = '';
62 expected = '';
63 actual = str[method]();
64 reportCompare(expected, actual, '"' + toPrinted(str) + '".' + method + '()');
66 print('Test string with no whitespace.');
67 str = 'a';
68 expected = 'a';
69 actual = str[method]();
70 reportCompare(expected, actual, '"' + toPrinted(str) + '".' + method + '()');
72 for (var i = 0; i < whitespace.length; ++i)
73 {
74 var v = whitespace[i].s;
75 var t = whitespace[i].t;
76 v = v + v + v;
78 print('=======================================');
79 print('Test ' + method + ' with with only whitespace. : ' + t);
80 str = v;
81 expected = '';
82 actual = str[method]();
83 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');
85 print('Test ' + method + ' with with no leading or trailing whitespace. : ' + t);
86 str = 'a' + v + 'b';
87 expected = str;
88 actual = str[method]();
89 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');
91 print('Test ' + method + ' with with leading whitespace. : ' + t);
92 str = v + 'a';
93 switch(method)
94 {
95 case 'trim':
96 expected = 'a';
97 break;
98 case 'trimLeft':
99 expected = 'a';
100 break;
101 case 'trimRight':
102 expected = str;
103 break;
104 }
105 actual = str[method]();
106 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');
108 print('Test ' + method + ' with with trailing whitespace. : ' + t);
109 str = 'a' + v;
110 switch(method)
111 {
112 case 'trim':
113 expected = 'a';
114 break;
115 case 'trimLeft':
116 expected = str;
117 break;
118 case 'trimRight':
119 expected = 'a';
120 break;
121 }
122 actual = str[method]();
123 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');
125 print('Test ' + method + ' with with leading and trailing whitepace.');
126 str = v + 'a' + v;
127 switch(method)
128 {
129 case 'trim':
130 expected = 'a';
131 break;
132 case 'trimLeft':
133 expected = 'a' + v;
134 break;
135 case 'trimRight':
136 expected = v + 'a';
137 break;
138 }
139 actual = str[method]();
140 reportCompare(expected, actual, t + ':' + '"' + toPrinted(str) + '".' + method + '()');
142 }
143 }