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 /devtools/client/shared/shim/test/test_service_prefs_defaults.html | |
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 'devtools/client/shared/shim/test/test_service_prefs_defaults.html')
-rw-r--r-- | devtools/client/shared/shim/test/test_service_prefs_defaults.html | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/devtools/client/shared/shim/test/test_service_prefs_defaults.html b/devtools/client/shared/shim/test/test_service_prefs_defaults.html new file mode 100644 index 000000000..d8933b74a --- /dev/null +++ b/devtools/client/shared/shim/test/test_service_prefs_defaults.html @@ -0,0 +1,71 @@ +<!DOCTYPE html> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1309384 +--> +<head> + <title>Test for Bug 1309384 - Services.prefs replacement defaults handling</title> + <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" + href="chrome://mochikit/content/tests/SimpleTest/test.css"> + +<script type="application/javascript;version=1.8"> +"use strict"; +var exports = {} +var module = {exports}; + +// Allow one require("raw!prefs...") to return some defaults, with the +// others being ignored. +var firstTime = true; +function require(something) { + if (!something.startsWith("raw!prefs!")) { + throw new Error("whoops"); + } + if (!firstTime) { + return ""; + } + firstTime = false; + return "pref('pref1', 'pref1default');\n" + + "pref('pref2', 'pref2default');\n" + + "pref('pref3', 'pref3default');\n"; +} + +// Pretend that one of the prefs was modifed by the user in an earlier session. +localStorage.setItem("Services.prefs:pref3", JSON.stringify({ + // string + type: 32, + defaultValue: "pref3default", + hasUserValue: true, + userValue: "glass winged butterfly" +})); + +</script> + + <script type="application/javascript;version=1.8" + src="resource://devtools/client/shared/shim/Services.js"></script> +</head> +<body> +<script type="application/javascript;version=1.8"> +"use strict"; + +is(Services.prefs.getCharPref("pref1"), "pref1default", "pref1 value"); +is(Services.prefs.getCharPref("pref2"), "pref2default", "pref2 value"); +is(Services.prefs.getCharPref("pref3"), "glass winged butterfly", "pref3 value"); + +// Only pref3 should be in local storage at this point. +is(localStorage.length, 1, "local storage is correct"); + +Services.prefs.setCharPref("pref2", "pref2override"); + +// Check that a default pref can be overridden properly + +// Workaround to reset the prefs helper and force it to read defaults & overrides again. +Services._prefs = null; +is(Services.prefs.getCharPref("pref2"), "pref2override", "pref2 value overridden"); + +// Clean up. +localStorage.clear(); + +</script> +</body> |