From 159ecf12ef64bd021697bce2724ede7d92a123a3 Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Mon, 3 Jan 2011 16:37:01 -0800 Subject: [PATCH] Bug 607860 - remove navigator.mozNotification from Firefox desktop. r=jst/jonas a=betaN+ --- dom/base/nsDOMClassInfo.cpp | 20 ++++--- dom/base/nsGlobalWindow.cpp | 6 +++ dom/base/nsGlobalWindow.h | 2 + .../notification/notification_common.js | 4 ++ .../notification/test_basic_notification.html | 42 ++++++++------- .../test_basic_notification_click.html | 52 +++++++++++-------- .../notification/test_leak_windowClose.html | 20 ++++--- modules/libpref/src/init/all.js | 3 ++ 8 files changed, 95 insertions(+), 54 deletions(-) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index cee18010110..2139e7eca68 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -2276,12 +2276,20 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMLocation) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorDesktopNotification) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation) - DOM_CLASSINFO_MAP_END + if (nsNavigator::HasDesktopNotificationSupport()) { + DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorDesktopNotification) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation) + DOM_CLASSINFO_MAP_END + } else { + DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation) + DOM_CLASSINFO_MAP_END + } DOM_CLASSINFO_MAP_BEGIN(Plugin, nsIDOMPlugin) DOM_CLASSINFO_MAP_ENTRY(nsIDOMPlugin) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 43bb541ce18..6264c35f078 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -10722,6 +10722,12 @@ nsNavigator::RefreshMIMEArray() return rv; } +bool +nsNavigator::HasDesktopNotificationSupport() +{ + return nsContentUtils::GetBoolPref("notification.feature.enabled", PR_FALSE); +} + //***************************************************************************** // nsNavigator::nsIDOMClientInformation //***************************************************************************** diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 54b2355f848..194fcbedcf5 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -1056,6 +1056,8 @@ public: void LoadingNewDocument(); nsresult RefreshMIMEArray(); + static bool HasDesktopNotificationSupport(); + protected: nsRefPtr mMimeTypes; nsRefPtr mPlugins; diff --git a/dom/tests/mochitest/notification/notification_common.js b/dom/tests/mochitest/notification/notification_common.js index b582c01d5b5..a95ca158561 100644 --- a/dom/tests/mochitest/notification/notification_common.js +++ b/dom/tests/mochitest/notification/notification_common.js @@ -72,3 +72,7 @@ function force_click_on_notification(val) { prefs.setBoolPref("notification.prompt.testing.click_on_notification", val); } +function is_feature_enabled() { + var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); + return prefs.getBoolPref("notification.feature.enabled"); +} diff --git a/dom/tests/mochitest/notification/test_basic_notification.html b/dom/tests/mochitest/notification/test_basic_notification.html index ec8404e2f61..3765fa69dbc 100644 --- a/dom/tests/mochitest/notification/test_basic_notification.html +++ b/dom/tests/mochitest/notification/test_basic_notification.html @@ -21,27 +21,33 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=573588
 
 
diff --git a/dom/tests/mochitest/notification/test_basic_notification_click.html b/dom/tests/mochitest/notification/test_basic_notification_click.html index 333a12aab51..50b5a3adb03 100644 --- a/dom/tests/mochitest/notification/test_basic_notification_click.html +++ b/dom/tests/mochitest/notification/test_basic_notification_click.html @@ -21,32 +21,38 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=573588
 
 
diff --git a/dom/tests/mochitest/notification/test_leak_windowClose.html b/dom/tests/mochitest/notification/test_leak_windowClose.html index 81eda4ad1f4..1944aff1588 100644 --- a/dom/tests/mochitest/notification/test_leak_windowClose.html +++ b/dom/tests/mochitest/notification/test_leak_windowClose.html @@ -10,16 +10,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605309 diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 04ccb6f2088..30286153a0f 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -3278,3 +3278,6 @@ pref("extensions.alwaysUnpack", false); pref("network.buffer.cache.count", 24); pref("network.buffer.cache.size", 32768); + +// Desktop Notification +pref("notification.feature.enabled", false);