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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | const { getRulesForLocale } = require("sdk/l10n/plural-rules"); |
michael@0 | 6 | |
michael@0 | 7 | // For more information, please visit unicode website: |
michael@0 | 8 | // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html |
michael@0 | 9 | |
michael@0 | 10 | function map(assert, f, n, form) { |
michael@0 | 11 | assert.equal(f(n), form, n + " maps to '" + form + "'"); |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | exports.testFrench = function(assert) { |
michael@0 | 15 | let f = getRulesForLocale("fr"); |
michael@0 | 16 | map(assert, f, -1, "other"); |
michael@0 | 17 | map(assert, f, 0, "one"); |
michael@0 | 18 | map(assert, f, 1, "one"); |
michael@0 | 19 | map(assert, f, 1.5, "one"); |
michael@0 | 20 | map(assert, f, 2, "other"); |
michael@0 | 21 | map(assert, f, 100, "other"); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | exports.testEnglish = function(assert) { |
michael@0 | 25 | let f = getRulesForLocale("en"); |
michael@0 | 26 | map(assert, f, -1, "other"); |
michael@0 | 27 | map(assert, f, 0, "other"); |
michael@0 | 28 | map(assert, f, 1, "one"); |
michael@0 | 29 | map(assert, f, 1.5, "other"); |
michael@0 | 30 | map(assert, f, 2, "other"); |
michael@0 | 31 | map(assert, f, 100, "other"); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | exports.testArabic = function(assert) { |
michael@0 | 35 | let f = getRulesForLocale("ar"); |
michael@0 | 36 | map(assert, f, -1, "other"); |
michael@0 | 37 | map(assert, f, 0, "zero"); |
michael@0 | 38 | map(assert, f, 0.5, "other"); |
michael@0 | 39 | |
michael@0 | 40 | map(assert, f, 1, "one"); |
michael@0 | 41 | map(assert, f, 1.5, "other"); |
michael@0 | 42 | |
michael@0 | 43 | map(assert, f, 2, "two"); |
michael@0 | 44 | map(assert, f, 2.5, "other"); |
michael@0 | 45 | |
michael@0 | 46 | map(assert, f, 3, "few"); |
michael@0 | 47 | map(assert, f, 3.5, "few"); // I'd expect it to be 'other', but the unicode.org |
michael@0 | 48 | // algorithm computes 'few'. |
michael@0 | 49 | map(assert, f, 5, "few"); |
michael@0 | 50 | map(assert, f, 10, "few"); |
michael@0 | 51 | map(assert, f, 103, "few"); |
michael@0 | 52 | map(assert, f, 105, "few"); |
michael@0 | 53 | map(assert, f, 110, "few"); |
michael@0 | 54 | map(assert, f, 203, "few"); |
michael@0 | 55 | map(assert, f, 205, "few"); |
michael@0 | 56 | map(assert, f, 210, "few"); |
michael@0 | 57 | |
michael@0 | 58 | map(assert, f, 11, "many"); |
michael@0 | 59 | map(assert, f, 50, "many"); |
michael@0 | 60 | map(assert, f, 99, "many"); |
michael@0 | 61 | map(assert, f, 111, "many"); |
michael@0 | 62 | map(assert, f, 150, "many"); |
michael@0 | 63 | map(assert, f, 199, "many"); |
michael@0 | 64 | |
michael@0 | 65 | map(assert, f, 100, "other"); |
michael@0 | 66 | map(assert, f, 101, "other"); |
michael@0 | 67 | map(assert, f, 102, "other"); |
michael@0 | 68 | map(assert, f, 200, "other"); |
michael@0 | 69 | map(assert, f, 201, "other"); |
michael@0 | 70 | map(assert, f, 202, "other"); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | exports.testJapanese = function(assert) { |
michael@0 | 74 | // Japanese doesn't have plural forms. |
michael@0 | 75 | let f = getRulesForLocale("ja"); |
michael@0 | 76 | map(assert, f, -1, "other"); |
michael@0 | 77 | map(assert, f, 0, "other"); |
michael@0 | 78 | map(assert, f, 1, "other"); |
michael@0 | 79 | map(assert, f, 1.5, "other"); |
michael@0 | 80 | map(assert, f, 2, "other"); |
michael@0 | 81 | map(assert, f, 100, "other"); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | require('sdk/test').run(exports); |