mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 04:37:44 +00:00
LibWeb+LibWebView+WebContent: Implement more <input type=file> behavior
We had previous implemented some plumbing for file input elements in
commit 636602a54e
.
This implements the return path for chromes to inform WebContent of the
file(s) the user selected. This patch includes a dummy implementation
for headless-browser to enable testing.
This commit is contained in:
parent
435c2c24d1
commit
108521a566
23 changed files with 307 additions and 5 deletions
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/JsonObject.h>
|
||||
|
@ -44,6 +45,7 @@
|
|||
#include <LibWeb/Cookie/Cookie.h>
|
||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||
#include <LibWeb/HTML/ActivateTab.h>
|
||||
#include <LibWeb/HTML/SelectedFile.h>
|
||||
#include <LibWeb/Worker/WebWorkerClient.h>
|
||||
#include <LibWebView/CookieJar.h>
|
||||
#include <LibWebView/Database.h>
|
||||
|
@ -433,6 +435,21 @@ static ErrorOr<TestResult> run_test(HeadlessWebContentView& view, StringView inp
|
|||
promise->resolve({});
|
||||
};
|
||||
view.on_text_test_finish = {};
|
||||
|
||||
view.on_request_file_picker = [&](auto allow_multiple_files) {
|
||||
// Create some dummy files for tests.
|
||||
Vector<Web::HTML::SelectedFile> selected_files;
|
||||
selected_files.empend("file1"sv, MUST(ByteBuffer::copy("Contents for file1"sv.bytes())));
|
||||
|
||||
if (allow_multiple_files == Web::HTML::AllowMultipleFiles::Yes) {
|
||||
selected_files.empend("file2"sv, MUST(ByteBuffer::copy("Contents for file2"sv.bytes())));
|
||||
selected_files.empend("file3"sv, MUST(ByteBuffer::copy("Contents for file3"sv.bytes())));
|
||||
selected_files.empend("file4"sv, MUST(ByteBuffer::copy("Contents for file4"sv.bytes())));
|
||||
}
|
||||
|
||||
view.file_picker_closed(move(selected_files));
|
||||
};
|
||||
|
||||
view.load(URL("about:blank"sv));
|
||||
MUST(promise->await());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue