зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 3a615fbeed50 (bug 1216271) for windows bc1 test failures and crashes
This commit is contained in:
Родитель
0757435b88
Коммит
5282e3c38d
|
@ -1,13 +1,11 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
head.js
|
||||
file_dom_notifications.html
|
||||
|
||||
[browser_notification_close.js]
|
||||
[browser_notification_do_not_disturb.js]
|
||||
[browser_notification_open_settings.js]
|
||||
[browser_notification_remove_permission.js]
|
||||
[browser_notification_permission_migration.js]
|
||||
|
||||
[browser_notification_tab_switching.js]
|
||||
skip-if = buildapp == 'mulet' || e10s # Bug 1100662 - content access causing uncaught exception - Error: cannot ipc non-cpow object at chrome://mochitests/content/browser/browser/base/content/test/general/browser_notification_tab_switching.js:32 (or in RemoteAddonsChild.jsm)
|
||||
|
|
|
@ -2,6 +2,17 @@
|
|||
|
||||
var notificationURL = "http://example.org/browser/browser/base/content/test/alerts/file_dom_notifications.html";
|
||||
|
||||
function waitForCloseWindow(window) {
|
||||
return new Promise(function(resolve) {
|
||||
Services.ww.registerNotification(function observer(subject, topic, data) {
|
||||
if (topic == "domwindowclosed" && subject == window) {
|
||||
Services.ww.unregisterNotification(observer);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function* test_settingsOpen_observer() {
|
||||
info("Opening a dummy tab so openPreferences=>switchToTabHavingURI doesn't use the blank tab.");
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
|
@ -41,7 +52,7 @@ add_task(function* test_settingsOpen_button() {
|
|||
return;
|
||||
}
|
||||
|
||||
let closePromise = promiseWindowClosed(alertWindow);
|
||||
let closePromise = waitForCloseWindow(alertWindow);
|
||||
let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, "about:preferences#content");
|
||||
let openSettingsMenuItem = alertWindow.document.getElementById("openSettingsMenuItem");
|
||||
openSettingsMenuItem.click();
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
const UI_VERSION = 32;
|
||||
|
||||
var gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"]
|
||||
.getService(Ci.nsIObserver);
|
||||
var notificationURI = makeURI("http://example.org");
|
||||
var pm = Services.perms;
|
||||
var currentUIVersion;
|
||||
|
||||
add_task(function* test_permissionMigration() {
|
||||
currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
|
||||
Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
|
||||
pm.add(notificationURI, "desktop-notification", pm.ALLOW_ACTION);
|
||||
|
||||
if ("@mozilla.org/system-alerts-service;1" in Cc) {
|
||||
ok(true, "Notifications don't use XUL windows on all platforms.");
|
||||
return;
|
||||
}
|
||||
|
||||
info("Waiting for migration notification");
|
||||
let alertWindowPromise = promiseAlertWindow();
|
||||
gBrowserGlue.observe(null, "browser-glue-test", "force-ui-migration");
|
||||
let alertWindow = yield alertWindowPromise;
|
||||
|
||||
info("Clicking on notification");
|
||||
let url = Services.urlFormatter.formatURLPref("browser.push.warning.infoURL");
|
||||
let closePromise = promiseWindowClosed(alertWindow);
|
||||
let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, url);
|
||||
EventUtils.synthesizeMouseAtCenter(alertWindow.document.getElementById("alertTitleLabel"), {}, alertWindow);
|
||||
|
||||
info("Waiting for migration info tab");
|
||||
let tab = yield tabPromise;
|
||||
ok(tab, "The migration info tab opened");
|
||||
|
||||
yield closePromise;
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(function* cleanup() {
|
||||
Services.prefs.setIntPref("browser.migration.version", currentUIVersion);
|
||||
pm.remove(notificationURI, "desktop-notification");
|
||||
});
|
|
@ -1,34 +0,0 @@
|
|||
function promiseAlertWindow() {
|
||||
return new Promise(function(resolve) {
|
||||
let listener = {
|
||||
onOpenWindow(window) {
|
||||
let alertWindow = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
|
||||
alertWindow.addEventListener("load", function onLoad() {
|
||||
alertWindow.removeEventListener("load", onLoad);
|
||||
let windowType = alertWindow.document.documentElement.getAttribute("windowtype");
|
||||
if (windowType != "alert:alert") {
|
||||
return;
|
||||
}
|
||||
Services.wm.removeListener(listener);
|
||||
resolve(alertWindow);
|
||||
});
|
||||
},
|
||||
};
|
||||
Services.wm.addListener(listener);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* `promiseWindowClosed` is similar to `BrowserTestUtils.closeWindow`, but
|
||||
* doesn't call `window.close()`.
|
||||
*/
|
||||
function promiseWindowClosed(window) {
|
||||
return new Promise(function(resolve) {
|
||||
Services.ww.registerNotification(function observer(subject, topic, data) {
|
||||
if (topic == "domwindowclosed" && subject == window) {
|
||||
Services.ww.unregisterNotification(observer);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
|
@ -187,9 +187,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
|
|||
XPCOMUtils.defineLazyServiceGetter(this, "WindowsUIUtils",
|
||||
"@mozilla.org/windows-ui-utils;1", "nsIWindowsUIUtils");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "AlertsService",
|
||||
"@mozilla.org/alerts-service;1", "nsIAlertsService");
|
||||
|
||||
const ABOUT_NEWTAB = "about:newtab";
|
||||
|
||||
const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
|
||||
|
@ -1567,6 +1564,16 @@ BrowserGlue.prototype = {
|
|||
if (actions.indexOf("showAlert") == -1)
|
||||
return;
|
||||
|
||||
let notifier;
|
||||
try {
|
||||
notifier = Cc["@mozilla.org/alerts-service;1"].
|
||||
getService(Ci.nsIAlertsService);
|
||||
}
|
||||
catch (e) {
|
||||
// nsIAlertsService is not available for this platform
|
||||
return;
|
||||
}
|
||||
|
||||
let title = getNotifyString({propName: "alertTitle",
|
||||
stringName: "puAlertTitle",
|
||||
stringParams: [appName]});
|
||||
|
@ -1587,11 +1594,10 @@ BrowserGlue.prototype = {
|
|||
try {
|
||||
// This will throw NS_ERROR_NOT_AVAILABLE if the notification cannot
|
||||
// be displayed per the idl.
|
||||
AlertsService.showAlertNotification(null, title, text,
|
||||
true, url, clickCallback);
|
||||
notifier.showAlertNotification(null, title, text,
|
||||
true, url, clickCallback);
|
||||
}
|
||||
catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1871,7 +1877,7 @@ BrowserGlue.prototype = {
|
|||
},
|
||||
|
||||
_migrateUI: function BG__migrateUI() {
|
||||
const UI_VERSION = 32;
|
||||
const UI_VERSION = 31;
|
||||
const BROWSER_DOCURL = "chrome://browser/content/browser.xul";
|
||||
let currentUIVersion = 0;
|
||||
try {
|
||||
|
@ -2212,49 +2218,10 @@ BrowserGlue.prototype = {
|
|||
xulStore.removeValue(BROWSER_DOCURL, "home-button", "class");
|
||||
}
|
||||
|
||||
if (currentUIVersion < 32) {
|
||||
this._notifyNotificationsUpgrade();
|
||||
}
|
||||
|
||||
// Update the migration version.
|
||||
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
|
||||
},
|
||||
|
||||
_hasExistingNotificationPermission: function BG__hasExistingNotificationPermission() {
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let permission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
if (permission.type == "desktop-notification") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_notifyNotificationsUpgrade: function BG__notifyNotificationsUpgrade() {
|
||||
if (!this._hasExistingNotificationPermission()) {
|
||||
return;
|
||||
}
|
||||
function clickCallback(subject, topic, data) {
|
||||
if (topic != "alertclickcallback")
|
||||
return;
|
||||
let win = RecentWindow.getMostRecentBrowserWindow();
|
||||
win.openUILinkIn(data, "tab");
|
||||
}
|
||||
let imageURL = "chrome://browser/skin/web-notifications-icon.svg";
|
||||
let title = gBrowserBundle.GetStringFromName("webNotifications.upgradeTitle");
|
||||
let text = gBrowserBundle.GetStringFromName("webNotifications.upgradeInfo");
|
||||
let url = Services.urlFormatter.formatURLPref("browser.push.warning.infoURL");
|
||||
|
||||
try {
|
||||
AlertsService.showAlertNotification(imageURL, title, text,
|
||||
true, url, clickCallback);
|
||||
}
|
||||
catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
},
|
||||
|
||||
// ------------------------------
|
||||
// public nsIBrowserGlue members
|
||||
// ------------------------------
|
||||
|
|
|
@ -382,10 +382,6 @@ webNotifications.alwaysReceive.accesskey=A
|
|||
webNotifications.neverShow=Always Block Notifications
|
||||
webNotifications.neverShow.accesskey=N
|
||||
webNotifications.receiveFromSite=Would you like to receive notifications from this site?
|
||||
# LOCALIZATION NOTE (webNotifications.upgradeTitle): When using native notifications on OS X, the title may be truncated around 32 characters.
|
||||
webNotifications.upgradeTitle=Notifications have been upgraded
|
||||
# LOCALIZATION NOTE (webNotifications.upgradeInfo): When using native notifications on OS X, the body may be truncated around 100 characters in some views.
|
||||
webNotifications.upgradeInfo=You will receive notifications from sites, even those not open in a tab. Click to learn more.
|
||||
|
||||
# Pointer lock UI
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче