Bug 1030844 - Get rid of nsIDOMWindowUtils.getFile/getBlob, r=janv
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 26 Jun 2014 23:05:25 -0700
changeset 204923 7123ff981fc79e88923f7a3c6c8c8b92654b9215
parent 204922 9d2d8726dff6ae5ad80af0f2991941a95c72d6bb
child 204924 c6b2136514f265399c05419fc1794f32e9561037
push id6561
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 21:23:20 +0000
treeherdermozilla-aurora@428d4d3c8588 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs1030844
milestone33.0a1
Bug 1030844 - Get rid of nsIDOMWindowUtils.getFile/getBlob, r=janv
dom/base/nsDOMWindowUtils.cpp
dom/contacts/tests/test_contacts_blobs.html
dom/filehandle/test/helpers.js
dom/filehandle/test/test_append_read_data.html
dom/filehandle/test/test_write_read_data.html
dom/indexedDB/test/file.js
dom/interfaces/base/nsIDOMWindowUtils.idl
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -2936,101 +2936,16 @@ nsDOMWindowUtils::AreDialogsEnabled(bool
 
   nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
 
   *aResult = static_cast<nsGlobalWindow*>(window.get())->AreDialogsEnabled();
   return NS_OK;
 }
 
-static nsIDOMBlob*
-GetXPConnectNative(JSContext* aCx, JSObject* aObj) {
-  nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(
-    nsContentUtils::XPConnect()->GetNativeOfWrapper(aCx, aObj));
-  return blob;
-}
-
-static nsresult
-GetFileOrBlob(const nsAString& aName, JS::Handle<JS::Value> aBlobParts,
-              JS::Handle<JS::Value> aParameters, JSContext* aCx,
-              uint8_t aOptionalArgCount, nsISupports** aResult)
-{
-  MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
-
-  nsresult rv;
-
-  nsCOMPtr<nsISupports> file;
-
-  if (aName.IsVoid()) {
-    rv = DOMMultipartFileImpl::NewBlob(getter_AddRefs(file));
-  }
-  else {
-    rv = DOMMultipartFileImpl::NewFile(aName, getter_AddRefs(file));
-  }
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(file);
-  MOZ_ASSERT(blob);
-
-  nsRefPtr<DOMFile> domFile = static_cast<DOMFile*>(blob.get());
-
-  DOMFileImpl* fileImpl = domFile->Impl();
-  MOZ_ASSERT(fileImpl);
-
-  DOMMultipartFileImpl* domFileImpl =
-    static_cast<DOMMultipartFileImpl*>(fileImpl);
-
-  JS::AutoValueArray<2> args(aCx);
-  args[0].set(aBlobParts);
-  args[1].set(aParameters);
-
-  rv = domFileImpl->InitBlob(aCx, aOptionalArgCount, args.begin(),
-                             GetXPConnectNative);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  file.forget(aResult);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::GetFile(const nsAString& aName, JS::Handle<JS::Value> aBlobParts,
-                          JS::Handle<JS::Value> aParameters, JSContext* aCx,
-                          uint8_t aOptionalArgCount, nsIDOMFile** aResult)
-{
-  MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
-
-  nsCOMPtr<nsISupports> file;
-  nsresult rv = GetFileOrBlob(aName, aBlobParts, aParameters, aCx,
-                              aOptionalArgCount, getter_AddRefs(file));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIDOMFile> result = do_QueryInterface(file);
-  result.forget(aResult);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMWindowUtils::GetBlob(JS::Handle<JS::Value> aBlobParts,
-                          JS::Handle<JS::Value> aParameters, JSContext* aCx,
-                          uint8_t aOptionalArgCount, nsIDOMBlob** aResult)
-{
-  MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
-
-  nsCOMPtr<nsISupports> blob;
-  nsresult rv = GetFileOrBlob(NullString(), aBlobParts, aParameters, aCx,
-                              aOptionalArgCount, getter_AddRefs(blob));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIDOMBlob> result = do_QueryInterface(blob);
-  result.forget(aResult);
-
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 nsDOMWindowUtils::GetFileId(JS::Handle<JS::Value> aFile, JSContext* aCx,
                             int64_t* aResult)
 {
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
 
   if (!aFile.isPrimitive()) {
     JSObject* obj = aFile.toObjectOrNull();
--- a/dom/contacts/tests/test_contacts_blobs.html
+++ b/dom/contacts/tests/test_contacts_blobs.html
@@ -35,24 +35,19 @@ function getRandomView(size)
 {
  var view = getView(size);
  for (var i = 0; i < size; i++) {
    view[i] = parseInt(Math.random() * 255)
  }
  return view;
 }
 
-function getBlob(type, view)
-{
-  return SpecialPowers.unwrap(utils.getBlob([view], {type: type}));
-}
-
 function getRandomBlob(size)
 {
-  return getBlob("binary/random", getRandomView(size));
+  return new Blob([getRandomView(size)], { type: "binary/random" });
 }
 
 function compareBuffers(buffer1, buffer2)
 {
   if (buffer1.byteLength != buffer2.byteLength) {
     return false;
   }
   var view1 = new Uint8Array(buffer1);
--- a/dom/filehandle/test/helpers.js
+++ b/dom/filehandle/test/helpers.js
@@ -189,22 +189,17 @@ function compareBuffers(buffer1, buffer2
   for (let i = 0; i < buffer1.byteLength; i++) {
     if (view1[i] != view2[i]) {
       return false;
     }
   }
   return true;
 }
 
-function getBlob(type, buffer)
-{
-  return SpecialPowers.unwrap(utils.getBlob([buffer], {type: type}));
-}
-
 function getRandomBlob(size)
 {
-  return getBlob("binary/random", getRandomBuffer(size));
+  return new Blob([getRandomBuffer(size)], { type: "binary/random" });
 }
 
 function getFileId(blob)
 {
   return SpecialPowers.unwrap(utils.getFileId(blob));
 }
--- a/dom/filehandle/test/test_append_read_data.html
+++ b/dom/filehandle/test/test_append_read_data.html
@@ -14,17 +14,17 @@
   {
     var testString = "Lorem ipsum his ponderum delicatissimi ne, at noster dolores urbanitas pro, cibo elaboraret no his. Ea dicunt maiorum usu. Ad appareat facilisis mediocritatem eos. Tale graeci mentitum in eos, hinc insolens at nam. Graecis nominavi aliquyam eu vix. Id solet assentior sadipscing pro. Et per atqui graecis, usu quot viris repudiandae ei, mollis evertitur an nam. At nam dolor ignota, liber labore omnesque ea mei, has movet voluptaria in. Vel an impetus omittantur. Vim movet option salutandi ex, ne mei ignota corrumpit. Mucius comprehensam id per. Est ea putant maiestatis.";
     for (let i = 0; i < 5; i++) {
       testString += testString;
     }
 
     var testBuffer = getRandomBuffer(100000);
 
-    var testBlob = getBlob("binary/random", testBuffer);
+    var testBlob = new Blob([testBuffer], {type: "binary/random"});
 
     for each (let fileStorage in fileStorages) {
       let request = getMutableFile(fileStorage.key, "test.txt");
       request.onerror = errorHandler;
       request.onsuccess = grabEventAndContinueHandler;
       let event = yield undefined;
 
       let mutableFile = event.target.result;
--- a/dom/filehandle/test/test_write_read_data.html
+++ b/dom/filehandle/test/test_write_read_data.html
@@ -14,17 +14,17 @@
   {
     var testString = "Lorem ipsum his ponderum delicatissimi ne, at noster dolores urbanitas pro, cibo elaboraret no his. Ea dicunt maiorum usu. Ad appareat facilisis mediocritatem eos. Tale graeci mentitum in eos, hinc insolens at nam. Graecis nominavi aliquyam eu vix. Id solet assentior sadipscing pro. Et per atqui graecis, usu quot viris repudiandae ei, mollis evertitur an nam. At nam dolor ignota, liber labore omnesque ea mei, has movet voluptaria in. Vel an impetus omittantur. Vim movet option salutandi ex, ne mei ignota corrumpit. Mucius comprehensam id per. Est ea putant maiestatis.";
     for (let i = 0; i < 5; i++) {
       testString += testString;
     }
 
     var testBuffer = getRandomBuffer(100000);
 
-    var testBlob = getBlob("binary/random", testBuffer);
+    var testBlob = new Blob([testBuffer], {type: "binary/random"});
 
     for each (let fileStorage in fileStorages) {
       let request = getMutableFile(fileStorage.key, "test.txt");
       request.onerror = errorHandler;
       request.onsuccess = grabEventAndContinueHandler;
       let event = yield undefined;
 
       let mutableFile = event.target.result;
--- a/dom/indexedDB/test/file.js
+++ b/dom/indexedDB/test/file.js
@@ -44,22 +44,22 @@ function compareBuffers(buffer1, buffer2
       return false;
     }
   }
   return true;
 }
 
 function getBlob(type, view)
 {
-  return SpecialPowers.unwrap(utils.getBlob([view], {type: type}));
+  return new Blob([view], {type: type});
 }
 
 function getFile(name, type, view)
 {
-  return SpecialPowers.unwrap(utils.getFile(name, [view], {type: type}));
+  return new File([view], name, {type: type});
 }
 
 function getRandomBlob(size)
 {
   return getBlob("binary/random", getRandomView(size));
 }
 
 function getRandomFile(name, size)
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -43,17 +43,17 @@ interface nsIDOMFile;
 interface nsIFile;
 interface nsIDOMClientRect;
 interface nsIURI;
 interface nsIDOMEventTarget;
 interface nsIRunnable;
 interface nsICompositionStringSynthesizer;
 interface nsITranslationNodeList;
 
-[scriptable, uuid(75b7674b-3e6e-4fac-931b-8fd3c4e4e8d2)]
+[scriptable, uuid(6f10cbf8-bd4e-4c56-8a5a-35641efcf286)]
 interface nsIDOMWindowUtils : nsISupports {
 
   /**
    * Image animation mode of the window. When this attribute's value
    * is changed, the implementation should set all images in the window
    * to the given value. That is, when set to kDontAnimMode, all images
    * will stop animating. The attribute's value must be one of the
    * animationMode values from imgIContainer.
@@ -1434,34 +1434,16 @@ interface nsIDOMWindowUtils : nsISupport
  
   /**
    * Check if any ThebesLayer painting has been done for this element,
    * clears the painted flags if they have.
    */
   boolean checkAndClearPaintedState(in nsIDOMElement aElement);
 
   /**
-   * Internal file constructor intended for testing of File objects.
-   * Example of constructor usage:
-   *   getFile("myfile.txt", [b1, "foo"], { type: "text/plain" })
-   */
-  [optional_argc, implicit_jscontext]
-  nsIDOMFile getFile(in DOMString aName, [optional] in jsval aBlobParts,
-                     [optional] in jsval aParameters);
-
-  /**
-   * Internal blob constructor intended for testing of Blob objects.
-   * Example of constructor usage:
-   *   getBlob([b1, "foo"], { type: "text/plain" })
-   */
-  [optional_argc, implicit_jscontext]
-  nsIDOMBlob getBlob([optional] in jsval aBlobParts,
-                     [optional] in jsval aParameters);
-
-  /**
    * Get internal id of the stored blob, file or file handle.
    */
   [implicit_jscontext] long long getFileId(in jsval aFile);
 
   /**
    * Get file ref count info for given database and file id.
    *
    */