mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
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:
parent
e25ef66af6
commit
070990e993
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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() {
|
||||
|
@ -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,
|
||||
|
@ -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() {
|
||||
|
@ -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");
|
||||
});
|
||||
|
@ -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({
|
||||
|
@ -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()`.
|
||||
|
Loading…
Reference in New Issue
Block a user