Merge mozilla-inbound with mozilla-central
authorPhil Ringnalda <philringnalda@gmail.com>
Sun, 01 Jan 2012 20:53:49 -0800
changeset 84865 31b7a15bc54de48552146a1718f3e4eca4c5117f
parent 84864 edffd43801d923c6d0540438fe3982db0f5960cd (current diff)
parent 84854 d98fbf3cbd713b9108a09fc3c0ec68f6b38c4736 (diff)
child 84866 ac280e7eb3e665f21315a0510e25cf43ca6b277e
child 84881 2f3dbb399dbfb981b293c70f8171b7924d6e8236
child 84892 8be4e3d2105e8155d7a29b5f87ff072027c6d414
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone12.0a1
Merge mozilla-inbound with mozilla-central
xpcom/base/nsCycleCollector.cpp
--- a/browser/components/sessionstore/content/aboutSessionRestore.js
+++ b/browser/components/sessionstore/content/aboutSessionRestore.js
@@ -135,17 +135,17 @@ function restoreSession() {
   var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   var top = getBrowserWindow();
   
   // if there's only this page open, reuse the window for restoring the session
   if (top.gBrowser.tabs.length == 1) {
     ss.setWindowState(top, stateString, true);
     return;
   }
-  
+
   // restore the session into a new window and close the current tab
   var newWindow = top.openDialog(top.location, "_blank", "chrome,dialog=no,all");
   newWindow.addEventListener("load", function() {
     newWindow.removeEventListener("load", arguments.callee, true);
     ss.setWindowState(newWindow, stateString, true);
     
     var tabbrowser = top.gBrowser;
     var tabIndex = tabbrowser.getBrowserIndexForDocument(document);
--- a/content/media/webm/nsWebMReader.cpp
+++ b/content/media/webm/nsWebMReader.cpp
@@ -132,19 +132,22 @@ nsWebMReader::nsWebMReader(nsBuiltinDeco
   mContext(nsnull),
   mPacketCount(0),
   mChannels(0),
   mVideoTrack(0),
   mAudioTrack(0),
   mAudioStartUsec(-1),
   mAudioFrames(0),
   mHasVideo(false),
-  mHasAudio(false)
+  mHasAudio(false),
+  mForceStereoMode(0)
 {
   MOZ_COUNT_CTOR(nsWebMReader);
+
+  Preferences::GetInt("media.webm.force_stereo_mode", &mForceStereoMode);
 }
 
 nsWebMReader::~nsWebMReader()
 {
   Cleanup();
 
   mVideoPackets.Reset();
   mAudioPackets.Reset();
@@ -301,35 +304,31 @@ nsresult nsWebMReader::ReadMetadata(nsVi
       case NESTEGG_VIDEO_STEREO_TOP_BOTTOM:
         mInfo.mStereoMode = STEREO_MODE_TOP_BOTTOM;
         break;
       case NESTEGG_VIDEO_STEREO_RIGHT_LEFT:
         mInfo.mStereoMode = STEREO_MODE_RIGHT_LEFT;
         break;
       }
 
-      PRInt32 forceStereoMode;
-      if (NS_SUCCEEDED(Preferences::GetInt("media.webm.force_stereo_mode",
-                                           &forceStereoMode))) {
-        switch (forceStereoMode) {
-        case 1:
-          mInfo.mStereoMode = STEREO_MODE_LEFT_RIGHT;
-          break;
-        case 2:
-          mInfo.mStereoMode = STEREO_MODE_RIGHT_LEFT;
-          break;
-        case 3:
-          mInfo.mStereoMode = STEREO_MODE_TOP_BOTTOM;
-          break;
-        case 4:
-          mInfo.mStereoMode = STEREO_MODE_BOTTOM_TOP;
-          break;
-        default:
-          mInfo.mStereoMode = STEREO_MODE_MONO;
-        }
+      switch (mForceStereoMode) {
+      case 1:
+        mInfo.mStereoMode = STEREO_MODE_LEFT_RIGHT;
+        break;
+      case 2:
+        mInfo.mStereoMode = STEREO_MODE_RIGHT_LEFT;
+        break;
+      case 3:
+        mInfo.mStereoMode = STEREO_MODE_TOP_BOTTOM;
+        break;
+      case 4:
+        mInfo.mStereoMode = STEREO_MODE_BOTTOM_TOP;
+        break;
+      default:
+        mInfo.mStereoMode = STEREO_MODE_MONO;
       }
     }
     else if (!mHasAudio && type == NESTEGG_TRACK_AUDIO) {
       nestegg_audio_params params;
       r = nestegg_track_audio_params(mContext, track, &params);
       if (r == -1) {
         Cleanup();
         return NS_ERROR_FAILURE;
--- a/content/media/webm/nsWebMReader.h
+++ b/content/media/webm/nsWebMReader.h
@@ -235,11 +235,15 @@ private:
   nsIntSize mInitialFrame;
 
   // Picture region, as relative to the initial frame size.
   nsIntRect mPicture;
 
   // Booleans to indicate if we have audio and/or video data
   bool mHasVideo;
   bool mHasAudio;
+
+  // Value of the "media.webm.force_stereo_mode" pref, which we need off the
+  // main thread.
+  PRInt32 mForceStereoMode;
 };
 
 #endif
--- a/toolkit/content/widgets/videocontrols.css
+++ b/toolkit/content/widgets/videocontrols.css
@@ -15,16 +15,17 @@
 .scrubber .scale-slider,
 .volumeControl .scale-slider {
   -moz-user-focus: none;
 }
 
 .mediaControlsFrame {
   direction: ltr;
   /* Prevent unwanted style inheritance. See bug 554717. */
+  text-align: left;
   list-style-image: none !important;
   font: normal normal normal 100%/normal sans-serif !important;
   text-decoration: none !important;
 }
 
 /* CSS Transitions
  *
  * These are overriden by the default theme; the rules here just 
--- a/toolkit/mozapps/extensions/AddonRepository.jsm
+++ b/toolkit/mozapps/extensions/AddonRepository.jsm
@@ -1252,18 +1252,20 @@ var AddonRepository = {
         callback(null);
       }
     });
   },
 
   // Parses addon_compatibility nodes, that describe compatibility overrides.
   _parseAddonCompatElement: function(aResultObj, aElement) {
     let guid = this._getDescendantTextContent(aElement, "guid");
-    if (!guid)
+    if (!guid) {
+        LOG("Compatibility override is missing guid.");
       return;
+    }
 
     let compat = {id: guid};
     compat.hosted = aElement.getAttribute("hosted") != "false";
 
     function findMatchingAppRange(aNodes) {
       let toolkitAppRange = null;
       for (let i = 0; i < aNodes.length; i++) {
         let node = aNodes[i];
@@ -1287,31 +1289,41 @@ var AddonRepository = {
           return appRange;
       }
       return toolkitAppRange;
     }
 
     function parseRangeNode(aNode) {
       let type = aNode.getAttribute("type");
       // Only "incompatible" (blacklisting) is supported for now.
-      if (type != "incompatible")
+      if (type != "incompatible") {
+        LOG("Compatibility override of unsupported type found.");
         return null;
+      }
 
       let override = new AddonManagerPrivate.AddonCompatibilityOverride(type);
 
       override.minVersion = this._getDirectDescendantTextContent(aNode, "min_version");
       override.maxVersion = this._getDirectDescendantTextContent(aNode, "max_version");
 
-      if (!override.minVersion || !override.maxVersion)
+      if (!override.minVersion) {
+        LOG("Compatibility override is missing min_version.");
         return null;
+      }
+      if (!override.maxVersion) {
+        LOG("Compatibility override is missing max_version.");
+        return null;
+      }
 
       let appRanges = aNode.querySelectorAll("compatible_applications > application");
       let appRange = findMatchingAppRange.bind(this)(appRanges);
-      if (!appRange)
+      if (!appRange) {
+        LOG("Compatibility override is missing a valid application range.");
         return null;
+      }
 
       override.appID = appRange.appID;
       override.appMinVersion = appRange.appMinVersion;
       override.appMaxVersion = appRange.appMaxVersion;
 
       return override;
     }
 
--- a/toolkit/mozapps/extensions/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/XPIProvider.jsm
@@ -6143,27 +6143,29 @@ AddonInstall.prototype = {
    */
   loadManifest: function AI_loadManifest(aCallback) {
     function addRepositoryData(aAddon) {
       // Try to load from the existing cache first
       AddonRepository.getCachedAddonByID(aAddon.id, function(aRepoAddon) {
         if (aRepoAddon) {
           aAddon._repositoryAddon = aRepoAddon;
           aAddon.compatibilityOverrides = aRepoAddon.compatibilityOverrides;
+          aAddon.appDisabled = !isUsableAddon(aAddon);
           aCallback();
           return;
         }
 
         // It wasn't there so try to re-download it
         AddonRepository.cacheAddons([aAddon.id], function() {
           AddonRepository.getCachedAddonByID(aAddon.id, function(aRepoAddon) {
             aAddon._repositoryAddon = aRepoAddon;
             aAddon.compatibilityOverrides = aRepoAddon ?
                                               aRepoAddon.compatibilityOverrides :
                                               null;
+            aAddon.appDisabled = !isUsableAddon(aAddon);
             aCallback();
           });
         });
       });
     }
 
     let zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].
                     createInstance(Ci.nsIZipReader);
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_install6/install.rdf
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+
+<!-- An extension that has a compatibility override making it incompatible. -->
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+    <em:id>addon6@tests.mozilla.org</em:id>
+    <em:version>1.0</em:version>
+
+    <!-- Front End MetaData -->
+    <em:name>Addon Test 6</em:name>
+    <em:description>Test Description</em:description>
+
+    <em:targetApplication>
+      <Description>
+        <em:id>xpcshell@tests.mozilla.org</em:id>
+        <em:minVersion>1</em:minVersion>
+        <em:maxVersion>1</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+
+  </Description>
+</RDF>
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml
@@ -26,9 +26,28 @@
         <appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
         <min_version>0</min_version>
         <max_version>*</max_version>
       </application>
     </compatible_applications>
     <compatible_os>ALL</compatible_os>
     <install size="2">http://example.com/browser/toolkit/mozapps/extensions/test/browser/addons/browser_install1_2.xpi</install>
   </addon>
+
+  <addon_compatibility hosted="false">
+    <guid>addon6@tests.mozilla.org</guid>
+    <name>Addon Test 6</name>
+    <version_ranges>
+      <version_range type="incompatible">
+        <min_version>1.0</min_version>
+        <max_version>1.0</max_version>
+        <compatible_applications>
+          <application>
+            <name>XPCShell</name>
+            <min_version>1.0</min_version>
+            <max_version>1.0</max_version>
+            <appID>xpcshell@tests.mozilla.org</appID>
+          </application>
+        </compatible_applications>
+      </version_range>
+    </version_ranges>
+  </addon_compatibility>
 </searchresults>
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js
@@ -1673,12 +1673,57 @@ function check_test_28(install) {
     "onInstallCancelled"
   ], finish_test_28);
   return false;
 }
 
 function finish_test_28(install) {
   prepare_test({}, [
     "onDownloadCancelled"
-  ], do_test_finished);
+  ], run_test_29);
 
   install.cancel();
 }
+
+// Tests that an install with a matching compatibility override has appDisabled
+// set correctly.
+function run_test_29() {
+  Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", true);
+
+  prepare_test({ }, [
+    "onNewInstall"
+  ]);
+
+  let url = "http://localhost:4444/addons/test_install6.xpi";
+  AddonManager.getInstallForURL(url, function(install) {
+    ensure_test_completed();
+
+    do_check_neq(install, null);
+    do_check_eq(install.version, "1.0");
+    do_check_eq(install.name, "Addon Test 6");
+    do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
+
+    AddonManager.getInstallsByTypes(null, function(activeInstalls) {
+      do_check_eq(activeInstalls.length, 1);
+      do_check_eq(activeInstalls[0], install);
+
+      prepare_test({}, [
+        "onDownloadStarted",
+        "onDownloadEnded"
+      ], check_test_29);
+      install.install();
+    });
+  }, "application/x-xpinstall", null, "Addon Test 6", null, "1.0");
+}
+
+function check_test_29(install) {
+  //ensure_test_completed();
+  do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
+  do_check_neq(install.addon, null);
+  do_check_false(install.addon.isCompatible);
+  do_check_true(install.addon.appDisabled);
+
+  prepare_test({}, [
+    "onDownloadCancelled"
+  ], do_test_finished);
+  install.cancel();
+  return false;
+}
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1369,27 +1369,40 @@ GraphWalker<Visitor>::DoWalk(nsDeque &aQ
     sCollector->mStats.mWalkedGraph++;
 #endif
 }
 
 
 class nsCycleCollectorLogger : public nsICycleCollectorListener
 {
 public:
-    nsCycleCollectorLogger() : mStream(nsnull)
+    nsCycleCollectorLogger() : mStream(nsnull), mWantAllTraces(false)
     {
     }
     ~nsCycleCollectorLogger()
     {
         if (mStream) {
             fclose(mStream);
         }
     }
     NS_DECL_ISUPPORTS
 
+    NS_IMETHOD AllTraces(nsICycleCollectorListener** aListener)
+    {
+      mWantAllTraces = true;
+      NS_ADDREF(*aListener = this);
+      return NS_OK;
+    }
+
+    NS_IMETHOD GetWantAllTraces(bool* aAllTraces)
+    {
+      *aAllTraces = mWantAllTraces;
+      return NS_OK;
+    }
+
     NS_IMETHOD Begin()
     {
         char name[MAXPATHLEN] = {'\0'};
         tmpnam(name);
         char *lastSlash = strrchr(name, XPCOM_FILE_PATH_SEPARATOR[0]);
         if (lastSlash) {
             *lastSlash = '\0';
         }
@@ -1451,16 +1464,17 @@ public:
         fclose(mStream);
         mStream = nsnull;
 
         return NS_OK;
     }
 
 private:
     FILE *mStream;
+    bool mWantAllTraces;
 
     static PRUint32 gLogCounter;
 };
 
 NS_IMPL_ISUPPORTS1(nsCycleCollectorLogger, nsICycleCollectorListener)
 
 PRUint32 nsCycleCollectorLogger::gLogCounter = 0;
 
@@ -1579,25 +1593,32 @@ GCGraphBuilder::GCGraphBuilder(GCGraph &
       mEdgeBuilder(aGraph.mEdges),
       mWeakMaps(aGraph.mWeakMaps),
       mRuntimes(aRuntimes),
       mListener(aListener)
 {
     if (!PL_DHashTableInit(&mPtrToNodeMap, &PtrNodeOps, nsnull,
                            sizeof(PtrToNodeEntry), 32768))
         mPtrToNodeMap.ops = nsnull;
-    // We want all edges and all info if DEBUG_CC is set or if we have a
-    // listener. Do we want them all the time?
-#ifndef DEBUG_CC
-    if (mListener)
+
+    PRUint32 flags = 0;
+#ifdef DEBUG_CC
+    flags = nsCycleCollectionTraversalCallback::WANT_DEBUG_INFO |
+            nsCycleCollectionTraversalCallback::WANT_ALL_TRACES;
 #endif
-    {
-        mFlags |= nsCycleCollectionTraversalCallback::WANT_DEBUG_INFO |
-                  nsCycleCollectionTraversalCallback::WANT_ALL_TRACES;
+    if (!flags && mListener) {
+        flags = nsCycleCollectionTraversalCallback::WANT_DEBUG_INFO;
+        bool all = false;
+        mListener->GetWantAllTraces(&all);
+        if (all) {
+            flags |= nsCycleCollectionTraversalCallback::WANT_ALL_TRACES;
+        }
     }
+
+    mFlags |= flags;
 }
 
 GCGraphBuilder::~GCGraphBuilder()
 {
     if (mPtrToNodeMap.ops)
         PL_DHashTableFinish(&mPtrToNodeMap);
 }
 
--- a/xpcom/base/nsICycleCollectorListener.idl
+++ b/xpcom/base/nsICycleCollectorListener.idl
@@ -44,19 +44,23 @@
  * beginResults(); then a mixture of describeRoot() for ref counted
  * nodes the CC has identified as roots and describeGarbage() for
  * nodes the CC has identified as garbage.  Ref counted nodes that are
  * not identified as either roots or garbage are neither, and have a
  * known edges count equal to their ref count.  Finally, there will be
  * a call to end().  If begin() returns an error none of the other
  * functions will be called.
  */
-[scriptable, uuid(3f3901bb-6a1c-4998-b32e-6f10a51db470)]
+[scriptable, uuid(35a3a9b0-a120-4bf7-9739-46027fe96212)]
 interface nsICycleCollectorListener : nsISupports
 {
+    nsICycleCollectorListener allTraces();
+    // false if allTraces() has not been called.
+    readonly attribute boolean wantAllTraces;
+
     void begin();
     void noteRefCountedObject (in unsigned long long aAddress,
 			       in unsigned long aRefCount,
 			       in string aObjectDescription);
     void noteGCedObject (in unsigned long long aAddress,
 			 in boolean aMarked,
 			 in string aObjectDescription);
     void noteEdge(in unsigned long long aToAddress,