toolkit/modules/tests/browser/browser_InlineSpellChecker.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 function test() {
michael@0 2 let tempScope = {};
michael@0 3 Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm", tempScope);
michael@0 4 let InlineSpellChecker = tempScope.InlineSpellChecker;
michael@0 5
michael@0 6 ok(InlineSpellChecker, "InlineSpellChecker class exists");
michael@0 7 for (var fname in tests) {
michael@0 8 tests[fname]();
michael@0 9 }
michael@0 10 }
michael@0 11
michael@0 12 let tests = {
michael@0 13 // Test various possible dictionary name to ensure they display as expected.
michael@0 14 // XXX: This only works for the 'en-US' locale, as the testing involves localized output.
michael@0 15 testDictionaryDisplayNames: function() {
michael@0 16 let isc = new InlineSpellChecker();
michael@0 17
michael@0 18 // Check non-well-formed language tag.
michael@0 19 is(isc.getDictionaryDisplayName("-invalid-"), "-invalid-", "'-invalid-' should display as '-invalid-'");
michael@0 20
michael@0 21 // XXX: It isn't clear how we'd ideally want to display variant subtags.
michael@0 22
michael@0 23 // Check valid language subtag.
michael@0 24 is(isc.getDictionaryDisplayName("en"), "English", "'en' should display as 'English'");
michael@0 25 is(isc.getDictionaryDisplayName("en-fonipa"), "English (fonipa)", "'en-fonipa' should display as 'English (fonipa)'");
michael@0 26 is(isc.getDictionaryDisplayName("en-qxqaaaaz"), "English (qxqaaaaz)", "'en-qxqaaaaz' should display as 'English (qxqaaaaz)'");
michael@0 27
michael@0 28 // Check valid language subtag and valid region subtag.
michael@0 29 is(isc.getDictionaryDisplayName("en-US"), "English (United States)", "'en-US' should display as 'English (United States)'");
michael@0 30 is(isc.getDictionaryDisplayName("en-US-fonipa"), "English (United States) (fonipa)", "'en-US-fonipa' should display as 'English (United States) (fonipa)'");
michael@0 31 is(isc.getDictionaryDisplayName("en-US-qxqaaaaz"), "English (United States) (qxqaaaaz)", "'en-US-qxqaaaaz' should display as 'English (United States) (qxqaaaaz)'");
michael@0 32
michael@0 33 // Check valid language subtag and invalid but well-formed region subtag.
michael@0 34 is(isc.getDictionaryDisplayName("en-QZ"), "English (QZ)", "'en-QZ' should display as 'English (QZ)'");
michael@0 35 is(isc.getDictionaryDisplayName("en-QZ-fonipa"), "English (QZ) (fonipa)", "'en-QZ-fonipa' should display as 'English (QZ) (fonipa)'");
michael@0 36 is(isc.getDictionaryDisplayName("en-QZ-qxqaaaaz"), "English (QZ) (qxqaaaaz)", "'en-QZ-qxqaaaaz' should display as 'English (QZ) (qxqaaaaz)'");
michael@0 37
michael@0 38 // Check valid language subtag and valid script subtag.
michael@0 39 todo_is(isc.getDictionaryDisplayName("en-Cyrl"), "English / Cyrillic", "'en-Cyrl' should display as 'English / Cyrillic'");
michael@0 40 todo_is(isc.getDictionaryDisplayName("en-Cyrl-fonipa"), "English / Cyrillic (fonipa)", "'en-Cyrl-fonipa' should display as 'English / Cyrillic (fonipa)'");
michael@0 41 todo_is(isc.getDictionaryDisplayName("en-Cyrl-qxqaaaaz"), "English / Cyrillic (qxqaaaaz)", "'en-Cyrl-qxqaaaaz' should display as 'English / Cyrillic (qxqaaaaz)'");
michael@0 42 todo_is(isc.getDictionaryDisplayName("en-Cyrl-US"), "English (United States) / Cyrillic", "'en-Cyrl-US' should display as 'English (United States) / Cyrillic'");
michael@0 43 todo_is(isc.getDictionaryDisplayName("en-Cyrl-US-fonipa"), "English (United States) / Cyrillic (fonipa)", "'en-Cyrl-US-fonipa' should display as 'English (United States) / Cyrillic (fonipa)'");
michael@0 44 todo_is(isc.getDictionaryDisplayName("en-Cyrl-US-qxqaaaaz"), "English (United States) / Cyrillic (qxqaaaaz)", "'en-Cyrl-US-qxqaaaaz' should display as 'English (United States) / Cyrillic (qxqaaaaz)'");
michael@0 45 todo_is(isc.getDictionaryDisplayName("en-Cyrl-QZ"), "English (QZ) / Cyrillic", "'en-Cyrl-QZ' should display as 'English (QZ) / Cyrillic'");
michael@0 46 todo_is(isc.getDictionaryDisplayName("en-Cyrl-QZ-fonipa"), "English (QZ) / Cyrillic (fonipa)", "'en-Cyrl-QZ-fonipa' should display as 'English (QZ) / Cyrillic (fonipa)'");
michael@0 47 todo_is(isc.getDictionaryDisplayName("en-Cyrl-QZ-qxqaaaaz"), "English (QZ) / Cyrillic (qxqaaaaz)", "'en-Cyrl-QZ-qxqaaaaz' should display as 'English (QZ) / Cyrillic (qxqaaaaz)'");
michael@0 48
michael@0 49 // Check valid language subtag and invalid but well-formed script subtag.
michael@0 50 is(isc.getDictionaryDisplayName("en-Qaaz"), "English / Qaaz", "'en-Qaaz' should display as 'English / Qaaz'");
michael@0 51 is(isc.getDictionaryDisplayName("en-Qaaz-fonipa"), "English / Qaaz (fonipa)", "'en-Qaaz-fonipa' should display as 'English / Qaaz (fonipa)'");
michael@0 52 is(isc.getDictionaryDisplayName("en-Qaaz-qxqaaaaz"), "English / Qaaz (qxqaaaaz)", "'en-Qaaz-qxqaaaaz' should display as 'English / Qaaz (qxqaaaaz)'");
michael@0 53 is(isc.getDictionaryDisplayName("en-Qaaz-US"), "English (United States) / Qaaz", "'en-Qaaz-US' should display as 'English (United States) / Qaaz'");
michael@0 54 is(isc.getDictionaryDisplayName("en-Qaaz-US-fonipa"), "English (United States) / Qaaz (fonipa)", "'en-Qaaz-US-fonipa' should display as 'English (United States) / Qaaz (fonipa)'");
michael@0 55 is(isc.getDictionaryDisplayName("en-Qaaz-US-qxqaaaaz"), "English (United States) / Qaaz (qxqaaaaz)", "'en-Qaaz-US-qxqaaaaz' should display as 'English (United States) / Qaaz (qxqaaaaz)'");
michael@0 56 is(isc.getDictionaryDisplayName("en-Qaaz-QZ"), "English (QZ) / Qaaz", "'en-Qaaz-QZ' should display as 'English (QZ) / Qaaz'");
michael@0 57 is(isc.getDictionaryDisplayName("en-Qaaz-QZ-fonipa"), "English (QZ) / Qaaz (fonipa)", "'en-Qaaz-QZ-fonipa' should display as 'English (QZ) / Qaaz (fonipa)'");
michael@0 58 is(isc.getDictionaryDisplayName("en-Qaaz-QZ-qxqaaaaz"), "English (QZ) / Qaaz (qxqaaaaz)", "'en-Qaaz-QZ-qxqaaaaz' should display as 'English (QZ) / Qaaz (qxqaaaaz)'");
michael@0 59
michael@0 60 // Check invalid but well-formed language subtag.
michael@0 61 is(isc.getDictionaryDisplayName("qaz"), "qaz", "'qaz' should display as 'qaz'");
michael@0 62 is(isc.getDictionaryDisplayName("qaz-fonipa"), "qaz (fonipa)", "'qaz-fonipa' should display as 'qaz (fonipa)'");
michael@0 63 is(isc.getDictionaryDisplayName("qaz-qxqaaaaz"), "qaz (qxqaaaaz)", "'qaz-qxqaaaaz' should display as 'qaz (qxqaaaaz)'");
michael@0 64
michael@0 65 // Check invalid but well-formed language subtag and valid region subtag.
michael@0 66 is(isc.getDictionaryDisplayName("qaz-US"), "qaz (United States)", "'qaz-US' should display as 'qaz (United States)'");
michael@0 67 is(isc.getDictionaryDisplayName("qaz-US-fonipa"), "qaz (United States) (fonipa)", "'qaz-US-fonipa' should display as 'qaz (United States) (fonipa)'");
michael@0 68 is(isc.getDictionaryDisplayName("qaz-US-qxqaaaaz"), "qaz (United States) (qxqaaaaz)", "'qaz-US-qxqaaaaz' should display as 'qaz (United States) (qxqaaaaz)'");
michael@0 69
michael@0 70 // Check invalid but well-formed language subtag and invalid but well-formed region subtag.
michael@0 71 is(isc.getDictionaryDisplayName("qaz-QZ"), "qaz (QZ)", "'qaz-QZ' should display as 'qaz (QZ)'");
michael@0 72 is(isc.getDictionaryDisplayName("qaz-QZ-fonipa"), "qaz (QZ) (fonipa)", "'qaz-QZ-fonipa' should display as 'qaz (QZ) (fonipa)'");
michael@0 73 is(isc.getDictionaryDisplayName("qaz-QZ-qxqaaaaz"), "qaz (QZ) (qxqaaaaz)", "'qaz-QZ-qxqaaaaz' should display as 'qaz (QZ) (qxqaaaaz)'");
michael@0 74
michael@0 75 // Check invalid but well-formed language subtag and valid script subtag.
michael@0 76 todo_is(isc.getDictionaryDisplayName("qaz-Cyrl"), "qaz / Cyrillic", "'qaz-Cyrl' should display as 'qaz / Cyrillic'");
michael@0 77 todo_is(isc.getDictionaryDisplayName("qaz-Cyrl-fonipa"), "qaz / Cyrillic (fonipa)", "'qaz-Cyrl-fonipa' should display as 'qaz / Cyrillic (fonipa)'");
michael@0 78 todo_is(isc.getDictionaryDisplayName("qaz-Cyrl-qxqaaaaz"), "qaz / Cyrillic (qxqaaaaz)", "'qaz-Cyrl-qxqaaaaz' should display as 'qaz / Cyrillic (qxqaaaaz)'");
michael@0 79 todo_is(isc.getDictionaryDisplayName("qaz-Cyrl-US"), "qaz (United States) / Cyrillic", "'qaz-Cyrl-US' should display as 'qaz (United States) / Cyrillic'");
michael@0 80 todo_is(isc.getDictionaryDisplayName("qaz-Cyrl-US-fonipa"), "qaz (United States) / Cyrillic (fonipa)", "'qaz-Cyrl-US-fonipa' should display as 'qaz (United States) / Cyrillic (fonipa)'");
michael@0 81 todo_is(isc.getDictionaryDisplayName("qaz-Cyrl-US-qxqaaaaz"), "qaz (United States) / Cyrillic (qxqaaaaz)", "'qaz-Cyrl-US-qxqaaaaz' should display as 'qaz (United States) / Cyrillic (qxqaaaaz)'");
michael@0 82 todo_is(isc.getDictionaryDisplayName("qaz-Cyrl-QZ"), "qaz (QZ) / Cyrillic", "'qaz-Cyrl-QZ' should display as 'qaz (QZ) / Cyrillic'");
michael@0 83 todo_is(isc.getDictionaryDisplayName("qaz-Cyrl-QZ-fonipa"), "qaz (QZ) / Cyrillic (fonipa)", "'qaz-Cyrl-QZ-fonipa' should display as 'qaz (QZ) / Cyrillic (fonipa)'");
michael@0 84 todo_is(isc.getDictionaryDisplayName("qaz-Cyrl-QZ-qxqaaaaz"), "qaz (QZ) / Cyrillic (qxqaaaaz)", "'qaz-Cyrl-QZ-qxqaaaaz' should display as 'qaz (QZ) / Cyrillic (qxqaaaaz)'");
michael@0 85
michael@0 86 // Check invalid but well-formed language subtag and invalid but well-formed script subtag.
michael@0 87 is(isc.getDictionaryDisplayName("qaz-Qaaz"), "qaz / Qaaz", "'qaz-Qaaz' should display as 'qaz / Qaaz'");
michael@0 88 is(isc.getDictionaryDisplayName("qaz-Qaaz-fonipa"), "qaz / Qaaz (fonipa)", "'qaz-Qaaz-fonipa' should display as 'qaz / Qaaz (fonipa)'");
michael@0 89 is(isc.getDictionaryDisplayName("qaz-Qaaz-qxqaaaaz"), "qaz / Qaaz (qxqaaaaz)", "'qaz-Qaaz-qxqaaaaz' should display as 'qaz / Qaaz (qxqaaaaz)'");
michael@0 90 is(isc.getDictionaryDisplayName("qaz-Qaaz-US"), "qaz (United States) / Qaaz", "'qaz-Qaaz-US' should display as 'qaz (United States) / Qaaz'");
michael@0 91 is(isc.getDictionaryDisplayName("qaz-Qaaz-US-fonipa"), "qaz (United States) / Qaaz (fonipa)", "'qaz-Qaaz-US-fonipa' should display as 'qaz (United States) / Qaaz (fonipa)'");
michael@0 92 is(isc.getDictionaryDisplayName("qaz-Qaaz-US-qxqaaaaz"), "qaz (United States) / Qaaz (qxqaaaaz)", "'qaz-Qaaz-US-qxqaaaaz' should display as 'qaz (United States) / Qaaz (qxqaaaaz)'");
michael@0 93 is(isc.getDictionaryDisplayName("qaz-Qaaz-QZ"), "qaz (QZ) / Qaaz", "'qaz-Qaaz-QZ' should display as 'qaz (QZ) / Qaaz'");
michael@0 94 is(isc.getDictionaryDisplayName("qaz-Qaaz-QZ-fonipa"), "qaz (QZ) / Qaaz (fonipa)", "'qaz-Qaaz-QZ-fonipa' should display as 'qaz (QZ) / Qaaz (fonipa)'");
michael@0 95 is(isc.getDictionaryDisplayName("qaz-Qaaz-QZ-qxqaaaaz"), "qaz (QZ) / Qaaz (qxqaaaaz)", "'qaz-Qaaz-QZ-qxqaaaaz' should display as 'qaz (QZ) / Qaaz (qxqaaaaz)'");
michael@0 96
michael@0 97 // Check multiple variant subtags.
michael@0 98 todo_is(isc.getDictionaryDisplayName("en-Cyrl-US-fonipa-fonxsamp"), "English (United States) / Cyrillic (fonipa / fonxsamp)", "'en-Cyrl-US-fonipa-fonxsamp' should display as 'English (United States) / Cyrillic (fonipa / fonxsamp)'");
michael@0 99 todo_is(isc.getDictionaryDisplayName("en-Cyrl-US-fonipa-qxqaaaaz"), "English (United States) / Cyrillic (fonipa / qxqaaaaz)", "'en-Cyrl-US-fonipa-qxqaaaaz' should display as 'English (United States) / Cyrillic (fonipa / qxqaaaaz)'");
michael@0 100 todo_is(isc.getDictionaryDisplayName("en-Cyrl-US-fonipa-fonxsamp-qxqaaaaz"), "English (United States) / Cyrillic (fonipa / fonxsamp / qxqaaaaz)", "'en-Cyrl-US-fonipa-fonxsamp-qxqaaaaz' should display as 'English (United States) / Cyrillic (fonipa / fonxsamp / qxqaaaaz)'");
michael@0 101 is(isc.getDictionaryDisplayName("qaz-Qaaz-QZ-fonipa-fonxsamp"), "qaz (QZ) / Qaaz (fonipa / fonxsamp)", "'qaz-Qaaz-QZ-fonipa-fonxsamp' should display as 'qaz (QZ) / Qaaz (fonipa / fonxsamp)'");
michael@0 102 is(isc.getDictionaryDisplayName("qaz-Qaaz-QZ-fonipa-qxqaaaaz"), "qaz (QZ) / Qaaz (fonipa / qxqaaaaz)", "'qaz-Qaaz-QZ-fonipa-qxqaaaaz' should display as 'qaz (QZ) / Qaaz (fonipa / qxqaaaaz)'");
michael@0 103 is(isc.getDictionaryDisplayName("qaz-Qaaz-QZ-fonipa-fonxsamp-qxqaaaaz"), "qaz (QZ) / Qaaz (fonipa / fonxsamp / qxqaaaaz)", "'qaz-Qaaz-QZ-fonipa-fonxsamp-qxqaaaaz' should display as 'qaz (QZ) / Qaaz (fonipa / fonxsamp / qxqaaaaz)'");
michael@0 104
michael@0 105 // Check numeric region subtag.
michael@0 106 todo_is(isc.getDictionaryDisplayName("es-419"), "Spanish (Latin America and the Caribbean)", "'es-419' should display as 'Spanish (Latin America and the Caribbean)'");
michael@0 107
michael@0 108 // Check that extension subtags are ignored.
michael@0 109 todo_is(isc.getDictionaryDisplayName("en-Cyrl-t-en-latn-m0-ungegn-2007"), "English / Cyrillic", "'en-Cyrl-t-en-latn-m0-ungegn-2007' should display as 'English / Cyrillic'");
michael@0 110
michael@0 111 // Check that privateuse subtags are ignored.
michael@0 112 is(isc.getDictionaryDisplayName("en-x-ignore"), "English", "'en-x-ignore' should display as 'English'");
michael@0 113 is(isc.getDictionaryDisplayName("en-x-ignore-this"), "English", "'en-x-ignore-this' should display as 'English'");
michael@0 114 is(isc.getDictionaryDisplayName("en-x-ignore-this-subtag"), "English", "'en-x-ignore-this-subtag' should display as 'English'");
michael@0 115
michael@0 116 // Check that both extension and privateuse subtags are ignored.
michael@0 117 todo_is(isc.getDictionaryDisplayName("en-Cyrl-t-en-latn-m0-ungegn-2007-x-ignore-this-subtag"), "English / Cyrillic", "'en-Cyrl-t-en-latn-m0-ungegn-2007-x-ignore-this-subtag' should display as 'English / Cyrillic'");
michael@0 118
michael@0 119 // XXX: Check grandfathered tags.
michael@0 120 },
michael@0 121 };

mercurial