Bug 1161677 - Expose dev mode state read-only through the navigator.hasFeature() api r=ehsan

This commit is contained in:
Fabrice Desré 2015-05-23 17:38:24 -07:00
parent 6b55b045b4
commit 2104397d2c
2 changed files with 25 additions and 1 deletions

View File

@ -1508,6 +1508,12 @@ Navigator::GetFeature(const nsAString& aName, ErrorResult& aRv)
}
#endif
// Mirror the dom.apps.developer_mode pref to let apps get it read-only.
if (aName.EqualsLiteral("dom.apps.developer_mode")) {
p->MaybeResolve(Preferences::GetBool("dom.apps.developer_mode", false));
return p.forget();
}
p->MaybeResolve(JS::UndefinedHandleValue);
return p.forget();
}

View File

@ -76,13 +76,31 @@ function createManifestTest(aFeature) {
}
}
function testDevMode(aExpected) {
return function() {
navigator.getFeature("dom.apps.developer_mode").then(res => {
is(res, aExpected, "dom.apps.developer_mode is " + aExpected);
runNextTest();
}, function() {
ok(false, "The Promise should not be rejected");
});
}
}
function enableDevMode() {
SpecialPowers.pushPrefEnv({"set": [["dom.apps.developer_mode", true]]}, runNextTest);
}
var currentTest = -1;
var tests = [
testNotSupported,
testNotSupportedManifest,
testSupported,
createManifestTest("manifest.origin"),
createManifestTest("manifest.redirects")
createManifestTest("manifest.redirects"),
testDevMode(false),
enableDevMode,
testDevMode(true)
];
function runNextTest() {