Bug 1188818 - DataTransfer must deal with nsIFile of directories, r=jwatt
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 30 Mar 2016 17:58:41 +0100
changeset 291091 95a4888a3da12f8b487f48890bdc649ba1834e4f
parent 291090 00f8c8fde8ca0e3d2816cf3ddc3f6e26b5070c52
child 291092 5dbb8c2b35f4ea34d543a346f04e934e1a85686a
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1188818
milestone48.0a1
Bug 1188818 - DataTransfer must deal with nsIFile of directories, r=jwatt
dom/events/DataTransfer.cpp
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -315,23 +315,29 @@ DataTransfer::GetFileListInternal(ErrorR
 
       if (NS_FAILED(rv))
         continue;
 
       nsCOMPtr<nsIFile> file = do_QueryInterface(supports);
 
       RefPtr<File> domFile;
       if (file) {
-#ifdef DEBUG
-        if (XRE_GetProcessType() == GeckoProcessType_Default) {
-          bool isDir;
-          file->IsDirectory(&isDir);
-          MOZ_ASSERT(!isDir, "How did we get here?");
+        MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default,
+                   "nsIFile objects are not expected on the content process");
+
+        bool isDir;
+        aRv = file->IsDirectory(&isDir);
+        if (NS_WARN_IF(aRv.Failed())) {
+          return nullptr;
         }
-#endif
+
+        if (isDir) {
+          continue;
+        }
+
         domFile = File::CreateFromFile(GetParentObject(), file);
       } else {
         nsCOMPtr<BlobImpl> blobImpl = do_QueryInterface(supports);
         if (!blobImpl) {
           continue;
         }
 
         MOZ_ASSERT(blobImpl->IsFile());
@@ -915,17 +921,17 @@ already_AddRefed<nsISupportsArray>
 DataTransfer::GetTransferables(nsIDOMNode* aDragTarget)
 {
   MOZ_ASSERT(aDragTarget);
 
   nsCOMPtr<nsINode> dragNode = do_QueryInterface(aDragTarget);
   if (!dragNode) {
     return nullptr;
   }
-    
+
   nsIDocument* doc = dragNode->GetCurrentDoc();
   if (!doc) {
     return nullptr;
   }
 
   return GetTransferables(doc->GetLoadContext());
 }
 
@@ -1027,17 +1033,17 @@ DataTransfer::ConvertFromVariant(nsIVari
 
   uint16_t type;
   aVariant->GetDataType(&type);
   if (type == nsIDataType::VTYPE_INTERFACE ||
       type == nsIDataType::VTYPE_INTERFACE_IS) {
     nsCOMPtr<nsISupports> data;
     if (NS_FAILED(aVariant->GetAsISupports(getter_AddRefs(data))))
        return false;
- 
+
     nsCOMPtr<nsIFlavorDataProvider> fdp = do_QueryInterface(data);
     if (fdp) {
       // for flavour data providers, use kFlavorHasDataProvider (which has the
       // value 0) as the length.
       fdp.forget(aSupports);
       *aLength = nsITransferable::kFlavorHasDataProvider;
     }
     else {