Backed out 3 changesets (bug 1307501) for xpcshell failures a=backout
authorWes Kocher <wkocher@mozilla.com>
Tue, 04 Oct 2016 14:55:29 -0700
changeset 316411 c8b204bac7ab87eea409e454d011554af415eb97
parent 316410 ede6abc13627a29a9e66952204f9bddb7a4cbc1a
child 316412 649af7cb0c87070b1f41cc407b6109f2f83a7889
push id82446
push userkwierso@gmail.com
push dateTue, 04 Oct 2016 21:55:32 +0000
treeherdermozilla-inbound@c8b204bac7ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1307501
milestone52.0a1
backs outb05f555321b78550fbca22685e5e89643af165d5
58e4d007f2a5eb24788debf16613d5d780df0ddb
113aa49cbb982144d17969f7161ef27153535a7c
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
Backed out 3 changesets (bug 1307501) for xpcshell failures a=backout Backed out changeset b05f555321b7 (bug 1307501) Backed out changeset 58e4d007f2a5 (bug 1307501) Backed out changeset 113aa49cbb98 (bug 1307501)
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginTags.cpp
dom/plugins/base/nsPluginTags.h
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -141,17 +141,38 @@ static const char *kPrefLoadInParentPref
 static const char *kPrefDisableFullPage = "plugin.disable_full_page_plugin_for_types";
 static const char *kPrefJavaMIME = "plugin.java.mime";
 
 // How long we wait before unloading an idle plugin process.
 // Defaults to 30 seconds.
 static const char *kPrefUnloadPluginTimeoutSecs = "dom.ipc.plugins.unloadTimeoutSecs";
 static const uint32_t kDefaultPluginUnloadingTimeout = 30;
 
-static const char *kPluginRegistryVersion = "0.18";
+// Version of cached plugin info
+// 0.01 first implementation
+// 0.02 added caching of CanUnload to fix bug 105935
+// 0.03 changed name, description and mime desc from string to bytes, bug 108246
+// 0.04 added new mime entry point on Mac, bug 113464
+// 0.05 added new entry point check for the default plugin, bug 132430
+// 0.06 strip off suffixes in mime description strings, bug 53895
+// 0.07 changed nsIRegistry to flat file support for caching plugins info
+// 0.08 mime entry point on MachO, bug 137535
+// 0.09 the file encoding is changed to UTF-8, bug 420285
+// 0.10 added plugin versions on appropriate platforms, bug 427743
+// 0.11 file name and full path fields now store expected values on all platforms, bug 488181
+// 0.12 force refresh due to quicktime pdf claim fix, bug 611197
+// 0.13 add architecture and list of invalid plugins, bug 616271
+// 0.14 force refresh due to locale comparison fix, bug 611296
+// 0.15 force refresh due to bug in reading Java plist MIME data, bug 638171
+// 0.16 version bump to avoid importing the plugin flags in newer versions
+// 0.17 added flag on whether plugin is loaded from an XPI
+// The current plugin registry version (and the maximum version we know how to read)
+static const char *kPluginRegistryVersion = "0.17";
+// The minimum registry version we know how to read
+static const char *kMinimumRegistryVersion = "0.9";
 
 static const char kDirectoryServiceContractID[] = "@mozilla.org/file/directory_service;1";
 
 #define kPluginRegistryFilename NS_LITERAL_CSTRING("pluginreg.dat")
 
 #ifdef PLUGIN_LOGGING
 LazyLogModule nsPluginLogging::gNPNLog(NPN_LOG_NAME);
 LazyLogModule nsPluginLogging::gNPPLog(NPP_LOG_NAME);
