Bug 1551779 part 6. Stop using [array] for replaceFaviconData. r=mak
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 16 May 2019 14:20:17 +0000
changeset 474113 fb8cc6cad30a0f94d5858cc35b20ce77acc605d2
parent 474112 5db31f792bf4ee2c800edfc88d69e7d825ab3e44
child 474114 283b94c196a15367f287fd7f2bb6c9b4bcad0b45
push id85659
push userbzbarsky@mozilla.com
push dateThu, 16 May 2019 15:15:02 +0000
treeherderautoland@fb8cc6cad30a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1551779
milestone68.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
Bug 1551779 part 6. Stop using [array] for replaceFaviconData. r=mak Differential Revision: https://phabricator.services.mozilla.com/D31243
toolkit/components/places/nsFaviconService.cpp
toolkit/components/places/nsIFaviconService.idl
toolkit/components/places/tests/favicons/test_expire_on_new_icons.js
toolkit/components/places/tests/favicons/test_favicons_conversions.js
toolkit/components/places/tests/favicons/test_favicons_protocols_ref.js
toolkit/components/places/tests/favicons/test_getFaviconDataForPage.js
toolkit/components/places/tests/favicons/test_getFaviconURLForPage.js
toolkit/components/places/tests/favicons/test_heavy_favicon.js
toolkit/components/places/tests/favicons/test_incremental_vacuum.js
toolkit/components/places/tests/favicons/test_multiple_frames.js
toolkit/components/places/tests/favicons/test_replaceFaviconData.js
toolkit/components/places/tests/favicons/test_replaceFaviconDataFromDataURL.js
toolkit/components/places/tests/favicons/test_root_icons.js
--- a/toolkit/components/places/nsFaviconService.cpp
+++ b/toolkit/components/places/nsFaviconService.cpp
@@ -380,24 +380,23 @@ nsFaviconService::SetAndFetchFaviconForP
 
   // Return this event to the caller to allow aborting an eventual fetch.
   event.forget(_canceler);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsFaviconService::ReplaceFaviconData(nsIURI* aFaviconURI, const uint8_t* aData,
-                                     uint32_t aDataLen,
+nsFaviconService::ReplaceFaviconData(nsIURI* aFaviconURI,
+                                     const nsTArray<uint8_t>& aData,
                                      const nsACString& aMimeType,
                                      PRTime aExpiration) {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_ARG(aFaviconURI);
-  NS_ENSURE_ARG(aData);
-  NS_ENSURE_ARG(aDataLen > 0);
+  NS_ENSURE_ARG(aData.Length() > 0);
   NS_ENSURE_ARG(aMimeType.Length() > 0);
   NS_ENSURE_ARG(imgLoader::SupportImageWithMimeType(
       PromiseFlatCString(aMimeType).get(),
       AcceptedMimeTypes::IMAGES_AND_DOCUMENTS));
 
   if (aExpiration == 0) {
     aExpiration = PR_Now() + MAX_FAVICON_EXPIRATION;
   }
@@ -434,17 +433,17 @@ nsFaviconService::ReplaceFaviconData(nsI
   // Note we can't set rootIcon here, because don't know the page it will be
   // associated with. We'll do that later in SetAndFetchFaviconForPage if the
   // icon doesn't exist; otherwise, if AsyncReplaceFaviconData updates an
   // existing icon, it will take care of not overwriting an existing
   // root = 1 value.
 
   IconPayload payload;
   payload.mimeType = aMimeType;
-  payload.data.Assign(TO_CHARBUFFER(aData), aDataLen);
+  payload.data.Assign(TO_CHARBUFFER(aData.Elements()), aData.Length());
   if (payload.mimeType.EqualsLiteral(SVG_MIME_TYPE)) {
     payload.width = UINT16_MAX;
   }
   // There may already be a previous payload, so ensure to only have one.
   iconData->payloads.Clear();
   iconData->payloads.AppendElement(payload);
 
   rv = OptimizeIconSizes(*iconData);
@@ -530,36 +529,32 @@ nsFaviconService::ReplaceFaviconDataFrom
   uint64_t available64;
   rv = stream->Available(&available64);
   NS_ENSURE_SUCCESS(rv, rv);
   if (available64 == 0 || available64 > UINT32_MAX / sizeof(uint8_t))
     return NS_ERROR_FILE_TOO_BIG;
   uint32_t available = (uint32_t)available64;
 
   // Read all the decoded data.
-  uint8_t* buffer =
-      static_cast<uint8_t*>(moz_xmalloc(sizeof(uint8_t) * available));
+  nsTArray<uint8_t> buffer;
+  buffer.SetLength(available);
   uint32_t numRead;
-  rv = stream->Read(TO_CHARBUFFER(buffer), available, &numRead);
+  rv = stream->Read(TO_CHARBUFFER(buffer.Elements()), available, &numRead);
   if (NS_FAILED(rv) || numRead != available) {
-    free(buffer);
     return rv;
   }
 
   nsAutoCString mimeType;
   rv = channel->GetContentType(mimeType);
   if (NS_FAILED(rv)) {
-    free(buffer);
     return rv;
   }
 
   // ReplaceFaviconData can now do the dirty work.
-  rv =
-      ReplaceFaviconData(aFaviconURI, buffer, available, mimeType, aExpiration);
-  free(buffer);
+  rv = ReplaceFaviconData(aFaviconURI, buffer, mimeType, aExpiration);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFaviconService::GetFaviconURLForPage(nsIURI* aPageURI,
                                        nsIFaviconDataCallback* aCallback,
--- a/toolkit/components/places/nsIFaviconService.idl
+++ b/toolkit/components/places/nsIFaviconService.idl
@@ -163,31 +163,28 @@ interface nsIFaviconService : nsISupport
    * than a defined limit we will try to convert it to a 16x16 png image.
    * If the conversion fails and favicon is still bigger than our max accepted
    * size it won't be saved.
    *
    * @param aFaviconURI
    *        URI of the favicon whose data is being set.
    * @param aData
    *        Binary contents of the favicon to save
-   * @param aDataLength
-   *        Length of binary data
    * @param aMimeType
    *        MIME type of the data to store.  This is important so that we know
    *        what to report when the favicon is used.  You should always set this
    *        param unless you are clearing an icon.
    * @param [optional] aExpiration
    *        Time in microseconds since the epoch when this favicon expires.
    *        Until this time, we won't try to load it again.
    * @throws NS_ERROR_FAILURE
    *         Thrown if the favicon is overbloated and won't be saved to the db.
    */
   void replaceFaviconData(in nsIURI aFaviconURI,
-                          [const,array,size_is(aDataLen)] in octet aData,
-                          in unsigned long aDataLen,
+                          in Array<octet> aData,
                           in AUTF8String aMimeType,
                           [optional] in PRTime aExpiration);
 
   /**
    * Same as replaceFaviconData but the data is provided by a string
    * containing a data URL.
    *
    * @see replaceFaviconData
--- a/toolkit/components/places/tests/favicons/test_expire_on_new_icons.js
+++ b/toolkit/components/places/tests/favicons/test_expire_on_new_icons.js
@@ -24,23 +24,23 @@ add_task(async function test_replaceFavi
       mimeType: "image/png",
       expire: 0,
     },
   ];
 
   for (let icon of favicons) {
     let data = readFileData(do_get_file(icon.name));
     PlacesUtils.favicons.replaceFaviconData(NetUtil.newURI(TEST_URL + icon.name),
-                                            data, data.length,
+                                            data,
                                             icon.mimeType,
                                             icon.expire);
     await setFaviconForPage(TEST_URL, TEST_URL + icon.name);
     if (icon.expire != 0) {
       PlacesUtils.favicons.replaceFaviconData(NetUtil.newURI(TEST_URL + icon.name),
-                                              data, data.length,
+                                              data,
                                               icon.mimeType,
                                               icon.expire);
       await setFaviconForPage(TEST_URL2, TEST_URL + icon.name);
     }
   }
 
   // Only the second and the third icons should have survived.
   Assert.equal(await getFaviconUrlForPage(TEST_URL, 16),
--- a/toolkit/components/places/tests/favicons/test_favicons_conversions.js
+++ b/toolkit/components/places/tests/favicons/test_favicons_conversions.js
@@ -31,18 +31,17 @@ var isWindows = ("@mozilla.org/windows-r
  */
 async function checkFaviconDataConversion(aFileName, aFileMimeType, aFileLength,
                                     aExpectConversion, aVaryOnWindows) {
   let pageURI = NetUtil.newURI("http://places.test/page/" + aFileName);
   await PlacesTestUtils.addVisits({ uri: pageURI, transition: TRANSITION_TYPED });
   let faviconURI = NetUtil.newURI("http://places.test/icon/" + aFileName);
   let fileData = readFileOfLength(aFileName, aFileLength);
 
-  PlacesUtils.favicons.replaceFaviconData(faviconURI, fileData, fileData.length,
-                                          aFileMimeType);
+  PlacesUtils.favicons.replaceFaviconData(faviconURI, fileData, aFileMimeType);
   await new Promise(resolve => {
     PlacesUtils.favicons.setAndFetchFaviconForPage(pageURI, faviconURI, true,
       PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
       (aURI, aDataLen, aData, aMimeType) => {
         if (!aExpectConversion) {
           Assert.ok(compareArrays(aData, fileData));
           Assert.equal(aMimeType, aFileMimeType);
         } else {
--- a/toolkit/components/places/tests/favicons/test_favicons_protocols_ref.js
+++ b/toolkit/components/places/tests/favicons/test_favicons_protocols_ref.js
@@ -7,21 +7,21 @@ const ICON16_URL = "http://places.test/f
 const ICON32_URL = "http://places.test/favicon-normal32.png";
 
 add_task(async function() {
   await PlacesTestUtils.addVisits(PAGE_URL);
   // Add 2 differently sized favicons for this page.
 
   let data = readFileData(do_get_file("favicon-normal16.png"));
   PlacesUtils.favicons.replaceFaviconData(NetUtil.newURI(ICON16_URL),
-                                          data, data.length, "image/png");
+                                          data, "image/png");
   await setFaviconForPage(PAGE_URL, ICON16_URL);
   data = readFileData(do_get_file("favicon-normal32.png"));
   PlacesUtils.favicons.replaceFaviconData(NetUtil.newURI(ICON32_URL),
-                                          data, data.length, "image/png");
+                                          data, "image/png");
   await setFaviconForPage(PAGE_URL, ICON32_URL);
 
   const PAGE_ICON_URL = "page-icon:" + PAGE_URL;
 
   await compareFavicons(PAGE_ICON_URL,
                         PlacesUtils.favicons.getFaviconLinkForIcon(NetUtil.newURI(ICON32_URL)),
                         "Not specifying a ref should return the bigger icon");
   // Fake window object.
--- a/toolkit/components/places/tests/favicons/test_getFaviconDataForPage.js
+++ b/toolkit/components/places/tests/favicons/test_getFaviconDataForPage.js
@@ -48,17 +48,17 @@ add_task(async function test_fallback() 
   const ROOT_URL = "https://www.example.com/";
   const ROOT_ICON_URL = ROOT_URL + "favicon.ico";
   const SUBPAGE_URL = ROOT_URL + "/missing";
 
   info("Set icon for the root");
   await PlacesTestUtils.addVisits(ROOT_URL);
   let data = readFileData(do_get_file("favicon-normal16.png"));
   PlacesUtils.favicons.replaceFaviconData(NetUtil.newURI(ROOT_ICON_URL),
-                                          data, data.length, "image/png");
+                                          data, "image/png");
   await setFaviconForPage(ROOT_URL, ROOT_ICON_URL);
 
   info("check fallback icons");
   await new Promise(resolve => {
     PlacesUtils.favicons.getFaviconDataForPage(NetUtil.newURI(ROOT_URL),
       (aURI, aDataLen, aData, aMimeType) => {
         Assert.equal(aURI.spec, ROOT_ICON_URL);
         Assert.equal(aDataLen, data.length);
@@ -77,17 +77,17 @@ add_task(async function test_fallback() 
         resolve();
       });
   });
 
   info("Now add a proper icon for the page");
   await PlacesTestUtils.addVisits(SUBPAGE_URL);
   let data32 = readFileData(do_get_file("favicon-normal32.png"));
   PlacesUtils.favicons.replaceFaviconData(NetUtil.newURI(ICON32_URL),
-                                          data32, data32.length, "image/png");
+                                          data32, "image/png");
   await setFaviconForPage(SUBPAGE_URL, ICON32_URL);
 
   info("check no fallback icons");
   await new Promise(resolve => {
     PlacesUtils.favicons.getFaviconDataForPage(NetUtil.newURI(ROOT_URL),
       (aURI, aDataLen, aData, aMimeType) => {
         Assert.equal(aURI.spec, ROOT_ICON_URL);
         Assert.equal(aDataLen, data.length);
--- a/toolkit/components/places/tests/favicons/test_getFaviconURLForPage.js
+++ b/toolkit/components/places/tests/favicons/test_getFaviconURLForPage.js
@@ -46,30 +46,30 @@ add_task(async function test_fallback() 
   const ROOT_URL = "https://www.example.com/";
   const ROOT_ICON_URL = ROOT_URL + "favicon.ico";
   const SUBPAGE_URL = ROOT_URL + "/missing";
 
   info("Set icon for the root");
   await PlacesTestUtils.addVisits(ROOT_URL);
   let data = readFileData(do_get_file("favicon-normal16.png"));
   PlacesUtils.favicons.replaceFaviconData(NetUtil.newURI(ROOT_ICON_URL),
-                                          data, data.length, "image/png");
+                                          data, "image/png");
   await setFaviconForPage(ROOT_URL, ROOT_ICON_URL);
 
   info("check fallback icons");
   Assert.equal(await getFaviconUrlForPage(ROOT_URL), ROOT_ICON_URL,
                "The root should have its favicon");
   Assert.equal(await getFaviconUrlForPage(SUBPAGE_URL), ROOT_ICON_URL,
                "The page should fallback to the root icon");
 
   info("Now add a proper icon for the page");
   await PlacesTestUtils.addVisits(SUBPAGE_URL);
   let data32 = readFileData(do_get_file("favicon-normal32.png"));
   PlacesUtils.favicons.replaceFaviconData(NetUtil.newURI(ICON32_URL),
-                                          data32, data32.length, "image/png");
+                                          data32, "image/png");
   await setFaviconForPage(SUBPAGE_URL, ICON32_URL);
 
   info("check no fallback icons");
   Assert.equal(await getFaviconUrlForPage(ROOT_URL), ROOT_ICON_URL,
                "The root should still have its favicon");
   Assert.equal(await getFaviconUrlForPage(SUBPAGE_URL), ICON32_URL,
                "The page should also have its icon");
 });
--- a/toolkit/components/places/tests/favicons/test_heavy_favicon.js
+++ b/toolkit/components/places/tests/favicons/test_heavy_favicon.js
@@ -19,14 +19,13 @@ add_task(async function() {
   // than this icon. For this test to make sense the icon shoul always be
   // bigger than MAX_FAVICON_BUFFER_SIZE. Please update the icon!
   Assert.ok(icon.data.length > Ci.nsIFaviconService.MAX_FAVICON_BUFFER_SIZE,
             "The test icon file size must be larger than Ci.nsIFaviconService.MAX_FAVICON_BUFFER_SIZE");
 
   let pageURI = uri("http://foo.bar/");
   await PlacesTestUtils.addVisits(pageURI);
 
-  PlacesUtils.favicons.replaceFaviconData(icon.uri, icon.data, icon.data.length,
-                                          icon.mimetype);
+  PlacesUtils.favicons.replaceFaviconData(icon.uri, icon.data, icon.mimetype);
   await setFaviconForPage(pageURI, icon.uri);
   Assert.equal(await getFaviconUrlForPage(pageURI), icon.uri.spec,
                "A resampled version of the icon should be stored");
 });
--- a/toolkit/components/places/tests/favicons/test_incremental_vacuum.js
+++ b/toolkit/components/places/tests/favicons/test_incremental_vacuum.js
@@ -11,18 +11,17 @@ add_task(async function() {
     mimetype: "image/png",
   };
 
   let url = "http://foo.bar/";
   await PlacesTestUtils.addVisits(url);
   for (let i = 0; i < 10; ++i) {
     let iconUri = NetUtil.newURI("http://mozilla.org/" + i);
     let data = readFileData(icon.file);
-    PlacesUtils.favicons.replaceFaviconData(iconUri, data, data.length,
-                                            icon.mimetype);
+    PlacesUtils.favicons.replaceFaviconData(iconUri, data, icon.mimetype);
     await setFaviconForPage(url, iconUri);
   }
 
   let promise = TestUtils.topicObserved("places-favicons-expired");
   PlacesUtils.favicons.expireAllFavicons();
   await promise;
 
   let db = await PlacesUtils.promiseDBConnection();
--- a/toolkit/components/places/tests/favicons/test_multiple_frames.js
+++ b/toolkit/components/places/tests/favicons/test_multiple_frames.js
@@ -10,18 +10,17 @@ add_task(async function() {
   // (howstuffworks.com icon, contains 13 icons with sizes from 16x16 to
   // 48x48 in varying depths)
   let pageURI = NetUtil.newURI("http://places.test/page/");
   await PlacesTestUtils.addVisits(pageURI);
   let faviconURI = NetUtil.newURI("http://places.test/icon/favicon-multi.ico");
   // Fake window.
   let win = { devicePixelRatio: 1.0 };
   let icoData = readFileData(do_get_file("favicon-multi.ico"));
-  PlacesUtils.favicons.replaceFaviconData(faviconURI, icoData, icoData.length,
-                                          "image/x-icon");
+  PlacesUtils.favicons.replaceFaviconData(faviconURI, icoData, "image/x-icon");
   await setFaviconForPage(pageURI, faviconURI);
 
   for (let size of [16, 32, 64]) {
     let file = do_get_file(`favicon-multi-frame${size}.png`);
     let data = readFileData(file);
 
     info("Check getFaviconDataForPage");
     let icon = await getFaviconDataForPage(pageURI, size);
--- a/toolkit/components/places/tests/favicons/test_replaceFaviconData.js
+++ b/toolkit/components/places/tests/favicons/test_replaceFaviconData.js
@@ -60,18 +60,17 @@ function run_test() {
 add_task(async function test_replaceFaviconData_validHistoryURI() {
   info("test replaceFaviconData for valid history uri");
 
   let pageURI = uri("http://test1.bar/");
   await PlacesTestUtils.addVisits(pageURI);
 
   let favicon = createFavicon("favicon1.png");
 
-  iconsvc.replaceFaviconData(favicon.uri, favicon.data, favicon.data.length,
-    favicon.mimetype);
+  iconsvc.replaceFaviconData(favicon.uri, favicon.data, favicon.mimetype);
 
   await new Promise(resolve => {
     iconsvc.setAndFetchFaviconForPage(pageURI, favicon.uri, true,
       PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
       function test_replaceFaviconData_validHistoryURI_check(aURI, aDataLen, aData, aMimeType) {
   dump("GOT " + aMimeType + "\n");
         checkCallbackSucceeded(aMimeType, aData, favicon.mimetype, favicon.data);
         checkFaviconDataForPage(
@@ -91,18 +90,17 @@ add_task(async function test_replaceFavi
 
   let pageURI = uri("http://test2.bar/");
   await PlacesTestUtils.addVisits(pageURI);
 
   let firstFavicon = createFavicon("favicon2.png");
   let secondFavicon = createFavicon("favicon3.png");
 
   iconsvc.replaceFaviconData(
-    firstFavicon.uri, secondFavicon.data, secondFavicon.data.length,
-    secondFavicon.mimetype);
+    firstFavicon.uri, secondFavicon.data, secondFavicon.mimetype);
 
   await new Promise(resolve => {
     iconsvc.setAndFetchFaviconForPage(
       pageURI, firstFavicon.uri, true,
       PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
       function test_replaceFaviconData_overrideDefaultFavicon_check(aURI, aDataLen, aData, aMimeType) {
         checkCallbackSucceeded(aMimeType, aData, secondFavicon.mimetype, secondFavicon.data);
         checkFaviconDataForPage(
@@ -132,18 +130,17 @@ add_task(async function test_replaceFavi
       pageURI, firstFavicon.uri, true,
       PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
       function test_replaceFaviconData_replaceExisting_firstSet_check(aURI, aDataLen, aData, aMimeType) {
         checkCallbackSucceeded(aMimeType, aData, firstFavicon.mimetype, firstFavicon.data);
         checkFaviconDataForPage(
           pageURI, firstFavicon.mimetype, firstFavicon.data,
           function test_replaceFaviconData_overrideDefaultFavicon_firstCallback() {
             iconsvc.replaceFaviconData(
-              firstFavicon.uri, secondFavicon.data, secondFavicon.data.length,
-              secondFavicon.mimetype);
+              firstFavicon.uri, secondFavicon.data, secondFavicon.mimetype);
             PlacesTestUtils.promiseAsyncUpdates().then(() => {
               checkFaviconDataForPage(
                 pageURI, secondFavicon.mimetype, secondFavicon.data,
                 function test_replaceFaviconData_overrideDefaultFavicon_secondCallback() {
                   firstFavicon.file.remove(false);
                   secondFavicon.file.remove(false);
                   resolve();
                 }, systemPrincipal);
@@ -160,18 +157,17 @@ add_task(async function test_replaceFavi
 
   let pageURI = uri("http://test4.bar/");
   await PlacesTestUtils.addVisits(pageURI);
 
   let favicon = createFavicon("favicon6.png");
   let unrelatedFavicon = createFavicon("favicon7.png");
 
   iconsvc.replaceFaviconData(
-    unrelatedFavicon.uri, unrelatedFavicon.data, unrelatedFavicon.data.length,
-    unrelatedFavicon.mimetype);
+    unrelatedFavicon.uri, unrelatedFavicon.data, unrelatedFavicon.mimetype);
 
   await new Promise(resolve => {
     iconsvc.setAndFetchFaviconForPage(
       pageURI, favicon.uri, true,
       PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
       function test_replaceFaviconData_unrelatedReplace_check(aURI, aDataLen, aData, aMimeType) {
         checkCallbackSucceeded(aMimeType, aData, favicon.mimetype, favicon.data);
         checkFaviconDataForPage(
@@ -187,47 +183,48 @@ add_task(async function test_replaceFavi
   await PlacesUtils.history.clear();
 });
 
 add_task(async function test_replaceFaviconData_badInputs() {
   info("test replaceFaviconData to throw on bad inputs");
   let icon = createFavicon("favicon8.png");
 
   Assert.throws(
-    () => iconsvc.replaceFaviconData(icon.uri, icon.data, icon.data.length, ""),
+    () => iconsvc.replaceFaviconData(icon.uri, icon.data, ""),
     /NS_ERROR_ILLEGAL_VALUE/);
   Assert.throws(
-    () => iconsvc.replaceFaviconData(icon.uri, icon.data, icon.data.length, "not-an-image"),
+    () => iconsvc.replaceFaviconData(icon.uri, icon.data, "not-an-image"),
     /NS_ERROR_ILLEGAL_VALUE/);
   Assert.throws(
-    () => iconsvc.replaceFaviconData(null, icon.data, icon.data.length, icon.mimetype),
+    () => iconsvc.replaceFaviconData(null, icon.data, icon.mimetype),
     /NS_ERROR_ILLEGAL_VALUE/);
   Assert.throws(
-    () => iconsvc.replaceFaviconData(icon.uri, null, 0, icon.mimetype),
+    () => iconsvc.replaceFaviconData(icon.uri, [], icon.mimetype),
     /NS_ERROR_ILLEGAL_VALUE/);
+  Assert.throws(
+    () => iconsvc.replaceFaviconData(icon.uri, null, icon.mimetype),
+    /NS_ERROR_XPC_CANT_CONVERT_PRIMITIVE_TO_ARRAY/);
 
   icon.file.remove(false);
   await PlacesUtils.history.clear();
 });
 
 add_task(async function test_replaceFaviconData_twiceReplace() {
   info("test replaceFaviconData on multiple replacements");
 
   let pageURI = uri("http://test5.bar/");
   await PlacesTestUtils.addVisits(pageURI);
 
   let firstFavicon = createFavicon("favicon9.png");
   let secondFavicon = createFavicon("favicon10.png");
 
   iconsvc.replaceFaviconData(
-    firstFavicon.uri, firstFavicon.data, firstFavicon.data.length,
-    firstFavicon.mimetype);
+    firstFavicon.uri, firstFavicon.data, firstFavicon.mimetype);
   iconsvc.replaceFaviconData(
-    firstFavicon.uri, secondFavicon.data, secondFavicon.data.length,
-    secondFavicon.mimetype);
+    firstFavicon.uri, secondFavicon.data, secondFavicon.mimetype);
 
   await new Promise(resolve => {
     iconsvc.setAndFetchFaviconForPage(
       pageURI, firstFavicon.uri, true,
       PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
       function test_replaceFaviconData_twiceReplace_check(aURI, aDataLen, aData, aMimeType) {
         checkCallbackSucceeded(aMimeType, aData, secondFavicon.mimetype, secondFavicon.data);
         checkFaviconDataForPage(
@@ -256,22 +253,20 @@ add_task(async function test_replaceFavi
   const PAGE_URL = "http://rootoverwrite.bar/";
   let pageURI = Services.io.newURI(PAGE_URL);
   const ICON_URL = "http://rootoverwrite.bar/favicon.ico";
   let iconURI = Services.io.newURI(ICON_URL);
 
   await PlacesTestUtils.addVisits(pageURI);
 
   let icon = createFavicon("favicon9.png");
-  PlacesUtils.favicons.replaceFaviconData(iconURI, icon.data, icon.data.length,
-                                          icon.mimetype);
+  PlacesUtils.favicons.replaceFaviconData(iconURI, icon.data, icon.mimetype);
   await PlacesTestUtils.addFavicons(new Map([[PAGE_URL, ICON_URL]]));
 
   Assert.equal(await getRootValue(ICON_URL), 1, "Check root == 1");
   let icon2 = createFavicon("favicon10.png");
-  PlacesUtils.favicons.replaceFaviconData(iconURI, icon2.data, icon2.data.length,
-                                          icon2.mimetype);
+  PlacesUtils.favicons.replaceFaviconData(iconURI, icon2.data, icon2.mimetype);
   // replaceFaviconData doesn't have a callback, but we must wait its updated.
   await PlacesTestUtils.promiseAsyncUpdates();
   Assert.equal(await getRootValue(ICON_URL), 1, "Check root did not change");
 
   await PlacesUtils.history.clear();
 });
--- a/toolkit/components/places/tests/favicons/test_replaceFaviconDataFromDataURL.js
+++ b/toolkit/components/places/tests/favicons/test_replaceFaviconDataFromDataURL.js
@@ -251,19 +251,18 @@ add_task(async function test_replaceFavi
   info("test replaceFaviconDataFromDataURL after replaceFaviconData");
 
   let pageURI = uri("http://test6.bar/");
   await PlacesTestUtils.addVisits(pageURI);
 
   let firstFavicon = createFavicon("favicon11.png");
   let secondFavicon = createFavicon("favicon12.png");
 
-  iconsvc.replaceFaviconData(
-    firstFavicon.uri, firstFavicon.data, firstFavicon.data.length,
-    firstFavicon.mimetype);
+  iconsvc.replaceFaviconData(firstFavicon.uri, firstFavicon.data,
+                             firstFavicon.mimetype);
   iconsvc.replaceFaviconDataFromDataURL(firstFavicon.uri, createDataURLForFavicon(secondFavicon), 0,
                                         Services.scriptSecurityManager.getSystemPrincipal());
 
   await new Promise(resolve => {
     iconsvc.setAndFetchFaviconForPage(
       pageURI, firstFavicon.uri, true,
       PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
       function test_replaceFaviconDataFromDataURL_afterRegularAssign_check(aURI, aDataLen, aData, aMimeType) {
@@ -287,19 +286,18 @@ add_task(async function test_replaceFavi
   let pageURI = uri("http://test7.bar/");
   await PlacesTestUtils.addVisits(pageURI);
 
   let firstFavicon = createFavicon("favicon13.png");
   let secondFavicon = createFavicon("favicon14.png");
 
   iconsvc.replaceFaviconDataFromDataURL(firstFavicon.uri, createDataURLForFavicon(firstFavicon), 0,
                                         Services.scriptSecurityManager.getSystemPrincipal());
-  iconsvc.replaceFaviconData(
-    firstFavicon.uri, secondFavicon.data, secondFavicon.data.length,
-    secondFavicon.mimetype);
+  iconsvc.replaceFaviconData(firstFavicon.uri, secondFavicon.data,
+                             secondFavicon.mimetype);
 
   await new Promise(resolve => {
     iconsvc.setAndFetchFaviconForPage(
       pageURI, firstFavicon.uri, true,
       PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
       function test_replaceFaviconDataFromDataURL_beforeRegularAssign_check(aURI, aDataLen, aData, aMimeType) {
         checkCallbackSucceeded(aMimeType, aData, secondFavicon.mimetype, secondFavicon.data);
         checkFaviconDataForPage(
--- a/toolkit/components/places/tests/favicons/test_root_icons.js
+++ b/toolkit/components/places/tests/favicons/test_root_icons.js
@@ -126,20 +126,20 @@ add_task(async function test_different_h
 add_task(async function test_same_size() {
   // Add two icons with the same size, one is a root icon. Check that the
   // non-root icon is preferred when a smaller size is requested.
   let data = readFileData(do_get_file("favicon-normal32.png"));
   let pageURI = NetUtil.newURI("http://new_places.test/page/");
   await PlacesTestUtils.addVisits(pageURI);
 
   let faviconURI = NetUtil.newURI("http://new_places.test/favicon.ico");
-  PlacesUtils.favicons.replaceFaviconData(faviconURI, data, data.length, "image/png");
+  PlacesUtils.favicons.replaceFaviconData(faviconURI, data, "image/png");
   await setFaviconForPage(pageURI, faviconURI);
   faviconURI = NetUtil.newURI("http://new_places.test/another_icon.ico");
-  PlacesUtils.favicons.replaceFaviconData(faviconURI, data, data.length, "image/png");
+  PlacesUtils.favicons.replaceFaviconData(faviconURI, data, "image/png");
   await setFaviconForPage(pageURI, faviconURI);
 
   Assert.equal(await getFaviconUrlForPage(pageURI, 20),
                faviconURI.spec, "Should get the non-root icon");
 });
 
 add_task(async function test_root_on_different_host() {
   async function getRootValue(url) {