diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /extensions/pref/autoconfig/test | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'extensions/pref/autoconfig/test')
5 files changed, 123 insertions, 0 deletions
diff --git a/extensions/pref/autoconfig/test/unit/autoconfig-latin1.cfg b/extensions/pref/autoconfig/test/unit/autoconfig-latin1.cfg new file mode 100644 index 000000000..6b96c65fd --- /dev/null +++ b/extensions/pref/autoconfig/test/unit/autoconfig-latin1.cfg @@ -0,0 +1,6 @@ +// # don't remove this comment! (the first line is ignored by Mozilla) +// © +lockPref("_test.string.ASCII", "ASCII"); +lockPref("_test.string.non-ASCII", "日本語"); +lockPref("_test.string.getPref", getPref("_test.string.non-ASCII")); +lockPref("_test.string.gIsUTF8", String(this.gIsUTF8)); diff --git a/extensions/pref/autoconfig/test/unit/autoconfig-utf8.cfg b/extensions/pref/autoconfig/test/unit/autoconfig-utf8.cfg new file mode 100644 index 000000000..eec789942 --- /dev/null +++ b/extensions/pref/autoconfig/test/unit/autoconfig-utf8.cfg @@ -0,0 +1,6 @@ +// # don't remove this comment! (the first line is ignored by Mozilla) + +lockPref("_test.string.ASCII", "UTF-8"); +lockPref("_test.string.non-ASCII", "日本語"); +lockPref("_test.string.getPref", getPref("_test.string.non-ASCII")); +lockPref("_test.string.gIsUTF8", String(this.gIsUTF8)); diff --git a/extensions/pref/autoconfig/test/unit/autoconfig.js b/extensions/pref/autoconfig/test/unit/autoconfig.js new file mode 100644 index 000000000..f831d95b6 --- /dev/null +++ b/extensions/pref/autoconfig/test/unit/autoconfig.js @@ -0,0 +1,4 @@ +pref("general.config.filename", "autoconfig.cfg"); +pref("general.config.vendor", "autoconfig"); +pref("general.config.obscure_value", 0); + diff --git a/extensions/pref/autoconfig/test/unit/test_autoconfig_nonascii.js b/extensions/pref/autoconfig/test/unit/test_autoconfig_nonascii.js new file mode 100644 index 000000000..a42bc1219 --- /dev/null +++ b/extensions/pref/autoconfig/test/unit/test_autoconfig_nonascii.js @@ -0,0 +1,97 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +var {classes: Cc, interfaces: Ci, results: Cr} = Components; + +function run_test() { + let dirSvc = Cc["@mozilla.org/file/directory_service;1"]. + getService(Ci.nsIProperties); + let obsvc = Cc['@mozilla.org/observer-service;1']. + getService(Ci.nsIObserverService); + let ps = Cc["@mozilla.org/preferences-service;1"]. + getService(Ci.nsIPrefService); + let defaultPrefs = ps.getDefaultBranch(null); + let prefs = ps.getBranch(null); + + let greD = dirSvc.get("GreD", Ci.nsIFile); + let defaultPrefD = dirSvc.get("PrfDef", Ci.nsIFile); + let testDir = do_get_cwd(); + + try { + let autoConfigJS = testDir.clone(); + autoConfigJS.append("autoconfig.js"); + autoConfigJS.copyTo(defaultPrefD, "autoconfig.js"); + + // Make sure nsReadConfig is initialized. + Cc["@mozilla.org/readconfig;1"].getService(Ci.nsISupports); + ps.resetPrefs(); + + var tests = [{ + filename: "autoconfig-utf8.cfg", + prefs: { + "_test.string.ASCII": "UTF-8", + "_test.string.non-ASCII": "日本語", + "_test.string.getPref": "日本語", + "_test.string.gIsUTF8": "true" + } + }, { + filename: "autoconfig-latin1.cfg", + prefs: { + "_test.string.ASCII": "ASCII", + "_test.string.non-ASCII": "日本語", + "_test.string.getPref": "日本語", + "_test.string.gIsUTF8": "false", + } + }]; + + function testAutoConfig(test) { + // Make sure pref values are unset. + for (let prefName in test.prefs) { + do_check_eq(Ci.nsIPrefBranch.PREF_INVALID, prefs.getPrefType(prefName)); + } + + let autoConfigCfg = testDir.clone(); + autoConfigCfg.append(test.filename); + autoConfigCfg.copyTo(greD, "autoconfig.cfg"); + + obsvc.notifyObservers(ps, "prefservice:before-read-userprefs", null); + + for (let prefName in test.prefs) { + do_check_eq(test.prefs[prefName], + prefs.getComplexValue(prefName, Ci.nsISupportsString).data); + } + + ps.resetPrefs(); + // Make sure pref values are reset. + for (let prefName in test.prefs) { + do_check_eq(Ci.nsIPrefBranch.PREF_INVALID, prefs.getPrefType(prefName)); + } + } + + tests.forEach(testAutoConfig); + + } finally { + try { + let autoConfigJS = defaultPrefD.clone(); + autoConfigJS.append("autoconfig.js"); + autoConfigJS.remove(false); + } catch (e) { + if (e.result != Cr.NS_ERROR_FILE_NOT_FOUND) { + throw e; + } + } + + try { + let autoConfigCfg = greD.clone(); + autoConfigCfg.append("autoconfig.cfg"); + autoConfigCfg.remove(false); + } catch (e) { + if (e.result != Cr.NS_ERROR_FILE_NOT_FOUND) { + throw e; + } + } + + ps.resetPrefs(); + } +} + diff --git a/extensions/pref/autoconfig/test/unit/xpcshell.ini b/extensions/pref/autoconfig/test/unit/xpcshell.ini new file mode 100644 index 000000000..4806363e5 --- /dev/null +++ b/extensions/pref/autoconfig/test/unit/xpcshell.ini @@ -0,0 +1,10 @@ +[DEFAULT] +head = +tail = +skip-if = toolkit == 'android' +support-files = + autoconfig-latin1.cfg + autoconfig-utf8.cfg + autoconfig.js + +[test_autoconfig_nonascii.js] |