@@ -2070,17 +2091,17 @@ nsPluginHost::AddPluginTag(nsPluginTag* 
       }
     }
   }
 }
 
 static bool
 PluginInfoIsFlash(const nsPluginInfo& info)
 {
-  if (strcmp(info.fName, "Shockwave Flash") != 0) {
+  if (strcmp(info.fDescription, "Shockwave Flash") != 0) {
     return false;
   }
   for (uint32_t i = 0; i < info.fVariantCount; ++i) {
     if (info.fMimeTypeArray[i] &&
         (!strcmp(info.fMimeTypeArray[i], "application/x-shockwave-flash") ||
          !strcmp(info.fMimeTypeArray[i], "application/x-shockwave-flash-test"))) {
       return true;
     }
@@ -2964,16 +2985,20 @@ nsPluginHost::WritePluginInfo()
 nsresult
 nsPluginHost::ReadPluginInfo()
 {
   MOZ_ASSERT(XRE_IsParentProcess());
 
   const long PLUGIN_REG_MIMETYPES_ARRAY_SIZE = 12;
   const long PLUGIN_REG_MAX_MIMETYPES = 1000;
 
+  // we need to import the legacy flags from the plugin registry once
+  const bool pluginStateImported =
+    Preferences::GetDefaultBool("plugin.importedState", false);
+
   nsresult rv;
 
   nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,&rv));
   if (NS_FAILED(rv))
     return rv;
 
   directoryService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile),
                         getter_AddRefs(mPluginRegFile));
@@ -3055,77 +3080,138 @@ nsPluginHost::ReadPluginInfo()
   // VersionLiteral, kPluginRegistryVersion
   if (2 != reader.ParseLine(values, 2))
     return rv;
 
   // VersionLiteral
   if (PL_strcmp(values[0], "Version"))
     return rv;
 
