Truly independent web browser
LibWeb+LibWebView: Let a page read back clipboard data its origin wrote
Shannon Boothc9fa91462b82
diff --git a/Libraries/LibWeb/Clipboard/Clipboard.cpp b/Libraries/LibWeb/Clipboard/Clipboard.cppindex 551edf244ab..6757d0664e8 100644--- a/Libraries/LibWeb/Clipboard/Clipboard.cpp+++ b/Libraries/LibWeb/Clipboard/Clipboard.cpp@@ -146,31 +146,45 @@ static void write_blobs_and_option_to_clipboard(JS::Realm& realm, ReadonlySpan<Grepresentations.empend(move(format_string), move(payload));}- window.page().client().page_did_insert_clipboard_item({ move(representations) }, presentation_style);+ window.page().client().page_did_insert_clipboard_item({ move(representations) }, presentation_style, window.associated_document().id());// FIXME: 3. Write web custom formats given webCustomFormats.}+// AD-HOC: Besides true and false, checking the clipboard read permission can allow reading only data that the reader's+// own origin wrote to the clipboard.+enum class ClipboardReadPermission : u8 {+ Denied,+ Granted,+ GrantedForOwnOriginData,+};+// https://w3c.github.io/clipboard-apis/#h-clipboard-read-permission-static bool check_clipboard_read_permission(JS::Realm& realm, bool is_running_from_paste)+static ClipboardReadPermission check_clipboard_read_permission(JS::Realm& realm, bool is_running_from_paste){// NOTE: The clipboard permission is undergoing a refactor because the clipboard-read permission was removed from// the Permissions spec. So this partially implements the proposed update:// https://pr-preview.s3.amazonaws.com/w3c/clipboard-apis/pull/164.html#read-permission+ auto& window = HTML::relevant_window(realm.global_object());+// 1. Let hasGesture be true if the relevant global object of this has transient activation, false otherwise.- auto has_gesture = HTML::relevant_window(realm.global_object()).has_transient_activation();+ auto has_gesture = window.has_transient_activation();// 2. If hasGesture then,if (has_gesture) {// 1. Return true if the current script is running as a result of user interaction with a "Paste" element// created by the user agent or operating system.if (is_running_from_paste)- return true;+ return ClipboardReadPermission::Granted;++ // AD-HOC: Reading back data that the reader's own origin wrote to the clipboard tells it nothing new, so allow+ // that without a "Paste" element.+ return ClipboardReadPermission::GrantedForOwnOriginData;}// 3. Otherwise, return false.- return false;+ return ClipboardReadPermission::Denied;}// https://w3c.github.io/clipboard-apis/#check-clipboard-write-permission@@ -219,7 +233,7 @@ void Clipboard::read(JS::Realm& realm, ClipboardReadOptions formats, GC::Ref<Webauto result = check_clipboard_read_permission(realm, pasted_data.has_value());// 2. If r is false, then:- if (!result) {+ if (result == ClipboardReadPermission::Denied) {// 1. Queue a global task on the permission task source, given realm’s global object, to reject p with// "NotAllowedError" DOMException in realm.queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), GC::create_function(GC::Heap::the(), GC::captures(realm, promise), [](auto& realm, auto& promise) {@@ -335,9 +349,26 @@ void Clipboard::read(JS::Realm& realm, ClipboardReadOptions formats, GC::Ref<Web});// 3. Let data be the system clipboard data.- // NB: Only a read running as a result of a paste of the system clipboard gets here, and it reads the data being- // pasted.- steps_with_data->function()(pasted_data.release_value());+ // NB: A read running as a result of a paste of the system clipboard reads the data being pasted.+ if (result == ClipboardReadPermission::Granted) {+ steps_with_data->function()(pasted_data.release_value());+ return;+ }++ // AD-HOC: For any other read, the UI process hands over the system clipboard data only if all of it is data that+ // the reading document's origin wrote.+ auto& document = HTML::relevant_window(realm.global_object()).associated_document();+ document.page().request_clipboard_entries(GC::create_function(GC::Heap::the(), GC::captures(realm, promise, steps_with_data), [](auto& realm, auto& promise, auto& steps_with_data, Vector<SystemClipboardItem> data) {+ if (data.is_empty()) {+ queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), GC::create_function(GC::Heap::the(), GC::captures(realm, promise), [](auto& realm, auto& promise) {+ HTML::TemporaryExecutionContext execution_context { realm };+ WebIDL::reject_promise(promise, WebIDL::NotAllowedError::create("Clipboard reading is only allowed while the user pastes"_utf16));+ }));+ return;+ }+ steps_with_data->function()(move(data));+ }),+ document.id());}));}@@ -356,7 +387,7 @@ void Clipboard::read_text(JS::Realm& realm, GC::Ref<WebIDL::Promise> promise)auto result = check_clipboard_read_permission(realm, pasted_data.has_value());// 2. If r is false, then:- if (!result) {+ if (result == ClipboardReadPermission::Denied) {// 1. Queue a global task on the permission task source, given realm’s global object, to reject p with// "NotAllowedError" DOMException in realm.queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), GC::create_function(GC::Heap::the(), GC::captures(realm, promise), [](auto& realm, auto& promise) {@@ -430,9 +461,26 @@ void Clipboard::read_text(JS::Realm& realm, GC::Ref<WebIDL::Promise> promise)});// 3. Let data be a copy of the system clipboard data.- // NB: Only a read running as a result of a paste of the system clipboard gets here, and it reads the data being- // pasted.- steps_with_data->function()(pasted_data.release_value());+ // NB: A read running as a result of a paste of the system clipboard reads the data being pasted.+ if (result == ClipboardReadPermission::Granted) {+ steps_with_data->function()(pasted_data.release_value());+ return;+ }++ // AD-HOC: For any other read, the UI process hands over the system clipboard data only if all of it is data that+ // the reading document's origin wrote.+ auto& document = HTML::relevant_window(realm.global_object()).associated_document();+ document.page().request_clipboard_entries(GC::create_function(GC::Heap::the(), GC::captures(realm, promise, steps_with_data), [](auto& realm, auto& promise, auto& steps_with_data, Vector<SystemClipboardItem> data) {+ if (data.is_empty()) {+ queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), GC::create_function(GC::Heap::the(), GC::captures(realm, promise), [](auto& realm, auto& promise) {+ HTML::TemporaryExecutionContext execution_context { realm };+ WebIDL::reject_promise(promise, WebIDL::NotAllowedError::create("Clipboard reading is only allowed while the user pastes"_utf16));+ }));+ return;+ }+ steps_with_data->function()(move(data));+ }),+ document.id());}));}diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cppindex 9efd2f71ffe..7b87af13566 100644--- a/Libraries/LibWeb/Internals/Internals.cpp+++ b/Libraries/LibWeb/Internals/Internals.cpp@@ -1176,7 +1176,8 @@ WebIDL::ExceptionOr<void> Internals::set_clipboard_file(Utf16String const& name,HTML::SelectedFile file { name, MUST(ByteBuffer::copy(data_utf8.bytes())) };Clipboard::SystemClipboardRepresentation item { move(mime_type_utf8), move(file) };- page().client().page_did_insert_clipboard_item({ { move(item) } }, "unspecified"sv);+ // NB: This stands in for another application writing to the clipboard, so no origin wrote it.+ page().client().page_did_insert_clipboard_item({ { move(item) } }, "unspecified"sv, {});return {};}diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cppindex 5f665075f79..d6012a0cb03 100644--- a/Libraries/LibWeb/Page/EventHandler.cpp+++ b/Libraries/LibWeb/Page/EventHandler.cpp@@ -2642,7 +2642,7 @@ static void write_data_transfer_to_clipboard(DOM::Document& document, HTML::Dragrepresentations.empend(move(mime_type), item.data.to_byte_string());}if (!representations.is_empty())- document.page().client().page_did_insert_clipboard_item({ move(representations) }, "unspecified"sv);+ document.page().client().page_did_insert_clipboard_item({ move(representations) }, "unspecified"sv, document.id());}EventResult EventHandler::perform_copy_action()@@ -2716,7 +2716,7 @@ bool EventHandler::perform_copy_action(ClipboardActionTrigger trigger)if (!text.is_empty())representations.empend("text/plain"_string, text.to_byte_string());if (!representations.is_empty())- document->page().client().page_did_insert_clipboard_item({ move(representations) }, "unspecified"sv);+ document->page().client().page_did_insert_clipboard_item({ move(representations) }, "unspecified"sv, document->id());// FIXME: 2. Fire a clipboard event named clipboardchange.}@@ -2796,7 +2796,7 @@ bool EventHandler::perform_cut_action(ClipboardActionTrigger trigger)if (!text.is_empty())representations.empend("text/plain"_string, text.to_byte_string());if (!representations.is_empty())- document->page().client().page_did_insert_clipboard_item({ move(representations) }, "unspecified"sv);+ document->page().client().page_did_insert_clipboard_item({ move(representations) }, "unspecified"sv, document->id());// 2. Remove the contents of the selection from the document and collapse the selection.// 4. Queue tasks to fire any events that should fire due to the modification.diff --git a/Libraries/LibWeb/Page/Page.cpp b/Libraries/LibWeb/Page/Page.cppindex 4cb4f79c19f..1593b879bce 100644--- a/Libraries/LibWeb/Page/Page.cpp+++ b/Libraries/LibWeb/Page/Page.cpp@@ -1510,6 +1510,14 @@ void Page::request_clipboard_entries_for_paste(ClipboardRequest request)client().page_did_request_clipboard_entries_for_paste(request_id);}+void Page::request_clipboard_entries(ClipboardRequest request, HTML::CrossProcessId reading_document_id)+{+ auto request_id = m_next_clipboard_request_id++;+ m_pending_clipboard_requests.set(request_id, request);++ client().page_did_request_clipboard_entries(request_id, reading_document_id);+}+void Page::retrieved_clipboard_entries(u64 request_id, Vector<Clipboard::SystemClipboardItem> items){if (auto request = m_pending_clipboard_requests.take(request_id); request.has_value())diff --git a/Libraries/LibWeb/Page/Page.h b/Libraries/LibWeb/Page/Page.hindex 62b5cc7c104..15d9b112826 100644--- a/Libraries/LibWeb/Page/Page.h+++ b/Libraries/LibWeb/Page/Page.h@@ -326,6 +326,7 @@ public:using ClipboardRequest = GC::Ref<GC::Function<void(Vector<Clipboard::SystemClipboardItem>)>>;void request_clipboard_entries_for_paste(ClipboardRequest);+ void request_clipboard_entries(ClipboardRequest, HTML::CrossProcessId reading_document_id);void retrieved_clipboard_entries(u64 request_id, Vector<Clipboard::SystemClipboardItem>);using SpellCheckRequest = GC::Ref<GC::Function<void(Vector<SpellingError>)>>;@@ -981,8 +982,9 @@ public:virtual void page_did_change_theme_color(Gfx::Color) { }virtual void page_did_change_background_color(Gfx::Color) { }- virtual void page_did_insert_clipboard_item(Clipboard::SystemClipboardItem const&, [[maybe_unused]] StringView presentation_style) { }+ virtual void page_did_insert_clipboard_item(Clipboard::SystemClipboardItem const&, [[maybe_unused]] StringView presentation_style, [[maybe_unused]] Optional<HTML::CrossProcessId> writing_document_id) { }virtual void page_did_request_clipboard_entries_for_paste([[maybe_unused]] u64 request_id) { }+ virtual void page_did_request_clipboard_entries([[maybe_unused]] u64 request_id, [[maybe_unused]] HTML::CrossProcessId reading_document_id) { }virtual void page_did_request_paste_from_clipboard_for_testing() { }virtual void page_did_request_spell_check([[maybe_unused]] u64 request_id, [[maybe_unused]] Utf16String const& text) { }virtual void page_did_request_translation([[maybe_unused]] TranslationUnit const&) { }diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cppindex 5cc499b064b..76824e55e18 100644--- a/Libraries/LibWebView/ViewImplementation.cpp+++ b/Libraries/LibWebView/ViewImplementation.cpp@@ -4,6 +4,7 @@* SPDX-License-Identifier: BSD-2-Clause*/+#include <AK/AllOf.h>#include <AK/AnyOf.h>#include <AK/Debug.h>#include <AK/Error.h>@@ -2846,6 +2847,32 @@ void ViewImplementation::read_clipboard_item(Function<void(Web::Clipboard::Systeon_read(clipboard_item());}+// NB: The tab remembers the last clipboard write by one of its pages, so a page reads back only what its origin wrote in+// the same tab.+void ViewImplementation::did_insert_clipboard_item_written_by(URL::Origin writer, Web::Clipboard::SystemClipboardItem item)+{+ m_last_clipboard_write_by_a_page = ClipboardWrite { move(writer), move(item) };+}++// Whatever wrote to the clipboard since, a page learns nothing new from data that its origin wrote itself. So compare+// the clipboard's data with that origin's write, rather than tracking every change to the clipboard.+bool ViewImplementation::is_clipboard_data_written_by(Web::Clipboard::SystemClipboardItem const& item, URL::Origin const& origin) const+{+ if (!m_last_clipboard_write_by_a_page.has_value() || !m_last_clipboard_write_by_a_page->writer.is_same_origin(origin))+ return false;++ auto const& written_representations = m_last_clipboard_write_by_a_page->item.system_clipboard_representations;+ auto was_written = [&](Web::Clipboard::SystemClipboardRepresentation const& representation) {+ auto const* data = representation.data.get_pointer<ByteString>();+ return data && any_of(written_representations, [&](Web::Clipboard::SystemClipboardRepresentation const& written) {+ auto const* written_data = written.data.get_pointer<ByteString>();+ return written.name == representation.name && written_data && *written_data == *data;+ });+ };++ return !item.system_clipboard_representations.is_empty() && all_of(item.system_clipboard_representations, was_written);+}+Web::Clipboard::SystemClipboardItem ViewImplementation::clipboard_item() const{return Application::the().clipboard_item();diff --git a/Libraries/LibWebView/ViewImplementation.h b/Libraries/LibWebView/ViewImplementation.hindex 5a6664ebc67..08933c3a008 100644--- a/Libraries/LibWebView/ViewImplementation.h+++ b/Libraries/LibWebView/ViewImplementation.h@@ -305,6 +305,9 @@ public:// Whether the page has yet to finish handling input that gives it user activation.bool is_delivering_user_activation_to(WebContentPage const&) const;bool take_paste_shortcut_handled_by(Badge<WebContentPage>, WebContentPage const&);++ void did_insert_clipboard_item_written_by(URL::Origin, Web::Clipboard::SystemClipboardItem);+ bool is_clipboard_data_written_by(Web::Clipboard::SystemClipboardItem const&, URL::Origin const&) const;// Consumes the activation of the earliest input giving the page activation that the page has yet to finish// handling, which leaves the input queued behind it the activation it gives.void consume_user_activation_of_input_in_flight_to(Badge<WebContentPage>, WebContentPage const&);@@ -968,6 +971,12 @@ protected:Optional<MonotonicTime> paste_shortcut_time {};};Vector<PendingInputEvent> m_pending_input_events;++ struct ClipboardWrite {+ URL::Origin writer;+ Web::Clipboard::SystemClipboardItem item;+ };+ Optional<ClipboardWrite> m_last_clipboard_write_by_a_page;void send_queued_input_events();void send_input_event(size_t index);bool may_scroll_for_key_event_in_compositor(size_t index) const;diff --git a/Libraries/LibWebView/WebContentPage.cpp b/Libraries/LibWebView/WebContentPage.cppindex 9d273bfada8..f61fc6d4563 100644--- a/Libraries/LibWebView/WebContentPage.cpp+++ b/Libraries/LibWebView/WebContentPage.cpp@@ -2107,10 +2107,14 @@ void WebContentPage::did_change_background_color(Gfx::Color color)// NB: The system clipboard belongs to the user, so a page reaches it only right after the user's own input to it, as// with a copy or paste shortcut, a click on a page control, or the browser's Paste command.-void WebContentPage::did_insert_clipboard_item(Web::Clipboard::SystemClipboardItem item, String)+void WebContentPage::did_insert_clipboard_item(Web::Clipboard::SystemClipboardItem item, String, Optional<Web::HTML::CrossProcessId> writing_document_id){if (!has_transient_user_activation())return;+ if (writing_document_id.has_value()) {+ if (auto document = hosted_document_with_id(*writing_document_id))+ view().did_insert_clipboard_item_written_by(document->origin(), item);+ }view().insert_clipboard_item(move(item));}@@ -2460,6 +2464,25 @@ void WebContentPage::did_request_clipboard_entries_for_paste(u64 request_id)});}+// NB: Outside a paste, a page reads only data that its own origin wrote to the clipboard, which tells it nothing new.+void WebContentPage::did_request_clipboard_entries(u64 request_id, Web::HTML::CrossProcessId reading_document_id)+{+ Vector<Web::Clipboard::SystemClipboardItem> items;+ auto document = hosted_document_with_id(reading_document_id);+ if (!document || !has_transient_user_activation()) {+ async_retrieved_clipboard_entries(request_id, items);+ return;+ }+ view().read_clipboard_item([page = NonnullRefPtr { *this }, request_id, origin = document->origin()](Web::Clipboard::SystemClipboardItem item) {+ if (!page->is_open())+ return;+ Vector<Web::Clipboard::SystemClipboardItem> items;+ if (auto view = page->traversable().view(); view.has_value() && view->is_clipboard_data_written_by(item, origin))+ items.append(move(item));+ page->async_retrieved_clipboard_entries(request_id, items);+ });+}+void WebContentPage::did_request_paste_from_clipboard_for_testing(){// NB: This stands in for the browser's Paste command, which hands the page the system clipboard data.diff --git a/Libraries/LibWebView/WebContentPage.h b/Libraries/LibWebView/WebContentPage.hindex 0d9dbdb8a02..188406081c9 100644--- a/Libraries/LibWebView/WebContentPage.h+++ b/Libraries/LibWebView/WebContentPage.h@@ -300,7 +300,7 @@ private:virtual void did_update_input_method_state(Optional<Web::DevicePixelRect> caret_rect, bool is_enabled, i32 cursor_position, i32 anchor_position, Utf16String text_before_cursor, Utf16String text_after_cursor) override;virtual void did_change_theme_color(Gfx::Color color) override;virtual void did_change_background_color(Gfx::Color color) override;- virtual void did_insert_clipboard_item(Web::Clipboard::SystemClipboardItem item, String) override;+ virtual void did_insert_clipboard_item(Web::Clipboard::SystemClipboardItem item, String, Optional<Web::HTML::CrossProcessId> writing_document_id) override;virtual void did_change_screen_wake_lock_state(Web::ScreenWakeLockState wake_lock_state) override;virtual void did_start_using_gamepads() override;virtual void did_update_session_history_entry_navigation_api_state(Web::HTML::CrossProcessId navigable_id, Web::HTML::SessionHistoryEntryIdentity entry_identity, Web::HTML::StorageSerializationRecord navigation_api_state) override;@@ -337,6 +337,7 @@ private:virtual void did_receive_network_response_headers(u64 request_id, u32 status_code, Optional<String> reason_phrase, Vector<HTTP::Header> response_headers, Requests::CacheState cache_state) override;virtual void did_update_indexed_database(String update) override;virtual void did_request_clipboard_entries_for_paste(u64 request_id) override;+ virtual void did_request_clipboard_entries(u64 request_id, Web::HTML::CrossProcessId reading_document_id) override;virtual void did_request_paste_from_clipboard_for_testing() override;virtual void did_request_spell_check(u64 request_id, Utf16String text) override;virtual void did_request_writing_suggestion(u64 request_id, Utf16String text, u32 caret_offset) override;diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cppindex efda6f1d2b7..a05e5e6959b 100644--- a/Services/WebContent/PageClient.cpp+++ b/Services/WebContent/PageClient.cpp@@ -2143,9 +2143,9 @@ void PageClient::page_did_change_background_color(Gfx::Color color)client().async_did_change_background_color(m_id, color);}-void PageClient::page_did_insert_clipboard_item(Web::Clipboard::SystemClipboardItem const& item, StringView presentation_style)+void PageClient::page_did_insert_clipboard_item(Web::Clipboard::SystemClipboardItem const& item, StringView presentation_style, Optional<Web::HTML::CrossProcessId> writing_document_id){- client().async_did_insert_clipboard_item(m_id, item, presentation_style);+ client().async_did_insert_clipboard_item(m_id, item, presentation_style, writing_document_id);}void PageClient::page_did_request_clipboard_entries_for_paste(u64 request_id)@@ -2153,6 +2153,11 @@ void PageClient::page_did_request_clipboard_entries_for_paste(u64 request_id)client().async_did_request_clipboard_entries_for_paste(m_id, request_id);}+void PageClient::page_did_request_clipboard_entries(u64 request_id, Web::HTML::CrossProcessId reading_document_id)+{+ client().async_did_request_clipboard_entries(m_id, request_id, reading_document_id);+}+void PageClient::page_did_request_paste_from_clipboard_for_testing(){client().async_did_request_paste_from_clipboard_for_testing(m_id);diff --git a/Services/WebContent/PageClient.h b/Services/WebContent/PageClient.hindex 060f18ce1b0..77b32a3a0d5 100644--- a/Services/WebContent/PageClient.h+++ b/Services/WebContent/PageClient.h@@ -392,8 +392,9 @@ private:virtual void page_did_set_device_pixel_ratio_for_testing(double ratio) override;virtual void page_did_change_theme_color(Gfx::Color color) override;virtual void page_did_change_background_color(Gfx::Color color) override;- virtual void page_did_insert_clipboard_item(Web::Clipboard::SystemClipboardItem const&, StringView presentation_style) override;+ virtual void page_did_insert_clipboard_item(Web::Clipboard::SystemClipboardItem const&, StringView presentation_style, Optional<Web::HTML::CrossProcessId> writing_document_id) override;virtual void page_did_request_clipboard_entries_for_paste(u64 request_id) override;+ virtual void page_did_request_clipboard_entries(u64 request_id, Web::HTML::CrossProcessId reading_document_id) override;virtual void page_did_request_paste_from_clipboard_for_testing() override;virtual void page_did_request_spell_check(u64 request_id, Utf16String const& text) override;virtual void page_did_request_translation(Web::TranslationUnit const&) override;diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipcindex 4aef1bc8992..dd361dd47e7 100644--- a/Services/WebContent/WebContentClient.ipc+++ b/Services/WebContent/WebContentClient.ipc@@ -260,8 +260,9 @@ endpoint WebContentClient routed by Web::PageId page_iddid_change_theme_color(Web::PageId page_id, Gfx::Color color) =|did_change_background_color(Web::PageId page_id, Gfx::Color color) =|- did_insert_clipboard_item(Web::PageId page_id, Web::Clipboard::SystemClipboardItem item, String presentation_style) =|+ did_insert_clipboard_item(Web::PageId page_id, Web::Clipboard::SystemClipboardItem item, String presentation_style, Optional<Web::HTML::CrossProcessId> writing_document_id) =|did_request_clipboard_entries_for_paste(Web::PageId page_id, u64 request_id) =|+ did_request_clipboard_entries(Web::PageId page_id, u64 request_id, Web::HTML::CrossProcessId reading_document_id) =|did_request_paste_from_clipboard_for_testing(Web::PageId page_id) =|did_request_spell_check(Web::PageId page_id, u64 request_id, Utf16String text) =|did_request_writing_suggestion(Web::PageId page_id, u64 request_id, Utf16String text, u32 caret_offset) =|diff --git a/Tests/LibWeb/Text/expected/Clipboard/clipboard-read-requires-paste.txt b/Tests/LibWeb/Text/expected/Clipboard/clipboard-read-requires-paste.txtindex c26fb57eef0..6c4ac2a5de0 100644--- a/Tests/LibWeb/Text/expected/Clipboard/clipboard-read-requires-paste.txt+++ b/Tests/LibWeb/Text/expected/Clipboard/clipboard-read-requires-paste.txt@@ -1,3 +1,4 @@+Another application's data on the clipboard:readText() without activation: rejected with NotAllowedErrorreadText() after a click: rejected with NotAllowedErrorread() after a click: rejected with NotAllowedError@@ -5,3 +6,8 @@ read() in a paste event the browser did not fire: rejected with NotAllowedErrorread() in a handed-over paste: rejected with NotAllowedErrorread() in a task after a browser paste: rejected with NotAllowedErrorread() in a browser paste: resolved with types []+The page's own data on the clipboard:+readText() after a click: resolved with "own text"+read() after a click: resolved with types [["text/plain"]]+Another application's data replacing the page's:+read() after a click: rejected with NotAllowedErrordiff --git a/Tests/LibWeb/Text/expected/wpt-import/clipboard-apis/async-navigator-clipboard-basics.https.txt b/Tests/LibWeb/Text/expected/wpt-import/clipboard-apis/async-navigator-clipboard-basics.https.txtindex 1f2c7f0b2f7..dd5d7573322 100644--- a/Tests/LibWeb/Text/expected/wpt-import/clipboard-apis/async-navigator-clipboard-basics.https.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/clipboard-apis/async-navigator-clipboard-basics.https.txt@@ -2,8 +2,8 @@ Harness status: OKFound 17 tests-13 Pass-4 Fail+14 Pass+3 FailPass navigator.clipboard existsPass navigator.clipboard.write([text/plain ClipboardItem]) succeedsFail navigator.clipboard.write([>1 ClipboardItems]) fails (not implemented)@@ -17,7 +17,7 @@ Pass navigator.clipboard.write({string : DOMString}) succeedsPass navigator.clipboard.write({string : image/png Blob}) succeedsPass navigator.clipboard.write([text + png] succeedsFail navigator.clipboard.write(image/png DOMString) fails-Fail navigator.clipboard.read() succeeds+Pass navigator.clipboard.read() succeedsFail navigator.clipboard.readText() succeedsPass navigator.clipboard.write(Promise<Blob>) succeedsPass navigator.clipboard.write(Promise<Blob>s) succeeds\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/Clipboard/clipboard-read-requires-paste.html b/Tests/LibWeb/Text/input/Clipboard/clipboard-read-requires-paste.htmlindex 213a1ac6011..e58d2e28b32 100644--- a/Tests/LibWeb/Text/input/Clipboard/clipboard-read-requires-paste.html+++ b/Tests/LibWeb/Text/input/Clipboard/clipboard-read-requires-paste.html@@ -18,6 +18,7 @@editor.focus();+ println("Another application's data on the clipboard:");internals.setClipboardFile("other.txt", "text/plain", "other application");println(`readText() without activation: ${await describe(navigator.clipboard.readText())}`);println(`readText() after a click: ${await readAfterClick(readText)}`);@@ -47,5 +48,15 @@println(`read() in a task after a browser paste: ${await describe(readLater)}`);println(`read() in a browser paste: ${await describe(readClipboardFromPaste(editor))}`);++ println("The page's own data on the clipboard:");+ activate();+ await navigator.clipboard.writeText("own text");+ println(`readText() after a click: ${await readAfterClick(readText)}`);+ println(`read() after a click: ${await readAfterClick(read)}`);++ println("Another application's data replacing the page's:");+ internals.setClipboardFile("other.txt", "text/plain", "other application");+ println(`read() after a click: ${await readAfterClick(read)}`);});</script>