Back out revision d3da96f774b3 on a CLOSED TREE - Bug 882339 because of mochitest-browser failures in browser_CTP_drag_drop.js and browser-pluginnotification.js
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 18 Jun 2013 16:44:07 -0400
changeset 147018 610382f55f339a32007b7c67ad0fd35f88fd7d91
parent 147017 089b861c6688313d079d106a97cdeff53c5700ad
child 147019 398e348e3ed885a0ee2d6a42d33d46d81d86fd6d
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs882339
milestone24.0a1
backs outd3da96f774b36e34d900f584b5b82936fe5a72d5
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Back out revision d3da96f774b3 on a CLOSED TREE - Bug 882339 because of mochitest-browser failures in browser_CTP_drag_drop.js and browser-pluginnotification.js
browser/base/content/test/head.js
content/base/test/chrome/test_bug391728.html
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginTags.cpp
dom/plugins/base/nsPluginTags.h
toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js
--- a/browser/base/content/test/head.js
+++ b/browser/base/content/test/head.js
@@ -110,18 +110,18 @@ function getTestPlugin(aName) {
   ok(false, "Unable to find plugin");
   return null;
 }
 
 function updateBlocklist(aCallback) {
   var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
                           .getService(Ci.nsITimerCallback);
   var observer = function() {
+    aCallback();
     Services.obs.removeObserver(observer, "blocklist-updated");
-    SimpleTest.executeSoon(aCallback);
   };
   Services.obs.addObserver(observer, "blocklist-updated", false);
   blocklistNotifier.notify(null);
 }
 
 var _originalTestBlocklistURL = null;
 function setAndUpdateBlocklist(aURL, aCallback) {
   if (!_originalTestBlocklistURL)
--- a/content/base/test/chrome/test_bug391728.html
+++ b/content/base/test/chrome/test_bug391728.html
@@ -53,18 +53,18 @@ function init_test() {
   if (!PluginUtils.withTestPlugin(start_test))
     SimpleTest.finish();
 }
 
 function updateBlocklist(aCallback) {
   var blocklistNotifier = Components.classes["@mozilla.org/extensions/blocklist;1"]
                           .getService(Components.interfaces.nsITimerCallback);
   var observer = function() {
+    aCallback();
     Services.obs.removeObserver(observer, "blocklist-updated");
-    SimpleTest.executeSoon(aCallback);
   };
   Services.obs.addObserver(observer, "blocklist-updated", false);
   blocklistNotifier.notify(null);
 }
 
 var _originalBlocklistURL = null;
 function setAndUpdateBlocklist(aURL, aCallback) {
   info("Setting blocklist to " + aURL);
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -287,17 +287,16 @@ nsPluginHost::nsPluginHost()
 
   Preferences::AddStrongObserver(this, "plugin.disable");
   Preferences::AddStrongObserver(this, "plugins.click_to_play");
 
   nsCOMPtr<nsIObserverService> obsService =
     mozilla::services::GetObserverService();
   if (obsService) {
     obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
-    obsService->AddObserver(this, "blocklist-updated", false);
 #ifdef MOZ_WIDGET_ANDROID
     obsService->AddObserver(this, "application-foreground", false);
     obsService->AddObserver(this, "application-background", false);
 #endif
   }
 
 #ifdef PLUGIN_LOGGING
   nsPluginLogging::gNPNLog = PR_NewLogModule(NPN_LOG_NAME);
@@ -1064,22 +1063,27 @@ nsPluginHost::GetStateForType(const nsAC
 
 nsresult
 nsPluginHost::GetBlocklistStateForType(const char *aMimeType, uint32_t *aState)
 {
   nsPluginTag *plugin = FindPluginForType(aMimeType, true);
   if (!plugin) {
     plugin = FindPluginForType(aMimeType, false);
   }
-  if (!plugin) {
-    return NS_ERROR_FAILURE;
+  if (plugin) {
+    nsCOMPtr<nsIBlocklistService> blocklist = do_GetService("@mozilla.org/extensions/blocklist;1");
+    if (blocklist) {
+      // The EmptyString()s are so we use the currently running application
+      // and toolkit versions
+      return blocklist->GetPluginBlocklistState(plugin, EmptyString(),
+                                                EmptyString(), aState);
+    }
   }
 
-  *aState = plugin->GetBlocklistState();
-  return NS_OK;
+  return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsPluginHost::GetPermissionStringForType(const nsACString &aMimeType, nsACString &aPermissionString)
 {
   aPermissionString.Truncate();
   uint32_t blocklistState;
   nsresult rv = GetBlocklistStateForType(aMimeType.Data(), &blocklistState);
@@ -1922,27 +1926,35 @@ nsresult nsPluginHost::ScanPluginsDirect
 
       pluginTag = new nsPluginTag(&info);
       pluginFile.FreePluginInfo(info);
       if (!pluginTag)
         return NS_ERROR_OUT_OF_MEMORY;
 
       pluginTag->mLibrary = library;
       pluginTag->mLastModifiedTime = fileModTime;
-      uint32_t state = pluginTag->GetBlocklistState();
-
-      // If the blocklist says it is risky and we have never seen this
-      // plugin before, then disable it.
-      // If the blocklist says this is an outdated plugin, warn about
-      // outdated plugins.
-      if (state == nsIBlocklistService::STATE_SOFTBLOCKED && !seenBefore) {
-        pluginTag->SetEnabledState(nsIPluginTag::STATE_DISABLED);
-      }
-      if (state == nsIBlocklistService::STATE_OUTDATED && !seenBefore) {
-        warnOutdated = true;
+
+      nsCOMPtr<nsIBlocklistService> blocklist = do_GetService("@mozilla.org/extensions/blocklist;1");
+      if (blocklist) {
+        uint32_t state;
+        rv = blocklist->GetPluginBlocklistState(pluginTag, EmptyString(),
+                                                EmptyString(), &state);
+
+        if (NS_SUCCEEDED(rv)) {
+          // If the blocklist says it is risky and we have never seen this
+          // plugin before, then disable it.
+          // If the blocklist says this is an outdated plugin, warn about
+          // outdated plugins.
+          if (state == nsIBlocklistService::STATE_SOFTBLOCKED && !seenBefore) {
+             pluginTag->SetEnabledState(nsIPluginTag::STATE_DISABLED);
+          }
+          if (state == nsIBlocklistService::STATE_OUTDATED && !seenBefore) {
+             warnOutdated = true;
+          }
+        }
       }
 
       // Plugin unloading is tag-based. If we created a new tag and loaded
       // the library in the process then we want to attempt to unload it here.
       // Only do this if the pref is set for aggressive unloading.
       if (UnloadPluginsASAP()) {
         pluginTag->TryUnloadPlugin(false);
       }
@@ -3129,51 +3141,44 @@ nsresult nsPluginHost::NewPluginStreamLi
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsPluginHost::Observe(nsISupports *aSubject,
                                     const char *aTopic,
                                     const PRUnichar *someData)
 {
-  if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) {
+  if (!nsCRT::strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) {
     OnShutdown();
     UnloadPlugins();
     sInst->Release();
   }
-  if (!strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) {
+  if (!nsCRT::strcmp(NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, aTopic)) {
     mPluginsDisabled = Preferences::GetBool("plugin.disable", false);
     mPluginsClickToPlay = Preferences::GetBool("plugins.click_to_play", false);
     // Unload or load plugins as needed
     if (mPluginsDisabled) {
       UnloadPlugins();
     } else {
       LoadPlugins();
     }
   }
-  if (!strcmp("blocklist-updated", aTopic)) {
-    nsPluginTag* plugin = mPlugins;
-    while (plugin) {
-      plugin->InvalidateBlocklistState();
-      plugin = plugin->mNext;
-    }
-  }
 #ifdef MOZ_WIDGET_ANDROID
-  if (!strcmp("application-background", aTopic)) {
+  if (!nsCRT::strcmp("application-background", aTopic)) {
     for(uint32_t i = 0; i < mInstances.Length(); i++) {
       mInstances[i]->NotifyForeground(false);
     }
   }
-  if (!strcmp("application-foreground", aTopic)) {
+  if (!nsCRT::strcmp("application-foreground", aTopic)) {
     for(uint32_t i = 0; i < mInstances.Length(); i++) {
       if (mInstances[i]->IsOnScreen())
         mInstances[i]->NotifyForeground(true);
     }
   }
-  if (!strcmp("memory-pressure", aTopic)) {
+  if (!nsCRT::strcmp("memory-pressure", aTopic)) {
     for(uint32_t i = 0; i < mInstances.Length(); i++) {
       mInstances[i]->MemoryPressure();
     }
   }
 #endif
   return NS_OK;
 }
 
--- a/dom/plugins/base/nsPluginTags.cpp
+++ b/dom/plugins/base/nsPluginTags.cpp
@@ -75,35 +75,31 @@ nsPluginTag::nsPluginTag(nsPluginTag* aP
     mExtensions(aPluginTag->mExtensions),
     mLibrary(nullptr),
     mIsJavaPlugin(aPluginTag->mIsJavaPlugin),
     mIsFlashPlugin(aPluginTag->mIsFlashPlugin),
     mFileName(aPluginTag->mFileName),
     mFullPath(aPluginTag->mFullPath),
     mVersion(aPluginTag->mVersion),
     mLastModifiedTime(0),
-    mNiceFileName(),
-    mCachedBlocklistState(nsIBlocklistService::STATE_NOT_BLOCKED),
-    mCachedBlocklistStateValid(false)
+    mNiceFileName()
 {
 }
 
 nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo)
   : mName(aPluginInfo->fName),
     mDescription(aPluginInfo->fDescription),
     mLibrary(nullptr),
     mIsJavaPlugin(false),
     mIsFlashPlugin(false),
     mFileName(aPluginInfo->fFileName),
     mFullPath(aPluginInfo->fFullPath),
     mVersion(aPluginInfo->fVersion),
     mLastModifiedTime(0),
-    mNiceFileName(),
-    mCachedBlocklistState(nsIBlocklistService::STATE_NOT_BLOCKED),
-    mCachedBlocklistStateValid(false)
+    mNiceFileName()
 {
   InitMime(aPluginInfo->fMimeTypeArray,
            aPluginInfo->fMimeDescriptionArray,
            aPluginInfo->fExtensionArray,
            aPluginInfo->fVariantCount);
   EnsureMembersAreUTF8();
 }
 
@@ -122,19 +118,17 @@ nsPluginTag::nsPluginTag(const char* aNa
     mDescription(aDescription),
     mLibrary(nullptr),
     mIsJavaPlugin(false),
     mIsFlashPlugin(false),
     mFileName(aFileName),
     mFullPath(aFullPath),
     mVersion(aVersion),
     mLastModifiedTime(aLastModifiedTime),
-    mNiceFileName(),
-    mCachedBlocklistState(nsIBlocklistService::STATE_NOT_BLOCKED),
-    mCachedBlocklistStateValid(false)
+    mNiceFileName()
 {
   InitMime(aMimeTypes, aMimeDescriptions, aExtensions,
            static_cast<uint32_t>(aVariants));
   if (!aArgsAreUTF8)
     EnsureMembersAreUTF8();
 }
 
 nsPluginTag::~nsPluginTag()
@@ -539,40 +533,8 @@ nsCString nsPluginTag::GetNiceFileName()
 }
 
 void nsPluginTag::ImportFlagsToPrefs(uint32_t flags)
 {
   if (!(flags & NS_PLUGIN_FLAG_ENABLED)) {
     SetPluginState(ePluginState_Disabled);
   }
 }
-
-uint32_t
-nsPluginTag::GetBlocklistState()
-{
-  if (mCachedBlocklistStateValid) {
-    return mCachedBlocklistState;
-  }
-
-  nsCOMPtr<nsIBlocklistService> blocklist = do_GetService("@mozilla.org/extensions/blocklist;1");
-  if (!blocklist) {
-    return nsIBlocklistService::STATE_NOT_BLOCKED;
-  }
-
-  // The EmptyString()s are so we use the currently running application
-  // and toolkit versions
-  uint32_t state;
-  if (NS_FAILED(blocklist->GetPluginBlocklistState(this, EmptyString(),
-                                                   EmptyString(), &state))) {
-    return nsIBlocklistService::STATE_NOT_BLOCKED;
-  }
-
-  MOZ_ASSERT(state <= UINT16_MAX);
-  mCachedBlocklistState = (uint16_t) state;
-  mCachedBlocklistStateValid = true;
-  return state;
-}
-
-void
-nsPluginTag::InvalidateBlocklistState()
-{
-  mCachedBlocklistStateValid = false;
-}
--- a/dom/plugins/base/nsPluginTags.h
+++ b/dom/plugins/base/nsPluginTags.h
@@ -80,24 +80,18 @@ public:
   nsRefPtr<nsNPAPIPlugin> mPlugin;
   bool          mIsJavaPlugin;
   bool          mIsFlashPlugin;
   nsCString     mFileName; // UTF-8
   nsCString     mFullPath; // UTF-8
   nsCString     mVersion;  // UTF-8
   int64_t       mLastModifiedTime;
   nsCOMPtr<nsITimer> mUnloadTimer;
-
-  uint32_t      GetBlocklistState();
-  void          InvalidateBlocklistState();
-
 private:
   nsCString     mNiceFileName; // UTF-8
-  uint16_t      mCachedBlocklistState;
-  bool          mCachedBlocklistStateValid;
 
   void InitMime(const char* const* aMimeTypes,
                 const char* const* aMimeDescriptions,
                 const char* const* aExtensions,
                 uint32_t aVariantCount);
   nsresult EnsureMembersAreUTF8();
 };
 
--- a/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js
@@ -6,18 +6,18 @@ const gHttpTestRoot = "http://127.0.0.1:
 let gManagerWindow;
 let gTestPluginId;
 let gPluginBrowser;
 
 function updateBlocklist(aCallback) {
   var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"]
                           .getService(Ci.nsITimerCallback);
   var observer = function() {
+    aCallback();
     Services.obs.removeObserver(observer, "blocklist-updated");
-    SimpleTest.executeSoon(aCallback);
   };
   Services.obs.addObserver(observer, "blocklist-updated", false);
   blocklistNotifier.notify(null);
 }
 
 var _originalBlocklistURL = null;
 function setAndUpdateBlocklist(aURL, aCallback) {
   if (!_originalBlocklistURL) {