-  // If we're reading an old registry, ignore it
-  if (!strcmp(values[1], kPluginRegistryVersion)) {
+  // kPluginRegistryVersion
+  int32_t vdiff = mozilla::CompareVersions(values[1], kPluginRegistryVersion);
+  mozilla::Version version(values[1]);
+  // If this is a registry from some future version then don't attempt to read it
+  if (vdiff > 0)
+    return rv;
+  // If this is a registry from before the minimum then don't attempt to read it
+  if (version < kMinimumRegistryVersion)
     return rv;
-  }
-
-  char* archValues[6];
-  if (!reader.NextLine()) {
-    return rv;
-  }
-
-  // ArchLiteral, Architecture
-  if (2 != reader.ParseLine(archValues, 2)) {
-    return rv;
+
+  // Registry v0.10 and upwards includes the plugin version field
+  bool regHasVersion = (version >= "0.10");
+
+  // Registry v0.13 and upwards includes the architecture
+  if (version >= "0.13") {
+    char* archValues[6];
+
+    if (!reader.NextLine()) {
+      return rv;
+    }
+
+    // ArchLiteral, Architecture
+    if (2 != reader.ParseLine(archValues, 2)) {
+      return rv;
+    }
+
+    // ArchLiteral
+    if (PL_strcmp(archValues[0], "Arch")) {
+      return rv;
+    }
+
+    nsCOMPtr<nsIXULRuntime> runtime = do_GetService("@mozilla.org/xre/runtime;1");
+    if (!runtime) {
+      return rv;
+    }
+
+    nsAutoCString arch;
+    if (NS_FAILED(runtime->GetXPCOMABI(arch))) {
+      return rv;
+    }
+
+    // If this is a registry from a different architecture then don't attempt to read it
+    if (PL_strcmp(archValues[1], arch.get())) {
+      return rv;
+    }
   }
 
-  // ArchLiteral
-  if (PL_strcmp(archValues[0], "Arch")) {
-    return rv;
-  }
-
-  nsCOMPtr<nsIXULRuntime> runtime = do_GetService("@mozilla.org/xre/runtime;1");
-  if (!runtime) {
-    return rv;
-  }
-
-  nsAutoCString arch;
-  if (NS_FAILED(runtime->GetXPCOMABI(arch))) {
-    return rv;
-  }
-
-  // If this is a registry from a different architecture then don't attempt to read it
-  if (PL_strcmp(archValues[1], arch.get())) {
-    return rv;
-  }
+  // Registry v0.13 and upwards includes the list of invalid plugins
+  const bool hasInvalidPlugins = (version >= "0.13");
+
+  // Registry v0.16 and upwards always have 0 for their plugin flags, prefs are used instead
+  const bool hasValidFlags = (version < "0.16");
+
+  // Registry v0.17 and upwards store whether the plugin comes from an XPI.
+  const bool hasFromExtension = (version >= "0.17");
+
+#if defined(XP_MACOSX)
+  const bool hasFullPathInFileNameField = false;
+#else
+  const bool hasFullPathInFileNameField = (version < "0.11");
+#endif
 
   if (!ReadSectionHeader(reader, "PLUGINS"))
     return rv;
 
   while (reader.NextLine()) {
-    if (*reader.LinePtr() == '[') {
+    const char *filename;
+    const char *fullpath;
+    nsAutoCString derivedFileName;
+
+    if (hasInvalidPlugins && *reader.LinePtr() == '[') {
       break;
     }
 
-    const char* filename = reader.LinePtr();
-    if (!reader.NextLine())
-      return rv;
-
-    const char* fullpath = reader.LinePtr();
-    if (!reader.NextLine())
-      return rv;
+    if (hasFullPathInFileNameField) {
+      fullpath = reader.LinePtr();
+      if (!reader.NextLine())
+        return rv;
+      // try to derive a file name from the full path
+      if (fullpath) {
+        nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1");
+        file->InitWithNativePath(nsDependentCString(fullpath));
+        file->GetNativeLeafName(derivedFileName);
+        filename = derivedFileName.get();
+      } else {
+        filename = nullptr;
+      }
+
+      // skip the next line, useless in this version
+      if (!reader.NextLine())
+        return rv;
+    } else {
+      filename = reader.LinePtr();
+      if (!reader.NextLine())
+        return rv;
+
+      fullpath = reader.LinePtr();
+      if (!reader.NextLine())
+        return rv;
+    }
 
     const char *version;
-    version = reader.LinePtr();
-    if (!reader.NextLine())
+    if (regHasVersion) {
+      version = reader.LinePtr();
+      if (!reader.NextLine())
+        return rv;
+    } else {
+      version = "0";
+    }
 
     // lastModifiedTimeStamp|canUnload|tag.mFlag|fromExtension
-    if (4 != reader.ParseLine(values, 4))
+    const int count = hasFromExtension ? 4 : 3;
+    if (reader.ParseLine(values, count) != count)
       return rv;
 
-    int64_t lastmod = nsCRT::atoll(values[0]);
-    bool fromExtension = atoi(values[3]);
+    // If this is an old plugin registry mark this plugin tag to be refreshed
+    int64_t lastmod = (vdiff == 0) ? nsCRT::atoll(values[0]) : -1;
+    uint32_t tagflag = atoi(values[2]);
+    bool fromExtension = false;
+    if (hasFromExtension) {
+      fromExtension = atoi(values[3]);
+    }
     if (!reader.NextLine())
       return rv;
 
     char *description = reader.LinePtr();
     if (!reader.NextLine())
       return rv;
 
 #if MOZ_WIDGET_ANDROID
@@ -3191,52 +3277,61 @@ nsPluginHost::ReadPluginInfo()
       (const char* const*)mimetypes,
       (const char* const*)mimedescriptions,
       (const char* const*)extensions,
       mimetypecount, lastmod, fromExtension, true);
     if (heapalloced)
       delete [] heapalloced;
 
     // Import flags from registry into prefs for old registry versions
+    if (hasValidFlags && !pluginStateImported) {
+      tag->ImportFlagsToPrefs(tagflag);
+    }
+
     MOZ_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_BASIC,
       ("LoadCachedPluginsInfo : Loading Cached plugininfo for %s\n", tag->FileName().get()));
 
     if (!ShouldAddPlugin(tag)) {
       continue;
     }
 
     tag->mNext = mCachedPlugins;
     mCachedPlugins = tag;
   }
 
 // On Android we always want to try to load a plugin again (Flash). Bug 935676.
 #ifndef MOZ_WIDGET_ANDROID
