Merge mozilla-central to inbound. a=merge CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Sun, 02 Sep 2018 01:00:31 +0300
changeset 492196 7f63a3e0614789ff83efd539a4395ee809d4af59
parent 492195 dedd5c14209a8a120ad837784362c5c8539d8784 (current diff)
parent 492184 8284cddccf78566ca4dc45272940ccae4b1150df (diff)
child 492197 766ddd82a829064d4dc62c1178140e39136fb931
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone63.0a1
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
Merge mozilla-central to inbound. a=merge CLOSED TREE
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1754,8 +1754,13 @@ pref("app.shield.optoutstudies.enabled",
 
 // Multi-lingual preferences
 pref("intl.multilingual.enabled", false);
 
 // Prio preferences
 // Curve25519 public keys for Prio servers
 pref("prio.publicKeyA", "35AC1C7576C7C6EDD7FED6BCFC337B34D48CB4EE45C86BEEFB40BD8875707733");
 pref("prio.publicKeyB", "26E6674E65425B823F1F1D5F96E3BB3EF9E406EC7FBA7DEF8B08A35DD135AF50");
+
+#ifdef NIGHTLY_BUILD
+pref("browser.fastblock.enabled", true);
+#endif
+
--- a/browser/components/preferences/in-content/tests/browser_contentblocking.js
+++ b/browser/components/preferences/in-content/tests/browser_contentblocking.js
@@ -67,17 +67,17 @@ add_task(async function testContentBlock
     FB_PREF,
     TP_LIST_PREF,
     TP_PREF,
     TP_PBM_PREF,
     NCB_PREF,
   ];
 
   Services.prefs.setBoolPref(CB_PREF, false);
-  Services.prefs.setBoolPref(FB_PREF, true);
+  Services.prefs.setBoolPref(FB_PREF, !Services.prefs.getBoolPref(FB_PREF));
   Services.prefs.setStringPref(TP_LIST_PREF, "test-track-simple,base-track-digest256,content-track-digest256");
   Services.prefs.setBoolPref(TP_PREF, true);
   Services.prefs.setBoolPref(TP_PBM_PREF, false);
   Services.prefs.setIntPref(NCB_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
 
   for (let pref of prefs) {
     ok(Services.prefs.prefHasUserValue(pref), `modified the pref ${pref}`);
   }
@@ -123,17 +123,17 @@ add_task(async function testContentBlock
   let resettable = [
     CB_PREF,
     FB_PREF,
     TP_LIST_PREF,
     NCB_PREF,
   ];
 
   Services.prefs.setBoolPref(CB_PREF, false);
-  Services.prefs.setBoolPref(FB_PREF, true);
+  Services.prefs.setBoolPref(FB_PREF, !Services.prefs.getBoolPref(FB_PREF));
   Services.prefs.setStringPref(TP_LIST_PREF, "test-track-simple,base-track-digest256,content-track-digest256");
   Services.prefs.setIntPref(NCB_PREF, Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER);
 
   for (let pref of resettable) {
     ok(Services.prefs.prefHasUserValue(pref), `modified the pref ${pref}`);
   }
 
   await extension.startup();
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -742,24 +742,25 @@ FragmentOrElement::nsDOMSlots::SizeOfInc
 
     n += extendedSlots->SizeOfExcludingThis(aMallocSizeOf);
   }
 
   if (mAttributeMap) {
     n += mAttributeMap->SizeOfIncludingThis(aMallocSizeOf);
   }
 
+  if (mChildrenList) {
+    n += mChildrenList->SizeOfIncludingThis(aMallocSizeOf);
+  }
+
   // Measurement of the following members may be added later if DMD finds it is
   // worthwhile:
   // - Superclass members (nsINode::nsSlots)
   // - mStyle
   // - mDataSet
-  // - mSMILOverrideStyle
-  // - mSMILOverrideStyleDeclaration
-  // - mChildrenList
   // - mClassList
 
   // The following member are not measured:
   // - mControllers: because it is non-owning
   // - mBindingParent: because it is some ancestor element.
   return n;
 }
 
@@ -830,20 +831,18 @@ FragmentOrElement::nsExtendedDOMSlots::S
   // it.
 
   // We don't seem to have memory reporting for nsXULControllers.  At least
   // report the memory it's using directly.
   if (mControllers) {
     n += aMallocSizeOf(mControllers);
   }
 
-  // We don't seem to have memory reporting for nsLabelsNodeList.  At least
-  // report the memory it's using directly.
   if (mLabelsList) {
-    n += aMallocSizeOf(mLabelsList);
+    n += mLabelsList->SizeOfIncludingThis(aMallocSizeOf);
   }
 
   // mShadowRoot should be handled during normal DOM tree memory reporting, just
   // like kids, siblings, etc.
 
   // We don't seem to have memory reporting for nsXBLBinding.  At least
   // report the memory it's using directly.
   if (mXBLBinding) {
--- a/dom/base/nsContentList.cpp
+++ b/dom/base/nsContentList.cpp
@@ -100,16 +100,24 @@ nsBaseContentList::IndexOf(nsIContent *a
 }
 
 int32_t
 nsBaseContentList::IndexOf(nsIContent* aContent)
 {
   return IndexOf(aContent, true);
 }
 
+size_t
+nsBaseContentList::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+{
+  size_t n = aMallocSizeOf(this);
+  n += mElements.ShallowSizeOfExcludingThis(aMallocSizeOf);
+  return n;
+}
+
 NS_IMPL_CYCLE_COLLECTION_INHERITED(nsSimpleContentList, nsBaseContentList,
                                    mRoot)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSimpleContentList)
 NS_INTERFACE_MAP_END_INHERITING(nsBaseContentList)
 
 
 NS_IMPL_ADDREF_INHERITED(nsSimpleContentList, nsBaseContentList)
--- a/dom/base/nsContentList.h
+++ b/dom/base/nsContentList.h
@@ -22,16 +22,17 @@
 #include "nsINodeList.h"
 #include "nsStubMutationObserver.h"
 #include "nsAtom.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsNameSpaceManager.h"
 #include "nsWrapperCache.h"
 #include "nsHashKeys.h"
 #include "mozilla/HashFunctions.h"
+#include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/NameSpaceConstants.h"
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
@@ -89,16 +90,21 @@ public:
 
   void SetCapacity(uint32_t aCapacity)
   {
     mElements.SetCapacity(aCapacity);
   }
 
   virtual void LastRelease() {}
 
+  // Memory reporting.  For now, subclasses of nsBaseContentList don't really
+  // need to report any members that are not part of the object itself, so we
+  // don't need to make this virtual.
+  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+
 protected:
   virtual ~nsBaseContentList();
 
   /**
    * To be called from non-destructor locations (e.g. unlink) that want to
    * remove from caches.  Cacheable subclasses should override.
    */
   virtual void RemoveFromCaches()
--- a/gfx/layers/opengl/GLBlitTextureImageHelper.cpp
+++ b/gfx/layers/opengl/GLBlitTextureImageHelper.cpp
@@ -235,19 +235,18 @@ GLBlitTextureImageHelper::UseBlitProgram
 
         gl->fCompileShader(shaders[i]);
         gl->fGetShaderiv(shaders[i], LOCAL_GL_COMPILE_STATUS, &success);
         NS_ASSERTION(success, "Shader compilation failed!");
 
         if (!success) {
             nsAutoCString log;
             gl->fGetShaderiv(shaders[i], LOCAL_GL_INFO_LOG_LENGTH, (GLint*) &len);
-            log.SetCapacity(len);
+            log.SetLength(len);
             gl->fGetShaderInfoLog(shaders[i], len, (GLint*) &len, (char*) log.BeginWriting());
-            log.SetLength(len);
 
             printf_stderr("Shader %d compilation failed:\n%s\n", i, log.get());
             return;
         }
 
         gl->fAttachShader(mBlitProgram, shaders[i]);
         gl->fDeleteShader(shaders[i]);
     }
