Bug 1352791 - Use a pushPermissions helper for alerts b-c tests. r=MattN

MozReview-Commit-ID: E6tsp3TioBS

--HG--
extra : rebase_source : 0838676cb13b47f87b7ecf0d4c3fbcc510448954
This commit is contained in:
Matthew Noorenberghe 2017-10-09 18:49:54 -04:00
parent e25ef66af6
commit 070990e993
8 changed files with 24 additions and 32 deletions

View File

@ -6,9 +6,7 @@ support-files =
[browser_notification_close.js]
skip-if = os == 'win' # Bug 1227785
[browser_notification_do_not_disturb.js]
skip-if = (os == 'win' && bits == 32) # Bug 1352791
[browser_notification_open_settings.js]
[browser_notification_remove_permission.js]
[browser_notification_replace.js]
[browser_notification_tab_switching.js]
skip-if = os == "win" || os == "linux" # Bug 1243263

View File

@ -7,9 +7,8 @@ let notificationURL = "http://example.org/browser/browser/base/content/test/aler
let oldShowFavicons;
add_task(async function test_notificationClose() {
let pm = Services.perms;
let notificationURI = makeURI(notificationURL);
pm.add(notificationURI, "desktop-notification", pm.ALLOW_ACTION);
await addNotificationPermission(notificationURL);
oldShowFavicons = Services.prefs.getBoolPref("alerts.showFavicons");
Services.prefs.setBoolPref("alerts.showFavicons", true);

View File

@ -21,23 +21,22 @@ function test() {
return;
}
let pm = Services.perms;
registerCleanupFunction(function() {
ALERT_SERVICE.manualDoNotDisturb = false;
pm.remove(makeURI(notificationURL), "desktop-notification");
gBrowser.removeTab(tab);
window.restore();
});
pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION);
// Make sure that do-not-disturb is not enabled.
ok(!ALERT_SERVICE.manualDoNotDisturb, "Alert service should not be disabled when test starts");
ALERT_SERVICE.manualDoNotDisturb = false;
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
gBrowser.selectedTab = tab;
tab.linkedBrowser.addEventListener("load", onLoad, true);
addNotificationPermission(notificationURL).then(function openTab() {
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
gBrowser.selectedTab = tab;
tab.linkedBrowser.addEventListener("load", onLoad, true);
});
}
function onLoad() {

View File

@ -25,13 +25,7 @@ add_task(async function test_settingsOpen_observer() {
add_task(async function test_settingsOpen_button() {
info("Adding notification permission");
await new Promise(resolve => {
SpecialPowers.pushPermissions([{
type: "desktop-notification",
allow: true,
context: notificationURL,
}], resolve);
});
await addNotificationPermission(notificationURL);
await BrowserTestUtils.withNewTab({
gBrowser,

View File

@ -8,18 +8,16 @@ var permRemoved = false;
function test() {
waitForExplicitFinish();
let pm = Services.perms;
registerCleanupFunction(function() {
pm.remove(makeURI(notificationURL), "desktop-notification");
gBrowser.removeTab(tab);
window.restore();
});
pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION);
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
gBrowser.selectedTab = tab;
tab.linkedBrowser.addEventListener("load", onLoad, true);
addNotificationPermission(notificationURL).then(function openTab() {
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
gBrowser.selectedTab = tab;
tab.linkedBrowser.addEventListener("load", onLoad, true);
});
}
function onLoad() {

View File

@ -3,8 +3,7 @@
let notificationURL = "http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html";
add_task(async function test_notificationReplace() {
let pm = Services.perms;
pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION);
await addNotificationPermission(notificationURL);
await BrowserTestUtils.withNewTab({
gBrowser,
@ -32,7 +31,3 @@ add_task(async function test_notificationReplace() {
});
});
});
add_task(async function cleanup() {
Services.perms.remove(makeURI(notificationURL), "desktop-notification");
});

View File

@ -10,8 +10,7 @@ var notificationURL = "http://example.org/browser/browser/base/content/test/aler
var newWindowOpenedFromTab;
add_task(async function test_notificationPreventDefaultAndSwitchTabs() {
let pm = Services.perms;
pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION);
await addNotificationPermission(notificationURL);
let originalTab = gBrowser.selectedTab;
await BrowserTestUtils.withNewTab({

View File

@ -1,3 +1,13 @@
async function addNotificationPermission(originString) {
return new Promise(resolve => {
SpecialPowers.pushPermissions([{
type: "desktop-notification",
allow: true,
context: originString,
}], resolve);
});
}
/**
* Similar to `BrowserTestUtils.closeWindow`, but
* doesn't call `window.close()`.