Bug 1146116 - Clone File objects passed to mozSetFileArray into receiver's global. r=sicking

This commit is contained in:
Jed Davis
2015-03-27 08:41:00 -04:00
parent 3ae7ebad35
commit ae0905fc86
4 changed files with 93 additions and 1 deletions

View File

@@ -2339,9 +2339,14 @@ HTMLInputElement::MozGetFileNameArray(uint32_t* aLength, char16_t*** aFileNames)
void
HTMLInputElement::MozSetFileArray(const Sequence<OwningNonNull<File>>& aFiles)
{
nsCOMPtr<nsIGlobalObject> global = OwnerDoc()->GetScopeObject();
MOZ_ASSERT(global);
if (!global) {
return;
}
nsTArray<nsRefPtr<File>> files;
for (uint32_t i = 0; i < aFiles.Length(); ++i) {
files.AppendElement(aFiles[i]);
files.AppendElement(new File(global, aFiles[i].get()->Impl()));
}
SetFiles(files, true);
}