author | Edgar Chen <echen@mozilla.com> |
Mon, 04 Apr 2022 09:54:34 +0000 (2022-04-04) | |
changeset 613248 | fa7449627f17464200539c186fcf26c8ee90c285 |
parent 613247 | d7d9ec18156b401807815e7d0204f1b41818ff8b |
child 613249 | b51315e2bba420ef93799386cb0cbc35bb9c3243 |
push id | 39518 |
push user | nbeleuzu@mozilla.com |
push date | Mon, 04 Apr 2022 21:49:47 +0000 (2022-04-04) |
treeherder | mozilla-central@0bc4b1a0adff [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smaug |
bugs | 1760560 |
milestone | 100.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/test/common_postMessages.js +++ b/dom/base/test/common_postMessages.js @@ -1,12 +1,8 @@ -function setup_tests() { - SpecialPowers.pushPrefEnv({ set: [["dom.input.dirpicker", true]] }, next); -} - function getType(a) { if (a === null || a === undefined) { return "null"; } if (Array.isArray(a)) { return "array"; } @@ -121,25 +117,28 @@ function create_directory() { var url = SimpleTest.getTestFileURL("script_postmessages_fileList.js"); var script = SpecialPowers.loadChromeScript(url); function onOpened(message) { var fileList = document.getElementById("fileList"); SpecialPowers.wrap(fileList).mozSetDirectory(message.dir); - fileList.getFilesAndDirectories().then(function(list) { - // Just a simple test - is(list.length, 1, "This list has 1 element"); - ok(list[0] instanceof Directory, "We have a directory."); + SpecialPowers.wrap(fileList) + .getFilesAndDirectories() + .then(function(list) { + list = SpecialPowers.unwrap(list); + // Just a simple test + is(list.length, 1, "This list has 1 element"); + ok(list[0] instanceof Directory, "We have a directory."); - clonableObjects.push({ target: "all", data: list[0] }); - script.destroy(); - next(); - }); + clonableObjects.push({ target: "all", data: list[0] }); + script.destroy(); + next(); + }); } script.addMessageListener("dir.opened", onOpened); script.sendAsyncMessage("dir.open"); } function create_wasmModule() { info("Checking if we can play with WebAssembly..."); @@ -386,9 +385,9 @@ function next() { SimpleTest.finish(); return; } var test = tests.shift(); test(); } -var tests = [setup_tests, create_fileList, create_directory, create_wasmModule]; +var tests = [create_fileList, create_directory, create_wasmModule];
--- a/dom/events/DataTransfer.cpp +++ b/dom/events/DataTransfer.cpp @@ -799,58 +799,16 @@ void DataTransfer::UpdateDragImage(Eleme } nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession(); if (dragSession) { dragSession->UpdateDragImage(&aImage, aX, aY); } } -already_AddRefed<Promise> DataTransfer::GetFilesAndDirectories( - nsIPrincipal& aSubjectPrincipal, 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; - } - - RefPtr<Promise> p = Promise::Create(global, aRv); - if (NS_WARN_IF(aRv.Failed())) { - return nullptr; - } - - RefPtr<FileList> files = mItems->Files(&aSubjectPrincipal); - if (NS_WARN_IF(!files)) { - return nullptr; - } - - Sequence<RefPtr<File>> filesSeq; - files->ToSequence(filesSeq, aRv); - if (NS_WARN_IF(aRv.Failed())) { - return nullptr; - } - - p->MaybeResolve(filesSeq); - - return p.forget(); -} - -already_AddRefed<Promise> DataTransfer::GetFiles( - bool aRecursiveFlag, nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) { - // Currently we don't support directories. - return GetFilesAndDirectories(aSubjectPrincipal, aRv); -} - void DataTransfer::AddElement(Element& aElement, ErrorResult& aRv) { if (IsReadOnly()) { aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR); return; } mDragTarget = &aElement; }
--- a/dom/events/DataTransfer.h +++ b/dom/events/DataTransfer.h @@ -217,23 +217,16 @@ class DataTransfer final : public nsISup /** * Holds a list of all the local files available on this data transfer. * A dataTransfer containing no files will return an empty list, and an * invalid index access on the resulting file list will return null. */ already_AddRefed<FileList> GetFiles(nsIPrincipal& aSubjectPrincipal); - already_AddRefed<Promise> GetFilesAndDirectories( - nsIPrincipal& aSubjectPrincipal, mozilla::ErrorResult& aRv); - - already_AddRefed<Promise> GetFiles(bool aRecursiveFlag, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aRv); - void AddElement(Element& aElement, mozilla::ErrorResult& aRv); uint32_t MozItemCount() const; void GetMozCursor(nsAString& aCursor) { if (mCursorState) { aCursor.AssignLiteral("default"); } else {
--- a/dom/filesystem/compat/tests/test_formSubmission.html +++ b/dom/filesystem/compat/tests/test_formSubmission.html @@ -25,18 +25,17 @@ function setup_tests() { form = document.getElementById("form"); iframe = document.getElementById("target_iframe"); iframe.onload = function() { info("Frame loaded!"); next(); }; - SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true], - ["dom.webkitBlink.dirPicker.enabled", true], + SpecialPowers.pushPrefEnv({"set": [["dom.webkitBlink.dirPicker.enabled", true], ["dom.filesystem.pathcheck.disabled", true], ["dom.webkitBlink.filesystem.enabled", true]]}, next); } function populate_entries(webkitDirectory) { var url = SimpleTest.getTestFileURL("script_entries.js"); script = SpecialPowers.loadChromeScript(url); @@ -81,23 +80,22 @@ function setup_plain() { form.method = "POST"; form.enctype = "text/plain"; form.submit(); } function test_plain() { var content = iframe.contentDocument.documentElement.textContent; var submission = JSON.parse(content); - input.getFilesAndDirectories().then(function(array) { - is(submission, array.map(function(v) { - return "input=" + v.name + "\r\n"; - }).join(""), "Data match"); + info(submission); + is(submission, input.webkitEntries.map(function(v) { + return "input=" + v.name + "\r\n"; + }).join(""), "Data match"); - next(); - }); + next(); } function setup_urlencoded() { info("Preparing for a urlencoded submission..."); form.action = "../../../html/test/form_submit_server.sjs?url"; form.method = "POST"; form.enctype = "application/x-www-form-urlencoded"; form.submit(); @@ -117,111 +115,106 @@ function setup_urlencoded_empty() { form.method = ""; form.enctype = ""; form.submit(); } function test_urlencoded() { var content = iframe.contentDocument.documentElement.textContent; var submission = JSON.parse(content); - input.getFilesAndDirectories().then(function(array) { - is(submission, array.map(function(v) { - return "input=" + v.name; - }).join("&"), "Data match"); + info(submission); + is(submission, input.webkitEntries.map(function(v) { + return "input=" + v.name; + }).join("&"), "Data match"); - next(); - }); + next(); } function setup_formData() { info("Preparing for a fromData submission..."); xhr = new XMLHttpRequest(); xhr.onload = next; xhr.open("POST", "../../../html/test/form_submit_server.sjs"); xhr.send(new FormData(form)); } function test_multipart() { var submission = JSON.parse(xhr.responseText); - input.getFilesAndDirectories().then(function(array) { - is(submission.length, array.length, "Same length"); + + var array = input.webkitEntries; + is(submission.length, array.length, "Same length"); + info(submission); - for (var i = 0; i < array.length; ++i) { - if (array[i] instanceof Directory) { - is(submission[i].headers["Content-Disposition"], - "form-data; name=\"input\"; filename=\"/" + array[i].name + "\"", - "Correct Content-Disposition"); - is(submission[i].headers["Content-Type"], "application/octet-stream", - "Correct Content-Type"); - is(submission[i].body, "", "Correct body"); - } else { - ok(array[i] instanceof File); - is(submission[i].headers["Content-Disposition"], - "form-data; name=\"input\"; filename=\"" + array[i].name + "\"", - "Correct Content-Disposition"); - is(submission[i].headers["Content-Type"], array[i].type, - "Correct Content-Type"); - is(submission[i].body, "", "Correct body"); - } + for (var i = 0; i < array.length; ++i) { + if (array[i].isDirectory) { + is(submission[i].headers["Content-Disposition"], + "form-data; name=\"input\"; filename=\"/" + array[i].name + "\"", + "Correct Content-Disposition"); + is(submission[i].headers["Content-Type"], "application/octet-stream", + "Correct Content-Type"); + is(submission[i].body, "", "Correct body"); + } else { + ok(array[i].isFile); + is(submission[i].headers["Content-Disposition"], + "form-data; name=\"input\"; filename=\"" + array[i].name + "\"", + "Correct Content-Disposition"); + is(submission[i].headers["Content-Type"], array[i].type, + "Correct Content-Type"); + is(submission[i].body, "", "Correct body"); } - next(); - }); + } + + next(); +} + +function getInputFiles(inputElement) { + var array = []; + for (var i = 0; i < inputElement.files.length; ++i) { + array.push(inputElement.files[i]); + } + return array; } function test_webkit_plain() { var content = iframe.contentDocument.documentElement.textContent; var submission = JSON.parse(content); - input.getFiles(true).then(function(array) { - is(submission, array.map(function(v) { - return "input=" + v.name + "\r\n"; - }).join(""), "Data match"); + is(submission, getInputFiles(input).map(function(v) { + return "input=" + v.name + "\r\n"; + }).join(""), "Data match"); - next(); - }); + next(); } function test_webkit_urlencoded() { var content = iframe.contentDocument.documentElement.textContent; var submission = JSON.parse(content); - input.getFiles(true).then(function(array) { - is(submission, array.map(function(v) { - return "input=" + v.name; - }).join("&"), "Data match"); + is(submission, getInputFiles(input).map(function(v) { + return "input=" + v.name; + }).join("&"), "Data match"); - next(); - }); + next(); } function test_webkit_multipart() { var submission = JSON.parse(xhr.responseText); - input.getFiles(true).then(function(array) { - is(submission.length, array.length, "Same length"); + var array = getInputFiles(input); + is(submission.length, array.length, "Same length"); - for (var i = 0; i < array.length; ++i) { - if (array[i] instanceof Directory) { - is(submission[i].headers["Content-Disposition"], - "form-data; name=\"input\"; filename=\"/" + array[i].name + "\"", - "Correct Content-Disposition"); - is(submission[i].headers["Content-Type"], "application/octet-stream", - "Correct Content-Type"); - is(submission[i].body, "", "Correct body"); - } else { - ok(array[i] instanceof File); - is(submission[i].headers["Content-Disposition"], - "form-data; name=\"input\"; filename=\"" + array[i].webkitRelativePath + "\"", - "Correct Content-Disposition"); - is(submission[i].headers["Content-Type"], array[i].type, - "Correct Content-Type"); - is(submission[i].body, "", "Correct body"); - } - } - next(); - }); + for (var i = 0; i < array.length; ++i) { + ok(array[i] instanceof File); + is(submission[i].headers["Content-Disposition"], + "form-data; name=\"input\"; filename=\"" + array[i].webkitRelativePath + "\"", + "Correct Content-Disposition"); + is(submission[i].headers["Content-Type"], array[i].type, + "Correct Content-Type"); + is(submission[i].body, "", "Correct body"); + } + next(); } var tests = [ setup_tests, function() { populate_entries(false); }, setup_plain,
--- a/dom/filesystem/tests/filesystem_commons.js +++ b/dom/filesystem/tests/filesystem_commons.js @@ -8,17 +8,16 @@ function createRelativePath(parentDir, d return path.substring(1); } function setup_tests(aNext) { SimpleTest.requestLongerTimeout(2); SpecialPowers.pushPrefEnv( { set: [ - ["dom.input.dirpicker", true], ["dom.filesystem.pathcheck.disabled", true], ["dom.webkitBlink.dirPicker.enabled", true], ], }, aNext ); }
--- a/dom/filesystem/tests/test_basic.html +++ b/dom/filesystem/tests/test_basic.html @@ -20,17 +20,18 @@ function create_fileList(aPath) { var url = SimpleTest.getTestFileURL("script_fileList.js"); var script = SpecialPowers.loadChromeScript(url); function onOpened(message) { SpecialPowers.wrap(fileList).mozSetDirectory(message.dir); fileList.setAttribute("data-name", message.name); - fileList.getFilesAndDirectories().then(function(array) { + SpecialPowers.wrap(fileList).getFilesAndDirectories().then(function(array) { + array = SpecialPowers.unwrap(array); is(array.length, 1, "We want just 1 directory."); ok(array[0] instanceof Directory, "We want just 1 directory."); directory = array[0]; script.destroy(); next(); }); } @@ -61,78 +62,29 @@ function test_simpleFilePicker(aPath) { function test_duplicateGetFilesAndDirectories() { var url = SimpleTest.getTestFileURL("script_fileList.js"); var script = SpecialPowers.loadChromeScript(url); function onOpened(message) { SpecialPowers.wrap(fileList).mozSetDirectory(message.dir); - var p1 = fileList.getFilesAndDirectories(); - var p2 = fileList.getFilesAndDirectories(); + var p1 = SpecialPowers.wrap(fileList).getFilesAndDirectories(); + var p2 = SpecialPowers.wrap(fileList).getFilesAndDirectories(); isnot(p1, p2, "We create 2 different promises"); script.destroy(); next(); } script.addMessageListener("dir.opened", onOpened); script.sendAsyncMessage("dir.open", { path: "test" }); } -function test_inputGetFiles() { - var url = SimpleTest.getTestFileURL("script_fileList.js"); - var script = SpecialPowers.loadChromeScript(url); - - function onOpened(message) { - SpecialPowers.wrap(fileList).mozSetDirectory(message.dir); - fileList.setAttribute("data-name", message.name); - - fileList.getFilesAndDirectories() - .then(function(result) { - is(result.length, 1, "getFilesAndDirectories should return 1 element"); - ok(result[0] instanceof Directory, "getFilesAndDirectories should return 1 directory"); - - return fileList.getFiles(false); - }) - .then(function(result) { - is(result.length, 1, "getFiles should return 1 element"); - ok(result[0] instanceof File, "getFile should return 1 file"); - is(result[0].name, "foo.txt", "getFiles()[0].name should be 'foo.txt'"); - is(result[0].webkitRelativePath, fileList.dataset.name + "/foo.txt", "getFiles()[0].webkitRelativePath should be '/foo.txt'"); - - return fileList.getFiles(true); - }) - .then(function(result) { - is(result.length, 2, "getFiles should return 2 elements"); - - function checkFile(file) { - ok(file instanceof File, "getFile[x] should return a file"); - if (file.name == "foo.txt") { - is(file.webkitRelativePath, fileList.dataset.name + "/foo.txt", "getFiles()[x].webkitRelativePath should be '/foo.txt'"); - } else { - is(file.name, "bar.txt", "getFiles()[x].name should be 'bar.txt'"); - is(file.webkitRelativePath, fileList.dataset.name + "/subdir/bar.txt", "getFiles()[x].webkitRelativePath should be '/subdir/bar.txt'"); - } - } - - checkFile(result[0]); - checkFile(result[1]); - }) - .then(function() { - script.destroy(); - next(); - }); - } - - script.addMessageListener("dir.opened", onOpened); - script.sendAsyncMessage("dir.open", { path: "test" }); -} - var tests = [ function() { setup_tests(next); }, function() { create_fileList("tree"); }, function() { test_basic(directory, next); }, function() { test_getFilesAndDirectories(directory, true, next); }, function() { test_getFiles(directory, false, next); }, function() { test_getFiles(directory, true, next); }, @@ -141,17 +93,16 @@ var tests = [ function() { test_getFiles_recursiveComparison(directory, next); }, function() { create_fileList("root"); }, function() { test_basic(directory, next); }, function() { test_getFilesAndDirectories(directory, false, next); }, function() { test_getFiles(directory, false, next); }, test_duplicateGetFilesAndDirectories, - test_inputGetFiles, test_simpleFilePicker, ]; function next() { if (!tests.length) { SimpleTest.finish(); return; }
--- a/dom/filesystem/tests/test_bug1319088.html +++ b/dom/filesystem/tests/test_bug1319088.html @@ -7,18 +7,17 @@ </head> <body> <input id="input" type="file"></input> <script type="application/javascript"> function testSetup() { - SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true], - ["dom.webkitBlink.dirPicker.enabled", true]]}, next); + SpecialPowers.pushPrefEnv({"set": [["dom.webkitBlink.dirPicker.enabled", true]]}, next); } function populateInputFile() { var url = SimpleTest.getTestFileURL("script_fileList.js"); var script = SpecialPowers.loadChromeScript(url); function onOpened(message) { var input = document.getElementById("input");
--- a/dom/filesystem/tests/test_webkitdirectory.html +++ b/dom/filesystem/tests/test_webkitdirectory.html @@ -3,18 +3,16 @@ <head> <title>Test for webkitdirectory and webkitRelativePath</title> <script src="/tests/SimpleTest/SimpleTest.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> </head> <body> <input id="inputFileWebkitDirectory" type="file" webkitdirectory></input> -<input id="inputFileWebkitDirectoryAndDirectory" type="file" webkitdirectory allowdirs></input> -<input id="inputFileDirectory" type="file" allowdirs></input> <input id="inputFileDirectoryChange" type="file" webkitdirectory></input> <script type="application/javascript"> const { AppConstants } = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {}); let promptHandler; @@ -173,18 +171,17 @@ function test_changeDataWhileWorking() { async function test_setup() { let promptHandlerUrl = SimpleTest.getTestFileURL("script_promptHandler.js") promptHandler = SpecialPowers.loadChromeScript(promptHandlerUrl); let promptHandlerReady = new Promise(resolve => promptHandler.addMessageListener("initDone", resolve)); promptHandler.sendAsyncMessage("init"); await promptHandlerReady; - SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true], - ["dom.filesystem.pathcheck.disabled", true], + SpecialPowers.pushPrefEnv({"set": [["dom.filesystem.pathcheck.disabled", true], ["dom.webkitBlink.dirPicker.enabled", true]]}, next); } async function test_cleanup() { let promptHandlerDone = new Promise(resolve => promptHandler.addMessageListener("cleanupDone", resolve)); promptHandler.sendAsyncMessage("cleanup"); await promptHandlerDone; promptHandler.destroy(); @@ -192,22 +189,18 @@ async function test_cleanup() { var testDirData = [ { name: "foo.txt", path: "/foo.txt" }, { name: "bar.txt", path: "/subdir/bar.txt" }]; var tests = [ test_setup, function() { populateInputFile("inputFileWebkitDirectory"); }, - function() { populateInputFile("inputFileWebkitDirectoryAndDirectory"); }, - function() { populateInputFile("inputFileDirectory"); }, function() { test_fileList("inputFileWebkitDirectory", testDirData); }, - function() { test_fileList("inputFileWebkitDirectoryAndDirectory", testDirData); }, - function() { test_fileList("inputFileDirectory", null); }, test_webkitdirectory_attribute, test_changeDataWhileWorking, ]; async function next() { if (!tests.length) {
--- a/dom/filesystem/tests/test_worker_basic.html +++ b/dom/filesystem/tests/test_worker_basic.html @@ -26,17 +26,18 @@ function create_fileList() { next(); } script.addMessageListener("dir.opened", onOpened); script.sendAsyncMessage("dir.open", { path: "test" }); } function test_worker() { - fileList.getFilesAndDirectories().then(function(array) { + SpecialPowers.wrap(fileList).getFilesAndDirectories().then(function(array) { + array = SpecialPowers.unwrap(array); var worker = new Worker("worker_basic.js"); worker.onmessage = function(e) { if (e.data.type == "finish") { next(); return; } if (e.data.type == "test") {
--- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -2382,19 +2382,18 @@ void HTMLInputElement::GetDisplayFileNam if (mFileData->mFilesOrDirectories.Length() == 1) { GetDOMFileOrDirectoryName(mFileData->mFilesOrDirectories[0], aValue); return; } nsAutoString value; if (mFileData->mFilesOrDirectories.IsEmpty()) { - if ((StaticPrefs::dom_input_dirpicker() && Allowdirs()) || - (StaticPrefs::dom_webkitBlink_dirPicker_enabled() && - HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) { + if (StaticPrefs::dom_webkitBlink_dirPicker_enabled() && + HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)) { nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES, "NoDirSelected", OwnerDoc(), value); } else if (HasAttr(kNameSpaceID_None, nsGkAtoms::multiple)) { nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES, "NoFilesSelected", OwnerDoc(), value); } else { @@ -2547,22 +2546,16 @@ void HTMLInputElement::FireChangeEventIf Cancelable::eNo); } FileList* HTMLInputElement::GetFiles() { if (mType != FormControlType::InputFile) { return nullptr; } - if (StaticPrefs::dom_input_dirpicker() && Allowdirs() && - (!StaticPrefs::dom_webkitBlink_dirPicker_enabled() || - !HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) { - return nullptr; - } - if (!mFileData->mFileList) { mFileData->mFileList = new FileList(static_cast<nsIContent*>(this)); UpdateFileList(); } return mFileData->mFileList; } @@ -3511,19 +3504,18 @@ nsresult HTMLInputElement::MaybeInitPick } if (mType == FormControlType::InputFile) { // If the user clicked on the "Choose folder..." button we open the // directory picker, else we open the file picker. FilePickerType type = FILE_PICKER_FILE; nsIContent* target = nsIContent::FromEventTargetOrNull(aVisitor.mEvent->mOriginalTarget); if (target && target->FindFirstNonChromeOnlyAccessContent() == this && - ((StaticPrefs::dom_input_dirpicker() && Allowdirs()) || - (StaticPrefs::dom_webkitBlink_dirPicker_enabled() && - HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)))) { + StaticPrefs::dom_webkitBlink_dirPicker_enabled() && + HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)) { type = FILE_PICKER_DIRECTORY; } return InitFilePicker(type); } if (mType == FormControlType::InputColor) { return InitColorPicker(); } @@ -5220,18 +5212,17 @@ nsChangeHint HTMLInputElement::GetAttrib if (PlaceholderApplies() && aAttribute == nsGkAtoms::placeholder && isAdditionOrRemoval) { // We need to re-create our placeholder text. return true; } if (mType == FormControlType::InputFile && - (aAttribute == nsGkAtoms::allowdirs || - aAttribute == nsGkAtoms::webkitdirectory)) { + aAttribute == nsGkAtoms::webkitdirectory) { // The presence or absence of the 'directory' attribute determines what // value we show in the file label when empty, via GetDisplayFileName. return true; } if (mType == FormControlType::InputImage && isAdditionOrRemoval && (aAttribute == nsGkAtoms::alt || aAttribute == nsGkAtoms::value)) { // We might need to rebuild our alt text. Just go ahead and @@ -5279,42 +5270,16 @@ nsMapRuleToAttributesFunc HTMLInputEleme return &ImageInputMapAttributesIntoRule; } return &MapCommonAttributesInto; } // Directory picking methods: -bool HTMLInputElement::IsFilesAndDirectoriesSupported() const { - // This method is supposed to return true if a file and directory picker - // supports the selection of both files and directories *at the same time*. - // Only Mac currently supports that. We could implement it for Mac, but - // currently we do not. - return false; -} - -void HTMLInputElement::ChooseDirectory(ErrorResult& aRv) { - if (mType != FormControlType::InputFile) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); - return; - } - // Script can call this method directly, so even though we don't show the - // "Pick Folder..." button on platforms that don't have a directory picker - // we have to redirect to the file picker here. - InitFilePicker( -#if defined(ANDROID) - // No native directory picker - redirect to plain file picker - FILE_PICKER_FILE -#else - FILE_PICKER_DIRECTORY -#endif - ); -} - already_AddRefed<Promise> HTMLInputElement::GetFilesAndDirectories( ErrorResult& aRv) { if (mType != FormControlType::InputFile) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; } nsCOMPtr<nsIGlobalObject> global = OwnerDoc()->GetScopeObject(); @@ -5354,44 +5319,16 @@ already_AddRefed<Promise> HTMLInputEleme filesAndDirsSeq[i].SetAsFile() = filesAndDirs[i].GetAsFile(); } } p->MaybeResolve(filesAndDirsSeq); return p.forget(); } -already_AddRefed<Promise> HTMLInputElement::GetFiles(bool aRecursiveFlag, - ErrorResult& aRv) { - if (mType != FormControlType::InputFile) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); - return nullptr; - } - - GetFilesHelper* helper = GetOrCreateGetFilesHelper(aRecursiveFlag, aRv); - if (NS_WARN_IF(aRv.Failed())) { - return nullptr; - } - MOZ_ASSERT(helper); - - nsCOMPtr<nsIGlobalObject> global = OwnerDoc()->GetScopeObject(); - MOZ_ASSERT(global); - if (!global) { - return nullptr; - } - - RefPtr<Promise> p = Promise::Create(global, aRv); - if (aRv.Failed()) { - return nullptr; - } - - helper->AddPromise(p); - return p.forget(); -} - // Controllers Methods nsIControllers* HTMLInputElement::GetControllers(ErrorResult& aRv) { // XXX: what about type "file"? if (IsSingleLineTextControl(false)) { if (!mControllers) { mControllers = new nsXULControllers(); if (!mControllers) {
--- a/dom/html/HTMLInputElement.h +++ b/dom/html/HTMLInputElement.h @@ -694,42 +694,28 @@ class HTMLInputElement final : public Te MOZ_CAN_RUN_SCRIPT void SetRangeText(const nsAString& aReplacement, ErrorResult& aRv); MOZ_CAN_RUN_SCRIPT void SetRangeText(const nsAString& aReplacement, uint32_t aStart, uint32_t aEnd, SelectionMode aSelectMode, ErrorResult& aRv); - bool Allowdirs() const { - return HasAttr(kNameSpaceID_None, nsGkAtoms::allowdirs); - } - - void SetAllowdirs(bool aValue, ErrorResult& aRv) { - SetHTMLBoolAttr(nsGkAtoms::allowdirs, aValue, aRv); - } - bool WebkitDirectoryAttr() const { return HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory); } void SetWebkitDirectoryAttr(bool aValue, ErrorResult& aRv) { SetHTMLBoolAttr(nsGkAtoms::webkitdirectory, aValue, aRv); } void GetWebkitEntries(nsTArray<RefPtr<FileSystemEntry>>& aSequence); - bool IsFilesAndDirectoriesSupported() const; - already_AddRefed<Promise> GetFilesAndDirectories(ErrorResult& aRv); - already_AddRefed<Promise> GetFiles(bool aRecursiveFlag, ErrorResult& aRv); - - void ChooseDirectory(ErrorResult& aRv); - void GetAlign(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::align, aValue); } void SetAlign(const nsAString& aValue, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::align, aValue, aRv); } void GetUseMap(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::usemap, aValue); } void SetUseMap(const nsAString& aValue, ErrorResult& aRv) { SetHTMLAttr(nsGkAtoms::usemap, aValue, aRv);
--- a/dom/html/test/mochitest.ini +++ b/dom/html/test/mochitest.ini @@ -583,17 +583,16 @@ support-files = file_bug871161-1.html fi tags = openwindow skip-if = (toolkit == "android" && debug && !is_fennec) || (os == "linux") || (os == "win" && debug && bits == 64) # Bug 1533759 [test_viewport_resize.html] [test_image_clone_load.html] [test_bug1203668.html] [test_bug1166138.html] [test_bug1230665.html] [test_filepicker_default_directory.html] -[test_bug1233598.html] [test_bug1250401.html] [test_bug1260664.html] [test_bug1261673.html] skip-if = (os == 'android' || os == 'mac') [test_bug1261674-1.html] skip-if = (os == 'android' || os == 'mac') [test_bug1261674-2.html] skip-if = (os == 'mac')
deleted file mode 100644 --- a/dom/html/test/test_bug1233598.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=1233598 ---> -<head> - <title>Test for Bug 1233598</title> - <script src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1233598">Mozilla Bug 1233598</a> -<pre id="test"> -<script type="application/javascript"> - -/** Test for Bug 1233598 **/ - -var i; // must be out here to trigger the leak - -function runTest() -{ - i = document.createElement("input"); - i.setAttribute("type", "file"); - i.getFilesAndDirectories(); // returns a promise - ok(true, "Are we leaking?"); - SimpleTest.finish(); -} - -SimpleTest.waitForExplicitFinish(); -SpecialPowers.pushPrefEnv({"set":[["dom.input.dirpicker", true]]}, runTest); - -</script> -</pre> -</body> -</html>
--- a/dom/html/test/test_fakepath.html +++ b/dom/html/test/test_fakepath.html @@ -26,16 +26,15 @@ function onOpened(message) { SimpleTest.finish(); } function run() { script.addMessageListener("file.opened", onOpened); script.sendAsyncMessage("file.open"); } -SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true], - ["dom.webkitBlink.dirPicker.enabled", true]]}, run); +SpecialPowers.pushPrefEnv({"set": [["dom.webkitBlink.dirPicker.enabled", true]]}, run); SimpleTest.waitForExplicitFinish(); </script> </body> </html>
--- a/dom/webidl/DataTransfer.webidl +++ b/dom/webidl/DataTransfer.webidl @@ -28,24 +28,16 @@ interface DataTransfer { [Throws, NeedsSubjectPrincipal] void setData(DOMString format, DOMString data); [Throws, NeedsSubjectPrincipal] void clearData(optional DOMString format); [NeedsSubjectPrincipal] readonly attribute FileList? files; }; -partial interface DataTransfer { - [Throws, Pref="dom.input.dirpicker", NeedsSubjectPrincipal] - Promise<sequence<(File or Directory)>> getFilesAndDirectories(); - - [Throws, Pref="dom.input.dirpicker", NeedsSubjectPrincipal] - Promise<sequence<File>> getFiles(optional boolean recursiveFlag = false); -}; - // Mozilla specific stuff partial interface DataTransfer { /* * Set the drag source. Usually you would not change this, but it will * affect which node the drag and dragend events are fired at. The * default target is the node that was dragged. * * @param element drag source to use
--- a/dom/webidl/HTMLInputElement.webidl +++ b/dom/webidl/HTMLInputElement.webidl @@ -165,16 +165,20 @@ partial interface HTMLInputElement { // This method is meant to use for testing only. [ChromeOnly, Throws] void mozSetDirectory(DOMString directoryPath); // This method is meant to use for testing only. [ChromeOnly] void mozSetDndFilesAndDirectories(sequence<(File or Directory)> list); + // This method is meant to use for testing only. + [ChromeOnly, Throws] + Promise<sequence<(File or Directory)>> getFilesAndDirectories(); + boolean mozIsTextField(boolean aExcludePassword); [ChromeOnly] readonly attribute boolean hasBeenTypePassword; [ChromeOnly] attribute DOMString previewValue; @@ -210,33 +214,16 @@ interface mixin MozEditableElement { // of the value change is closer to the normal user input, so 'change' event // for example will be dispatched when focusing out the element. [Func="IsChromeOrUAWidget", NeedsSubjectPrincipal] void setUserInput(DOMString input); }; HTMLInputElement includes MozEditableElement; -partial interface HTMLInputElement { - [Pref="dom.input.dirpicker", SetterThrows] - attribute boolean allowdirs; - - [Pref="dom.input.dirpicker"] - readonly attribute boolean isFilesAndDirectoriesSupported; - - [Throws, Pref="dom.input.dirpicker"] - Promise<sequence<(File or Directory)>> getFilesAndDirectories(); - - [Throws, Pref="dom.input.dirpicker"] - Promise<sequence<File>> getFiles(optional boolean recursiveFlag = false); - - [Throws, Pref="dom.input.dirpicker"] - void chooseDirectory(); -}; - HTMLInputElement includes MozImageLoadingContent; // https://wicg.github.io/entries-api/#idl-index partial interface HTMLInputElement { [Pref="dom.webkitBlink.filesystem.enabled", Frozen, Cached, Pure] readonly attribute sequence<FileSystemEntry> webkitEntries; [Pref="dom.webkitBlink.dirPicker.enabled", BinaryName="WebkitDirectoryAttr", SetterThrows]
--- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -393,18 +393,17 @@ nsFileControlFrame::DnDListener::HandleE nsTArray<OwningFileOrDirectory> array; if (webkitDir) { AppendBlobImplAsDirectory(array, webkitDir, inputElement); inputElement->MozSetDndFilesAndDirectories(array); } else { bool blinkFileSystemEnabled = StaticPrefs::dom_webkitBlink_filesystem_enabled(); - bool dirPickerEnabled = StaticPrefs::dom_input_dirpicker(); - if (blinkFileSystemEnabled || dirPickerEnabled) { + if (blinkFileSystemEnabled) { FileList* files = static_cast<FileList*>(fileList.get()); if (files) { for (uint32_t i = 0; i < files->Length(); ++i) { File* file = files->Item(i); if (file) { if (file->Impl() && file->Impl()->IsDirectory()) { AppendBlobImplAsDirectory(array, file->Impl(), inputElement); } else { @@ -419,20 +418,16 @@ nsFileControlFrame::DnDListener::HandleE // Entries API. if (blinkFileSystemEnabled) { // This is rather ugly. Pass the directories as Files using SetFiles, // but then if blink filesystem API is enabled, it wants // FileOrDirectory array. inputElement->SetFiles(fileList, true); inputElement->UpdateEntries(array); } - // Directory Upload API - else if (dirPickerEnabled) { - inputElement->SetFilesOrDirectories(array, true); - } // Normal DnD else { inputElement->SetFiles(fileList, true); } RefPtr<TextEditor> textEditor; DebugOnly<nsresult> rvIgnored = nsContentUtils::DispatchInputEvent(inputElement);
--- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -2647,22 +2647,16 @@ mirror: always # Is support for HTMLElement.inputMode enabled? - name: dom.forms.inputmode type: bool value: true mirror: always -# Enable Directory API. By default, disabled. -- name: dom.input.dirpicker - type: bool - value: false - mirror: always - # Whether to allow or disallow web apps to cancel `beforeinput` events caused # by MozEditableElement#setUserInput() which is used by autocomplete, autofill # and password manager. - name: dom.input_event.allow_to_cancel_set_user_input type: bool value: false mirror: always
--- a/xpcom/ds/StaticAtoms.py +++ b/xpcom/ds/StaticAtoms.py @@ -72,17 +72,16 @@ STATIC_ATOMS = [ Atom("actuate", "actuate"), Atom("address", "address"), Atom("adoptedsheetclones", "adoptedsheetclones"), Atom("after", "after"), Atom("align", "align"), Atom("alink", "alink"), Atom("all", "all"), Atom("allow", "allow"), - Atom("allowdirs", "allowdirs"), Atom("allowdownloads", "allow-downloads"), Atom("allowevents", "allowevents"), Atom("allowforms", "allow-forms"), Atom("allowfullscreen", "allowfullscreen"), Atom("allowmodals", "allow-modals"), Atom("alloworientationlock", "allow-orientation-lock"), Atom("allowpointerlock", "allow-pointer-lock"), Atom("allowpopupstoescapesandbox", "allow-popups-to-escape-sandbox"),