Bug 1591102 - Let some SpecialPowers.pushPermissions callers use promises r=jdm

Some callers of SpecialPowers.pushPermissions wrapped the call in a
promise. That is not needed; directly use the returned promise instead.

Differential Revision: https://phabricator.services.mozilla.com/D50487

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Rob Wu 2019-10-27 15:28:41 +00:00
parent 20949d82c8
commit 34c77beb98
5 changed files with 20 additions and 37 deletions

View File

@ -1,16 +1,11 @@
async function addNotificationPermission(originString) {
return new Promise(resolve => {
SpecialPowers.pushPermissions(
[
{
type: "desktop-notification",
allow: true,
context: originString,
},
],
resolve
);
});
return SpecialPowers.pushPermissions([
{
type: "desktop-notification",
allow: true,
context: originString,
},
]);
}
/**

View File

@ -13,10 +13,8 @@ let registration;
let subscription;
const registerServiceWorker = async function() {
await new Promise(resolve => {
const perm = { type: "desktop-notification", allow: true, context: document };
SpecialPowers.pushPermissions([perm], resolve);
});
const perm = { type: "desktop-notification", allow: true, context: document };
await SpecialPowers.pushPermissions([perm]);
try {
registration = await navigator.serviceWorker.register("push-sw.js");

View File

@ -31,16 +31,11 @@ function log(msg) {
const autoplayPermission = "autoplay-media";
async function pushAutoplayAllowedPermission() {
return new Promise((resolve, reject) => {
SpecialPowers.pushPermissions(
[
{
type: autoplayPermission,
allow: true,
context: document,
},
],
resolve
);
});
return SpecialPowers.pushPermissions([
{
type: autoplayPermission,
allow: true,
context: document,
},
]);
}

View File

@ -43,9 +43,7 @@
async function run() {
ok(await SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Shockwave Flash"), "Should find allowed test flash plugin");
ok(!await SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Third Test Plug-in"), "Should not find disallowed plugin");
await new Promise(resolve => {
SpecialPowers.pushPermissions([{type: "plugin:flash", allow: true, context: document}], resolve);
});
await SpecialPowers.pushPermissions([{type: "plugin:flash", allow: true, context: document}]);
createNode("plugin-flash", "application/x-shockwave-flash-test");
createNode("disallowedPlugin", "application/x-third-test");

View File

@ -172,12 +172,9 @@ SimpleTest.registerCleanupFunction(async function() {
});
function setPushPermission(allow) {
return new Promise(resolve => {
SpecialPowers.pushPermissions(
[{ type: "desktop-notification", allow, context: document }],
resolve
);
});
return SpecialPowers.pushPermissions([
{ type: "desktop-notification", allow, context: document },
]);
}
function setupPrefs() {