Bug 1190036 - ClipboardData.getFilesAndDirectories() should throw an exception when returning null. r=smaug, a=ritu
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 25 Aug 2015 08:22:57 +0100
changeset 288930 c47645f91f51afbfc50416a08ba625c5d4b4cf54
parent 288929 9ca02c1d8027122bfd29927f4b51636b8ad875e8
child 288931 119f61ff79afdd6735ca4d05f48383f03c72ac20
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, ritu
bugs1190036
milestone42.0a2
Bug 1190036 - ClipboardData.getFilesAndDirectories() should throw an exception when returning null. r=smaug, a=ritu
dom/events/DataTransfer.cpp
dom/events/crashtests/1190036-1.html
dom/events/crashtests/crashtests.list
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -845,34 +845,40 @@ MakeOrReuseFileSystem(const nsAString& a
   return fs.forget();
 }
 
 already_AddRefed<Promise>
 DataTransfer::GetFilesAndDirectories(ErrorResult& aRv)
 {
   nsCOMPtr<nsINode> parentNode = do_QueryInterface(mParent);
   if (!parentNode) {
+    aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsCOMPtr<nsIGlobalObject> global = parentNode->OwnerDoc()->GetScopeObject();
   MOZ_ASSERT(global);
   if (!global) {
+    aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   nsRefPtr<Promise> p = Promise::Create(global, aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   if (!mFiles) {
-    ErrorResult dummy;
-    GetFiles(dummy);
+    GetFiles(aRv);
+    if (NS_WARN_IF(aRv.Failed())) {
+      return nullptr;
+    }
+
     if (!mFiles) {
+      aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
   }
 
   Sequence<OwningFileOrDirectory> filesAndDirsSeq;
 
   if (!filesAndDirsSeq.SetLength(mFiles->Length(), mozilla::fallible_t())) {
     p->MaybeReject(NS_ERROR_OUT_OF_MEMORY);
new file mode 100644
--- /dev/null
+++ b/dom/events/crashtests/1190036-1.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="UTF-8">
+<script>
+
+function boom() {
+    var ev = new ClipboardEvent("p");
+    ev.clipboardData.getFilesAndDirectories();
+}
+
+</script>
+</head>
+<body onload="boom();"></body>
+</html>
--- a/dom/events/crashtests/crashtests.list
+++ b/dom/events/crashtests/crashtests.list
@@ -4,13 +4,14 @@ load 135345-1.html
 load 422009-1.xhtml
 load 457776-1.html
 load 496308-1.html
 load 682637-1.html
 load 1033343.html
 load 1035654-1.html
 load 1035654-2.html
 load 1143972-1.html
+load 1190036-1.html
 needs-focus load 1072137-1.html
 load eventctor-nulldictionary.html
 load eventctor-nullstorage.html
 load recursive-onload.html
 load recursive-DOMNodeInserted.html