Backed out changeset b5e8cd00d7ef (bug 1238515) for Android Test failures

This commit is contained in:
Carsten "Tomcat" Book 2016-01-12 14:15:08 +01:00
parent b1f61c3157
commit f7a100b46e
11 changed files with 49 additions and 55 deletions

View File

@ -71,12 +71,11 @@ FilePicker.prototype = {
/* readonly attribute nsISimpleEnumerator files - not implemented; */
/* readonly attribute nsIURI fileURL - not implemented; */
get domFileOrDirectoryEnumerator() {
get domfiles() {
return this.mFilesEnumerator;
},
// We don't support directory selection yet.
get domFileOrDirectory() {
get domfile() {
return this.mFilesEnumerator ? this.mFilesEnumerator.mFiles[0] : null;
},

View File

@ -386,8 +386,7 @@ HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult)
nsTArray<RefPtr<File>> newFiles;
if (mode == static_cast<int16_t>(nsIFilePicker::modeOpenMultiple)) {
nsCOMPtr<nsISimpleEnumerator> iter;
nsresult rv =
mFilePicker->GetDomFileOrDirectoryEnumerator(getter_AddRefs(iter));
nsresult rv = mFilePicker->GetDomfiles(getter_AddRefs(iter));
NS_ENSURE_SUCCESS(rv, rv);
if (!iter) {
@ -410,7 +409,7 @@ HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult)
MOZ_ASSERT(mode == static_cast<int16_t>(nsIFilePicker::modeOpen) ||
mode == static_cast<int16_t>(nsIFilePicker::modeGetFolder));
nsCOMPtr<nsISupports> tmp;
nsresult rv = mFilePicker->GetDomFileOrDirectory(getter_AddRefs(tmp));
nsresult rv = mFilePicker->GetDomfile(getter_AddRefs(tmp));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(tmp);

View File

@ -140,8 +140,7 @@ FilePicker.prototype = {
});
},
// We don't support directory selection yet.
get domFileOrDirectory() {
get domfile() {
let f = this.file;
if (!f) {
return null;
@ -156,7 +155,7 @@ FilePicker.prototype = {
return new File(f);
},
get domFileOrDirectoryEnumerator() {
get domfiles() {
let win = this._domWin;
return this.getEnumerator([this.file], function(file) {
if (win) {

View File

@ -31,15 +31,14 @@ add_test(function filepicker_open() {
is(file.path, "/mnt/sdcard/my-favorite-martian.png", "Retrieve the right martian file from array!");
}
let file = fp.domFileOrDirectory;
do_print("DOMFile: " + file.mozFullPath);
is(file.mozFullPath, "/mnt/sdcard/my-favorite-martian.png", "Retrieve the right martian DOM File!");
do_print("DOMFile: " + fp.domfile.mozFullPath);
is(fp.domfile.mozFullPath, "/mnt/sdcard/my-favorite-martian.png", "Retrieve the right martian domfile!");
let enum = fp.domFileOrDirectoryEnumerator;
while (enum.hasMoreElements()) {
let file = enum.getNext();
do_print("DOMFile: " + file.mozFullPath);
is(file.mozFullPath, "/mnt/sdcard/my-favorite-martian.png", "Retrieve the right martian file from domFileOrDirectoryEnumerator array!");
let domfiles = fp.domfiles;
while (domfiles.hasMoreElements()) {
let domfile = domfiles.getNext();
do_print("DOMFile: " + domfile.mozFullPath);
is(domfile.mozFullPath, "/mnt/sdcard/my-favorite-martian.png", "Retrieve the right martian file from domfile array!");
}
do_test_finished();

View File

@ -146,9 +146,7 @@ MockFilePickerInstance.prototype = {
return null;
},
// We don't support directories here.
get domFileOrDirectory() {
get domfile() {
if (MockFilePicker.returnFiles.length >= 1) {
// window.File does not implement nsIFile
if (!MockFilePicker.isNsIFile(MockFilePicker.returnFiles[0])) {
@ -186,7 +184,7 @@ MockFilePickerInstance.prototype = {
}
};
},
get domFileOrDirectoryEnumerator() {
get domfiles() {
let utils = this.parent.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
return {

View File

@ -93,14 +93,14 @@ nsFilePicker.prototype = {
/* readonly attribute nsISimpleEnumerator files; */
get files() { return this.mFilesEnumerator; },
/* we don't support directories, yet */
get domFileOrDirectory() {
let enumerator = this.domFileOrDirectoryEnumerator;
/* readonly attribute DOM File domfile; */
get domfile() {
let enumerator = this.domfiles;
return enumerator ? enumerator.mFiles[0] : null;
},
/* readonly attribute nsISimpleEnumerator domFileOrDirectoryEnumerator; */
get domFileOrDirectoryEnumerator() {
/* readonly attribute nsISimpleEnumerator domfiles; */
get domfiles() {
if (!this.mFilesEnumerator) {
return null;
}

View File

@ -337,25 +337,25 @@ nsBaseFilePicker::GetMode(int16_t* aMode)
}
NS_IMETHODIMP
nsBaseFilePicker::GetDomFileOrDirectory(nsISupports** aValue)
nsBaseFilePicker::GetDomfile(nsISupports** aDomfile)
{
nsCOMPtr<nsIFile> localFile;
nsresult rv = GetFile(getter_AddRefs(localFile));
NS_ENSURE_SUCCESS(rv, rv);
if (!localFile) {
*aValue = nullptr;
*aDomfile = nullptr;
return NS_OK;
}
RefPtr<File> domFile = File::CreateFromFile(mParent, localFile);
domFile->Impl()->SetIsDirectory(mMode == nsIFilePicker::modeGetFolder);
nsCOMPtr<nsIDOMBlob>(domFile).forget(aValue);
nsCOMPtr<nsIDOMBlob>(domFile).forget(aDomfile);
return NS_OK;
}
NS_IMETHODIMP
nsBaseFilePicker::GetDomFileOrDirectoryEnumerator(nsISimpleEnumerator** aValue)
nsBaseFilePicker::GetDomfiles(nsISimpleEnumerator** aDomfiles)
{
nsCOMPtr<nsISimpleEnumerator> iter;
nsresult rv = GetFiles(getter_AddRefs(iter));
@ -364,7 +364,7 @@ nsBaseFilePicker::GetDomFileOrDirectoryEnumerator(nsISimpleEnumerator** aValue)
RefPtr<nsBaseFilePickerEnumerator> retIter =
new nsBaseFilePickerEnumerator(mParent, iter, mMode);
retIter.forget(aValue);
retIter.forget(aDomfiles);
return NS_OK;
}

View File

@ -37,8 +37,8 @@ public:
NS_IMETHOD SetAddToRecentDocs(bool aFlag);
NS_IMETHOD GetMode(int16_t *aMode);
NS_IMETHOD GetDomFileOrDirectory(nsISupports** aValue);
NS_IMETHOD GetDomFileOrDirectoryEnumerator(nsISimpleEnumerator** aValue);
NS_IMETHOD GetDomfile(nsISupports** aDomfile);
NS_IMETHOD GetDomfiles(nsISimpleEnumerator** aDomfiles);
protected:

View File

@ -102,21 +102,21 @@ nsFilePickerProxy::SetFilterIndex(int32_t aFilterIndex)
NS_IMETHODIMP
nsFilePickerProxy::GetFile(nsIFile** aFile)
{
MOZ_ASSERT(false, "GetFile is unimplemented; use GetDomFileOrDirectory");
MOZ_ASSERT(false, "GetFile is unimplemented; use GetDomfile");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsFilePickerProxy::GetFileURL(nsIURI** aFileURL)
{
MOZ_ASSERT(false, "GetFileURL is unimplemented; use GetDomFileOrDirectory");
MOZ_ASSERT(false, "GetFileURL is unimplemented; use GetDomfile");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsFilePickerProxy::GetFiles(nsISimpleEnumerator** aFiles)
{
MOZ_ASSERT(false, "GetFiles is unimplemented; use GetDomFileOrDirectoryEnumerator");
MOZ_ASSERT(false, "GetFiles is unimplemented; use GetDomfiles");
return NS_ERROR_FAILURE;
}
@ -161,7 +161,7 @@ nsFilePickerProxy::Recv__delete__(const MaybeInputFiles& aFiles,
RefPtr<File> file = File::Create(mParent, blobImpl);
MOZ_ASSERT(file);
mFilesOrDirectories.AppendElement(file);
mDomfiles.AppendElement(file);
}
}
@ -174,16 +174,16 @@ nsFilePickerProxy::Recv__delete__(const MaybeInputFiles& aFiles,
}
NS_IMETHODIMP
nsFilePickerProxy::GetDomFileOrDirectory(nsISupports** aValue)
nsFilePickerProxy::GetDomfile(nsISupports** aDomfile)
{
*aValue = nullptr;
if (mFilesOrDirectories.IsEmpty()) {
*aDomfile = nullptr;
if (mDomfiles.IsEmpty()) {
return NS_OK;
}
MOZ_ASSERT(mFilesOrDirectories.Length() == 1);
nsCOMPtr<nsIDOMBlob> blob = mFilesOrDirectories[0].get();
blob.forget(aValue);
MOZ_ASSERT(mDomfiles.Length() == 1);
nsCOMPtr<nsIDOMBlob> blob = mDomfiles[0].get();
blob.forget(aDomfile);
return NS_OK;
}
@ -230,9 +230,9 @@ NS_IMPL_ISUPPORTS(SimpleEnumerator, nsISimpleEnumerator)
} // namespace
NS_IMETHODIMP
nsFilePickerProxy::GetDomFileOrDirectoryEnumerator(nsISimpleEnumerator** aDomfiles)
nsFilePickerProxy::GetDomfiles(nsISimpleEnumerator** aDomfiles)
{
RefPtr<SimpleEnumerator> enumerator = new SimpleEnumerator(mFilesOrDirectories);
RefPtr<SimpleEnumerator> enumerator = new SimpleEnumerator(mDomfiles);
enumerator.forget(aDomfiles);
return NS_OK;
}

View File

@ -51,8 +51,8 @@ public:
NS_IMETHODIMP GetFileURL(nsIURI** aFileURL) override;
NS_IMETHODIMP GetFiles(nsISimpleEnumerator** aFiles) override;
NS_IMETHODIMP GetDomFileOrDirectory(nsISupports** aValue) override;
NS_IMETHODIMP GetDomFileOrDirectoryEnumerator(nsISimpleEnumerator** aValue) override;
NS_IMETHODIMP GetDomfile(nsISupports** aFile) override;
NS_IMETHODIMP GetDomfiles(nsISimpleEnumerator** aFiles) override;
NS_IMETHODIMP Show(int16_t* aReturn) override;
NS_IMETHODIMP Open(nsIFilePickerShownCallback* aCallback) override;
@ -65,7 +65,7 @@ private:
~nsFilePickerProxy();
void InitNative(nsIWidget*, const nsAString&) override;
nsTArray<RefPtr<mozilla::dom::File>> mFilesOrDirectories;
nsTArray<RefPtr<mozilla::dom::File>> mDomfiles;
nsCOMPtr<nsIFilePickerShownCallback> mCallback;
int16_t mSelectedType;

View File

@ -23,7 +23,7 @@ interface nsIFilePickerShownCallback : nsISupports
void done(in short aResult);
};
[scriptable, uuid(2a74ba0d-ffdd-4dad-b78a-98635e525a38)]
[scriptable, uuid(9840d564-42c8-4d78-9a4d-71002343c918)]
interface nsIFilePicker : nsISupports
{
const short modeOpen = 0; // Load a file or directory
@ -142,19 +142,19 @@ interface nsIFilePicker : nsISupports
readonly attribute nsISimpleEnumerator files;
/**
* Get the DOM File or the DOM Directory
* Get the DOM File for the file.
*
* @return Returns the file or directory currently selected DOM object.
* @return Returns the file currently selected as File
*/
readonly attribute nsISupports domFileOrDirectory;
readonly attribute nsISupports domfile;
/**
* Get the enumerator for the selected files or directories
* Get the enumerator for the selected files
* only works in the modeOpenMultiple mode
*
* @return Returns the files/directories currently selected as DOM object.
* @return Returns the files currently selected as Files
*/
readonly attribute nsISimpleEnumerator domFileOrDirectoryEnumerator;
readonly attribute nsISimpleEnumerator domfiles;
/**
* Controls whether the chosen file(s) should be added to the system's recent