-  if (!ReadSectionHeader(reader, "INVALID")) {
-    return rv;
-  }
-
-  while (reader.NextLine()) {
-    const char *fullpath = reader.LinePtr();
-    if (!reader.NextLine()) {
+  if (hasInvalidPlugins) {
+    if (!ReadSectionHeader(reader, "INVALID")) {
       return rv;
     }
 
-    const char *lastModifiedTimeStamp = reader.LinePtr();
-    int64_t lastmod = nsCRT::atoll(lastModifiedTimeStamp);
-
-    RefPtr<nsInvalidPluginTag> invalidTag = new nsInvalidPluginTag(fullpath, lastmod);
-
-    invalidTag->mNext = mInvalidPlugins;
-    if (mInvalidPlugins) {
-      mInvalidPlugins->mPrev = invalidTag;
+    while (reader.NextLine()) {
+      const char *fullpath = reader.LinePtr();
+      if (!reader.NextLine()) {
+        return rv;
+      }
+
+      const char *lastModifiedTimeStamp = reader.LinePtr();
+      int64_t lastmod = (vdiff == 0) ? nsCRT::atoll(lastModifiedTimeStamp) : -1;
+
+      RefPtr<nsInvalidPluginTag> invalidTag = new nsInvalidPluginTag(fullpath, lastmod);
+
+      invalidTag->mNext = mInvalidPlugins;
+      if (mInvalidPlugins) {
+        mInvalidPlugins->mPrev = invalidTag;
+      }
+      mInvalidPlugins = invalidTag;
     }
-    mInvalidPlugins = invalidTag;
   }
 #endif
 
+  // flip the pref so we don't import the legacy flags again
+  Preferences::SetBool("plugin.importedState", true);
+
   return NS_OK;
 }
 
 void
 nsPluginHost::RemoveCachedPluginsInfo(const char *filePath, nsPluginTag **result)
 {
   RefPtr<nsPluginTag> prev;
   RefPtr<nsPluginTag> tag = mCachedPlugins;
--- a/dom/plugins/base/nsPluginTags.cpp
+++ b/dom/plugins/base/nsPluginTags.cpp
@@ -752,16 +752,23 @@ nsPluginTag::GetNiceFileName()
 
 NS_IMETHODIMP
 nsPluginTag::GetNiceName(nsACString & aResult)
 {
   aResult = GetNiceFileName();
   return NS_OK;
 }
 
+void nsPluginTag::ImportFlagsToPrefs(uint32_t flags)
+{
+  if (!(flags & NS_PLUGIN_FLAG_ENABLED)) {
+    SetPluginState(ePluginState_Disabled);
+  }
+}
+
 NS_IMETHODIMP
 nsPluginTag::GetBlocklistState(uint32_t *aResult)
 {
 #if defined(MOZ_WIDGET_ANDROID)
   *aResult = nsIBlocklistService::STATE_NOT_BLOCKED;
   return NS_OK;
 #else
   if (mCachedBlocklistStateValid) {
--- a/dom/plugins/base/nsPluginTags.h
+++ b/dom/plugins/base/nsPluginTags.h
@@ -146,16 +146,19 @@ public:
   bool IsEnabled() override;
   void SetEnabled(bool enabled);
   bool IsClicktoplay();
   bool IsBlocklisted();
 
   PluginState GetPluginState();
   void SetPluginState(PluginState state);
 
+  // import legacy flags from plugin registry into the preferences
+  void ImportFlagsToPrefs(uint32_t flag);
+
   bool HasSameNameAndMimes(const nsPluginTag *aPluginTag) const;
   const nsCString& GetNiceFileName() override;
 
   bool IsFromExtension() const;
 
   RefPtr<nsPluginTag> mNext;
   uint32_t      mId;