Bug 1216207 - Modify navigator.hasFeature method to implement new

late-customization feature detection and change the test as well
r=ehsan
This commit is contained in:
Juan Gomez 2015-10-27 13:39:35 +08:00
parent 9d6ee8543d
commit 181a49041d
2 changed files with 15 additions and 6 deletions

View File

@ -1607,9 +1607,10 @@ Navigator::HasFeature(const nsAString& aName, ErrorResult& aRv)
return nullptr;
}
// Hardcoded web-extensions feature which is b2g specific.
// Hardcoded extensions features which are b2g specific.
#ifdef MOZ_B2G
if (aName.EqualsLiteral("web-extensions")) {
if (aName.EqualsLiteral("web-extensions") ||
aName.EqualsLiteral("late-customization")) {
p->MaybeResolve(true);
return p.forget();
}

View File

@ -65,11 +65,19 @@ function testExtensions() {
return Promise.resolve();
}
return navigator.hasFeature("web-extensions").then(function(value) {
is(value, true, "Resolve the Promise with " + value + " for web-extensions");
}, function() {
ok(false, "The Promise should not be rejected");
var builtInFeatures = [
{feature: "web-extensions", value: true},
{feature: "late-customization", value: true}
];
builtInFeatures.forEach(function(x) {
navigator.hasFeature(x.feature).then(function(value) {
is(value, x.value, "Resolve the Promise with " + value + " for feature: " + x.feature);
}).catch(function(ex) {
ok(false, "The Promise should not be rejected");
});
});
return Promise.resolve();
}
SpecialPowers.pushPermissions([