Bug 1190036 - clipboardData.getFilesAndDirectories() should throw an exception when returning null, r=smaug

This commit is contained in:
Andrea Marchesini 2015-08-25 08:22:57 +01:00
parent 82e69d82b8
commit c674fbd6a7
3 changed files with 24 additions and 2 deletions

View File

@ -850,12 +850,14 @@ 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;
}
@ -865,9 +867,13 @@ DataTransfer::GetFilesAndDirectories(ErrorResult& aRv)
}
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;
}
}

View File

@ -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>

View File

@ -9,6 +9,7 @@ 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