Bug 1357812 - Remove "Upgraded notifications" notification from UI migration. r?kitcambridge draft
authorDão Gottwald <dao@mozilla.com>
Wed, 19 Apr 2017 18:43:00 +0200
changeset 565254 6710fdfe319b62d67c37d9d8cf5ba805905e777f
parent 565207 ef8d16ae0d0d5d5dc09c7a0d2463bde16b31b174
child 624947 39afcd28851ae979f6fc9fd6df50656ac62739cc
push id54819
push userdgottwald@mozilla.com
push dateWed, 19 Apr 2017 17:00:39 +0000
reviewerskitcambridge
bugs1357812
milestone55.0a1
Bug 1357812 - Remove "Upgraded notifications" notification from UI migration. r?kitcambridge MozReview-Commit-ID: 4hrPTyqQ9ge
browser/base/content/test/alerts/browser.ini
browser/base/content/test/alerts/browser_notification_permission_migration.js
browser/base/content/test/alerts/head.js
browser/components/nsBrowserGlue.js
browser/locales/en-US/chrome/browser/browser.properties
--- a/browser/base/content/test/alerts/browser.ini
+++ b/browser/base/content/test/alerts/browser.ini
@@ -2,11 +2,10 @@
 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_replace.js]
 [browser_notification_tab_switching.js]
deleted file mode 100644
--- a/browser/base/content/test/alerts/browser_notification_permission_migration.js
+++ /dev/null
@@ -1,45 +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* setup() {
-  currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
-  Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
-  pm.add(notificationURI, "desktop-notification", pm.ALLOW_ACTION);
-});
-
-add_task(function* test_permissionMigration() {
-  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("app.support.baseURL") +
-    "push#w_upgraded-notifications";
-  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");
-});
--- a/browser/base/content/test/alerts/head.js
+++ b/browser/base/content/test/alerts/head.js
@@ -1,27 +1,8 @@
-function promiseAlertWindow() {
-  return new Promise(function(resolve) {
-    let listener = {
-      onOpenWindow(window) {
-        let alertWindow = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
-        alertWindow.addEventListener("load", function() {
-          let windowType = alertWindow.document.documentElement.getAttribute("windowtype");
-          if (windowType != "alert:alert") {
-            return;
-          }
-          Services.wm.removeListener(listener);
-          resolve(alertWindow);
-        }, {once: true});
-      },
-    };
-    Services.wm.addListener(listener);
-  });
-}
-
 /**
  * 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) {
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1786,20 +1786,16 @@ BrowserGlue.prototype = {
       Services.prefs.clearUserPref("browser.devedition.showCustomizeButton");
     }
 
     if (currentUIVersion < 31) {
       xulStore.removeValue(BROWSER_DOCURL, "bookmarks-menu-button", "class");
       xulStore.removeValue(BROWSER_DOCURL, "home-button", "class");
     }
 
-    if (currentUIVersion < 32) {
-      this._notifyNotificationsUpgrade().catch(Cu.reportError);
-    }
-
     if (currentUIVersion < 36) {
       xulStore.removeValue("chrome://passwordmgr/content/passwordManager.xul",
                            "passwordCol",
                            "hidden");
     }
 
     if (currentUIVersion < 37) {
       Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
@@ -1851,59 +1847,16 @@ BrowserGlue.prototype = {
         Services.prefs.setCharPref("lightweightThemes.selectedThemeID", newTheme);
       }
     }
 
     // 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: Task.async(function* () {
-    if (!this._hasExistingNotificationPermission()) {
-      return;
-    }
-    yield this._firstWindowReady;
-    function clickCallback(subject, topic, data) {
-      if (topic != "alertclickcallback")
-        return;
-      let win = RecentWindow.getMostRecentBrowserWindow();
-      win.openUILinkIn(data, "tab");
-    }
-    // Show the application icon for XUL notifications. We assume system-level
-    // notifications will include their own icon.
-    let imageURL = this._hasSystemAlertsService() ? "" :
-                   "chrome://branding/content/about-logo.png";
-    let title = gBrowserBundle.GetStringFromName("webNotifications.upgradeTitle");
-    let text = gBrowserBundle.GetStringFromName("webNotifications.upgradeBody");
-    let url = Services.urlFormatter.formatURLPref("app.support.baseURL") +
-      "push#w_upgraded-notifications";
-
-    AlertsService.showAlertNotification(imageURL, title, text,
-                                        true, url, clickCallback);
-  }),
-
-  _hasSystemAlertsService() {
-    try {
-      return !!Cc["@mozilla.org/system-alerts-service;1"].getService(
-        Ci.nsIAlertsService);
-    } catch (e) {}
-    return false;
-  },
-
   // ------------------------------
   // public nsIBrowserGlue members
   // ------------------------------
 
   sanitize: function BG_sanitize(aParentWindow) {
     this._sanitizer.sanitize(aParentWindow);
   },
 
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -506,20 +506,16 @@ persistentStorage.remember=Remember this
 
 webNotifications.allow=Allow Notifications
 webNotifications.allow.accesskey=A
 webNotifications.notNow=Not Now
 webNotifications.notNow.accesskey=n
 webNotifications.never=Never Allow
 webNotifications.never.accesskey=v
 webNotifications.receiveFromSite2=Will you allow %S to send notifications?
-# LOCALIZATION NOTE (webNotifications.upgradeTitle): When using native notifications on OS X, the title may be truncated around 32 characters.
-webNotifications.upgradeTitle=Upgraded notifications
-# LOCALIZATION NOTE (webNotifications.upgradeBody): When using native notifications on OS X, the body may be truncated around 100 characters in some views.
-webNotifications.upgradeBody=You can now receive notifications from sites that are not currently loaded. Click to learn more.
 
 # Phishing/Malware Notification Bar.
 # LOCALIZATION NOTE (notADeceptiveSite, notAnAttack)
 # The two button strings will never be shown at the same time, so
 # it's okay for them to have the same access key
 safebrowsing.getMeOutOfHereButton.label=Get me out of here!
 safebrowsing.getMeOutOfHereButton.accessKey=G
 safebrowsing.deceptiveSite=Deceptive Site!