@@ -259,19 +258,18 @@ GLBlitTextureImageHelper::UseBlitProgram
 
     GLint success, len = 0;
     gl->fGetProgramiv(mBlitProgram, LOCAL_GL_LINK_STATUS, &success);
     NS_ASSERTION(success, "Shader linking failed!");
 
     if (!success) {
         nsAutoCString log;
         gl->fGetProgramiv(mBlitProgram, LOCAL_GL_INFO_LOG_LENGTH, (GLint*) &len);
-        log.SetCapacity(len);
+        log.SetLength(len);
         gl->fGetProgramInfoLog(mBlitProgram, len, (GLint*) &len, (char*) log.BeginWriting());
-        log.SetLength(len);
 
         printf_stderr("Program linking failed:\n%s\n", log.get());
         return;
     }
 
     gl->fUseProgram(mBlitProgram);
     gl->fUniform1i(gl->fGetUniformLocation(mBlitProgram, "uSrcTexture"), 0);
 }
--- a/gfx/layers/opengl/OGLShaderProgram.cpp
+++ b/gfx/layers/opengl/OGLShaderProgram.cpp
@@ -941,19 +941,18 @@ ShaderProgramOGL::CreateProgram(const ch
    */
   if (!success
 #ifdef DEBUG
       || (len > 10 && gfxEnv::DebugShaders())
 #endif
       )
   {
     nsAutoCString log;
-    log.SetCapacity(len);
+    log.SetLength(len);
     mGL->fGetProgramInfoLog(result, len, (GLint*) &len, (char*) log.BeginWriting());
-    log.SetLength(len);
 
     if (!success) {
       printf_stderr("=== PROGRAM LINKING FAILED ===\n");
     } else {
       printf_stderr("=== PROGRAM LINKING WARNINGS ===\n");
     }
     printf_stderr("=== Log:\n%s\n", log.get());
     printf_stderr("============\n");
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_filter.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_filter.html
@@ -131,16 +131,25 @@ add_task(async function test_webRequest_
     "file_image_good.png": {
       // These events only happen in non-e10s. See bug 1472156.
       optional_events: ["onBeforeRedirect", "onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders"],
       type: "main_frame",
       // cached: AppConstants.MOZ_BUILD_APP === "browser",
     },
   };
 
+  if (AppConstants.platform != "android") {
+    // A favicon request may be initiated, and complete or be aborted.
+    expect["favicon.ico"] = {
+      optional_events: ["onBeforeRedirect", "onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", "onHeadersReceived", "onResponseStarted", "onCompleted", "onErrorOccurred"],
+      type: "image",
+      origin: SimpleTest.getTestFileURL(img),
+    };
+  }
+
   let extension = makeExtension(events);
   await extension.startup();
   extension.sendMessage("set-expected", {expect, origin: location.href});
   await extension.awaitMessage("continue");
 
   if (AppConstants.MOZ_BUILD_APP === "browser") {
     // We should not get events for a new window load.
     let newWindow = window.open(img, "_blank", "width=100,height=100");
--- a/toolkit/components/url-classifier/tests/mochitest/test_classifier.html
+++ b/toolkit/components/url-classifier/tests/mochitest/test_classifier.html
@@ -166,16 +166,17 @@ function testService() {
 }
 
 SpecialPowers.pushPrefEnv(
   {"set": [["urlclassifier.malwareTable", "test-malware-simple,test-unwanted-simple,test-harmful-simple"],
            ["urlclassifier.phishTable", "test-phish-simple"],
            ["urlclassifier.downloadBlockTable", "test-block-simple"],
            ["urlclassifier.trackingTable", "test-track-simple"],
            ["browser.safebrowsing.debug", true],
+           ["browser.fastblock.enabled", false],
            ["privacy.trackingprotection.annotate_channels", true]]},
   function() {
     classifierHelper.waitForInit()
       .then(() => classifierHelper.addUrlToDB(testData))
       .then(updateSuccess)
       .catch(err => {
         updateError(err);
       })
--- a/toolkit/components/url-classifier/tests/mochitest/test_classify_ping.html
+++ b/toolkit/components/url-classifier/tests/mochitest/test_classify_ping.html
@@ -126,14 +126,15 @@
       });
   }
 
   SimpleTest.waitForExplicitFinish();
   SimpleTest.registerCleanupFunction(cleanup);
   SpecialPowers.pushPrefEnv({"set": [
     ["browser.send_pings", true],
     ["urlclassifier.trackingTable", "test-track-simple"],
+    ["browser.fastblock.enabled", false],
   ]}, runTest);
 
 </script>
 </pre>
 </body>
 </html>
--- a/xpcom/string/nsTSubstring.cpp
+++ b/xpcom/string/nsTSubstring.cpp
@@ -760,17 +760,20 @@ nsTSubstring<T>::Replace(index_type aCut
 
 template <typename T>
 void
 nsTSubstring<T>::ReplaceLiteral(index_type aCutStart, size_type aCutLength,
                                 const char_type* aData, size_type aLength)
 {
   aCutStart = XPCOM_MIN(aCutStart, this->Length());
 
-  if (!aCutStart && aCutLength == this->Length()) {
+  if (!aCutStart && aCutLength == this->Length() &&
+      !(this->mDataFlags & DataFlags::REFCOUNTED)) {
+    // Check for REFCOUNTED above to avoid undoing the effect of
+    // SetCapacity().
     AssignLiteral(aData, aLength);
   } else if (ReplacePrep(aCutStart, aCutLength, aLength) && aLength > 0) {
     char_traits::copy(this->mData + aCutStart, aData, aLength);
   }
 }
 
 template <typename T>
 void
--- a/xpcom/string/nsTSubstring.h
+++ b/xpcom/string/nsTSubstring.h
@@ -857,33 +857,56 @@ public:
   nsTSubstringSplitter<T> Split(const char_type aChar) const;
 
   /**
    * buffer sizing
    */
 
   /**
    * Attempts to set the capacity to the given size in number of
-   * code units without affecting the length of the string, in
-   * order to avoid reallocation during subsequent calls to Append()
-   * or subsequent converting appends where the conversion is between
-   * UTF-16 and Latin1 (in either direction).
+   * code units without affecting the length of the string in
+   * order to avoid reallocation during a subsequent sequence of
+   * appends.
+   *
+   * This method is appropriate to use before a sequence of multiple
+   * operations from the following list (without operations that are
+   * not on the list between the SetCapacity() call and operations
+   * from the list):
    *
-   * Calling SetCapacity() is a pessimization ahead of a converting
-   * append where the conversion is between UTF-16 and UTF-8 (in
-   * either direction), so please don't call SetCapacity() ahead
-   * of that kind of converting append.
+   * Append()
+   * AppendASCII()
+   * AppendLiteral() (except if the string is empty: bug 1487606)
+   * AppendPrintf()
+   * AppendInt()
+   * AppendFloat()
+   * LossyAppendUTF16toASCII()
+   * AppendASCIItoUTF16()
+   *
+   * DO NOT call SetCapacity() if the subsequent operations on the
+   * string do not meet the criteria above. Operations that undo
+   * the benefits of SetCapacity() include but are not limited to:
+   *
+   * SetLength()
+   * Truncate()
+   * Assign()
+   * AssignLiteral()
+   * Adopt()
+   * CopyASCIItoUTF16()
+   * LossyCopyUTF16toASCII()
+   * AppendUTF16toUTF8()
+   * AppendUTF8toUTF16()
+   * CopyUTF16toUTF8()
+   * CopyUTF8toUTF16()
    *
    * If your string is an nsAuto[C]String and you are calling
    * SetCapacity() with a constant N, please instead declare the
    * string as nsAuto[C]StringN<N+1> without calling SetCapacity().
    *
    * There is no need to include room for the null terminator: it is
    * the job of the string class.
-   * Also ensures that the buffer is mutable.
    *
    * Note: Calling SetCapacity() does not give you permission to
    * use the pointer obtained from BeginWriting() to write
    * past the current length (as returned by Length()) of the
    * string. Please use either BulkWrite() or SetLength()
    * instead.
    */
   void NS_FASTCALL SetCapacity(size_type aNewCapacity);
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -1284,43 +1284,57 @@ TEST(String, strip_chars)
                           u" ",
                           NS_LITERAL_STRING("foo"));
 }
 
 TEST_F(Strings, append_with_capacity)
 {
   nsAutoString s;
   const char16_t* origPtr = s.BeginReading();
-  s.SetCapacity(100);
+  s.SetCapacity(8000);
   const char16_t* ptr = s.BeginReading();
   EXPECT_NE(origPtr, ptr);
   for (int i = 0; i < 100; i++) {
     s.Append(u'a');
     EXPECT_EQ(s.BeginReading(), ptr);
     EXPECT_EQ(s.Length(), uint32_t(i + 1));
   }
 }
 
 TEST_F(Strings, append_string_with_capacity)
 {
   nsAutoString aa;
   aa.Append(u'a');
   aa.Append(u'a');
   nsAutoString s;
   const char16_t* origPtr = s.BeginReading();
-  s.SetCapacity(200);
+  s.SetCapacity(8000);
   const char16_t* ptr = s.BeginReading();
   EXPECT_NE(origPtr, ptr);
   for (int i = 0; i < 100; i++) {
     s.Append(aa);
     EXPECT_EQ(s.BeginReading(), ptr);
     EXPECT_EQ(s.Length(), uint32_t(2 * (i + 1)));
   }
 }
 
+TEST_F(Strings, append_literal_with_capacity)
+{
+  nsAutoString s;
+  const char16_t* origPtr = s.BeginReading();
+  s.SetCapacity(8000);
+  const char16_t* ptr = s.BeginReading();
+  EXPECT_NE(origPtr, ptr);
+  for (int i = 0; i < 100; i++) {
+    s.AppendLiteral(u"aa");
+    EXPECT_EQ(s.BeginReading(), ptr);
+    EXPECT_EQ(s.Length(), uint32_t(2 * (i + 1)));
+  }
+}
+
 TEST_F(Strings, legacy_set_length_semantics)
 {
   const char* foobar = "foobar";
   nsCString s;
   s.SetCapacity(2048);
   memcpy(s.BeginWriting(), foobar, strlen(foobar));
   s.SetLength(strlen(foobar));
   EXPECT_TRUE(s.EqualsASCII(foobar));