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