Truly independent web browser
LibWeb: List documents, image requests and audibility changes
Aliaksandr Kalenik6ef3cdee16fd
diff --git a/Libraries/LibWeb/DOM/HTMLCollection.cpp b/Libraries/LibWeb/DOM/HTMLCollection.cppindex be76af6727a..72d37629d7e 100644--- a/Libraries/LibWeb/DOM/HTMLCollection.cpp+++ b/Libraries/LibWeb/DOM/HTMLCollection.cpp@@ -111,16 +111,20 @@ void HTMLCollection::collect_elements_into(Vector<GC::RawPtr<Element>>& elements}}-void HTMLCollection::update_cache_if_needed() const+bool HTMLCollection::cache_is_valid() const{auto& document = root()->document();- auto invalidation_version = this->invalidation_version(document);-- if (m_cache_registration.list_node.is_in_list()+ return m_cache_registration.list_node.is_in_list()&& m_cached_document.ptr().ptr() == &document- && m_cached_invalidation_version == invalidation_version) {+ && m_cached_invalidation_version == invalidation_version(document);+}++void HTMLCollection::update_cache_if_needed() const+{+ if (cache_is_valid())return;- }+ auto& document = root()->document();+ auto invalidation_version = this->invalidation_version(document);invalidate_cache();@@ -136,7 +140,6 @@ void HTMLCollection::update_cache_if_needed() constm_cached_document = document;m_cached_invalidation_version = invalidation_version;- ++m_cache_generation;document.register_valid_html_collection_cache(m_attribute_invalidation_type);m_root->register_html_collection_with_valid_cache(const_cast<HTMLCollection&>(*this));}diff --git a/Libraries/LibWeb/DOM/HTMLCollection.h b/Libraries/LibWeb/DOM/HTMLCollection.hindex 04d75f0821e..801839d803a 100644--- a/Libraries/LibWeb/DOM/HTMLCollection.h+++ b/Libraries/LibWeb/DOM/HTMLCollection.h@@ -94,11 +94,10 @@ private:friend class Node;friend class Web::Internals::Internals;- u64 cache_generation_for_testing() const { return m_cache_generation; }+ bool cache_is_valid() const;mutable GC::Weak<Document const> m_cached_document;mutable u64 m_cached_invalidation_version { 0 };- mutable u64 m_cache_generation { 0 };mutable Vector<GC::RawPtr<Element>> m_cached_elements;mutable OwnPtr<OrderedHashMap<Utf16FlyString, GC::RawPtr<Element>>> m_cached_name_to_element_mappings;diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cppindex e3b139748de..2a576e89631 100644--- a/Libraries/LibWeb/Internals/Internals.cpp+++ b/Libraries/LibWeb/Internals/Internals.cpp@@ -506,9 +506,9 @@ WebIDL::UnsignedLongLong Internals::message_port_pending_outgoing_message_count(return port.pending_outgoing_message_count();}-WebIDL::UnsignedLongLong Internals::html_collection_cache_generation(DOM::HTMLCollection& collection)+bool Internals::html_collection_has_valid_cache(DOM::HTMLCollection& collection){- return collection.cache_generation_for_testing();+ return collection.cache_is_valid();}void Internals::fail_next_message_port_transfer(HTML::MessagePort& port)@@ -2376,10 +2376,12 @@ i32 Internals::web_content_process_id()return Core::System::getpid();}-u32 Internals::document_count_in_this_process()+Vector<String> Internals::documents_in_this_process(){- auto documents = HTML::main_thread_event_loop().documents_in_this_event_loop_matching([](auto const&) { return true; });- return documents.size();+ Vector<String> urls;+ for (auto const& document : HTML::main_thread_event_loop().documents_in_this_event_loop_matching([](auto const&) { return true; }))+ urls.append(document->url().serialize());+ return urls;}void Internals::close_tab_through_ui_process()@@ -2692,9 +2694,12 @@ WebIDL::UnsignedLongLong Internals::audio_capture_stream_count()return Audio::ClientConnection::capture_stream_count_for_testing();}-WebIDL::UnsignedLongLong Internals::tab_audibility_change_count()+Vector<String> Internals::tab_audibility_transitions(){- return window().associated_document().page().client().page_did_request_tab_audibility_change_count_for_testing();+ Vector<String> transitions;+ for (auto shown : window().associated_document().page().client().page_did_request_tab_audibility_transitions_for_testing())+ transitions.append(shown ? "shown"_string : "hidden"_string);+ return transitions;}bool Internals::media_element_video_sink_is_ticking(HTML::HTMLMediaElement& element)@@ -3546,9 +3551,13 @@ Utf16String Internals::canvas_color_scheme()return CSS::preferred_color_scheme_to_utf16_fly_string(document.canvas_color_scheme(read)).to_utf16_string();}-u64 Internals::image_request_count(DOM::Document const& document) const+Vector<String> Internals::image_request_urls(DOM::Document const& document) const{- return document.shared_resource_requests().size();+ Vector<String> urls;+ for (auto const& request : document.shared_resource_requests())+ urls.append(request.key.url.serialize());+ quick_sort(urls);+ return urls;}WebIDL::ExceptionOr<GC::Ref<JS::Object>> Internals::image_animation_state_for_url(Utf16String const& url)diff --git a/Libraries/LibWeb/Internals/Internals.h b/Libraries/LibWeb/Internals/Internals.hindex e7c8a4c160f..e7125de9dcc 100644--- a/Libraries/LibWeb/Internals/Internals.h+++ b/Libraries/LibWeb/Internals/Internals.h@@ -75,7 +75,7 @@ public:bool wrapper_is_preserved(JS::Object&);bool has_pending_activity(JS::Object&, GC::Ptr<DOM::Document>);WebIDL::UnsignedLongLong message_port_pending_outgoing_message_count(HTML::MessagePort&);- WebIDL::UnsignedLongLong html_collection_cache_generation(DOM::HTMLCollection&);+ bool html_collection_has_valid_cache(DOM::HTMLCollection&);void fail_next_message_port_transfer(HTML::MessagePort&);bool message_ports_are_directly_entangled(HTML::MessagePort&, HTML::MessagePort&);String message_port_entanglement_kind(HTML::MessagePort&);@@ -254,7 +254,7 @@ public:bool canvas_has_unpresented_content(HTML::HTMLCanvasElement&);void crash_remote_frame_processes();i32 web_content_process_id();- u32 document_count_in_this_process();+ Vector<String> documents_in_this_process();void close_tab_through_ui_process();void stop_loading_through_ui_process();void reload_through_ui_process();@@ -351,7 +351,7 @@ public:WebIDL::UnsignedLongLong active_timer_count(JS::Object& window);WebIDL::UnsignedLongLong task_queue_length();Utf16String canvas_color_scheme();- u64 image_request_count(DOM::Document const&) const;+ Vector<String> image_request_urls(DOM::Document const&) const;WebIDL::ExceptionOr<GC::Ref<JS::Object>> image_animation_state_for_url(Utf16String const& url);bool media_element_is_fetching(HTML::HTMLMediaElement&);bool media_element_is_playing_audio(HTML::HTMLMediaElement&);@@ -365,7 +365,7 @@ public:void report_audio_capture_of_page(WebIDL::UnsignedLongLong page_id, bool capturing);void retire_picture_in_picture_window();WebIDL::UnsignedLongLong audio_capture_stream_count();- WebIDL::UnsignedLongLong tab_audibility_change_count();+ Vector<String> tab_audibility_transitions();bool media_element_video_sink_is_ticking(HTML::HTMLMediaElement&);void set_media_element_ready_state(HTML::HTMLMediaElement&, u16 ready_state);void set_media_element_paused(HTML::HTMLMediaElement&, bool paused);diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idlindex 91289395acc..c3c42eb840a 100644--- a/Libraries/LibWeb/Internals/Internals.idl+++ b/Libraries/LibWeb/Internals/Internals.idl@@ -44,7 +44,8 @@ interface Internals {// Asks the global of the given document, or else the global of the object's realm.boolean hasPendingActivity(object object, optional Document document);unsigned long long messagePortPendingOutgoingMessageCount(MessagePort port);- unsigned long long htmlCollectionCacheGeneration(HTMLCollection collection);+ // Whether the collection holds the elements it collected, which a mutation that may change them discards.+ boolean htmlCollectionHasValidCache(HTMLCollection collection);undefined failNextMessagePortTransfer(MessagePort port);boolean messagePortsAreDirectlyEntangled(MessagePort first, MessagePort second);DOMString messagePortEntanglementKind(MessagePort port);@@ -282,8 +283,8 @@ interface Internals {boolean canvasHasUnpresentedContent(HTMLCanvasElement canvas);undefined crashRemoteFrameProcesses();long webContentProcessId();- // The documents this process has not collected yet, whether or not they are still displayed.- unsigned long documentCountInThisProcess();+ // The URLs of the documents this process has not collected yet, whether or not they are still displayed.+ sequence<USVString> documentsInThisProcess();// Closes this tab as the browser's close button does when it has no beforeunload check to run.undefined closeTabThroughUIProcess();// Stops loading and reloads as the browser's Stop and Reload buttons do.@@ -473,8 +474,8 @@ interface Internals {// Returns how many tasks sit in the main thread event loop's task queue, runnable or not.unsigned long long taskQueueLength();DOMString canvasColorScheme();- // Returns the number of shared image requests owned by the given document.- unsigned long long imageRequestCount(Document document);+ // The URLs of the shared image requests the given document owns, sorted.+ [ImplementedAs=image_request_urls] sequence<USVString> imageRequestURLs(Document document);// Returns the selector-insight cache state for stylesheet invalidation tests.object imageAnimationStateForURL(USVString url);boolean mediaElementIsFetching(HTMLMediaElement element);@@ -500,8 +501,8 @@ interface Internals {undefined retirePictureInPictureWindow();// How many streams this process's tracks hold of the capture sources it has open.unsigned long long audioCaptureStreamCount();- // How many times the UI process has changed whether this window's tab is shown as playing audio.- unsigned long long tabAudibilityChangeCount();+ // Each change of whether the UI process shows this window's tab as playing audio, in order: "shown" or "hidden".+ sequence<DOMString> tabAudibilityTransitions();boolean mediaElementVideoSinkIsTicking(HTMLMediaElement element);undefined setMediaElementReadyState(HTMLMediaElement element, unsigned short readyState);undefined setMediaElementPaused(HTMLMediaElement element, boolean paused);diff --git a/Libraries/LibWeb/Page/Page.h b/Libraries/LibWeb/Page/Page.hindex 15d9b112826..b0d8581d6b7 100644--- a/Libraries/LibWeb/Page/Page.h+++ b/Libraries/LibWeb/Page/Page.h@@ -924,7 +924,7 @@ public:virtual bool page_did_request_tab_is_capturing_audio_for_testing() { return false; }virtual void page_did_report_audio_capture_for_testing([[maybe_unused]] Web::PageId labelled_page_id, [[maybe_unused]] bool capturing) { }virtual void page_did_retire_picture_in_picture_window_for_testing() { }- virtual u64 page_did_request_tab_audibility_change_count_for_testing() { return 0; }+ virtual Vector<bool> page_did_request_tab_audibility_transitions_for_testing() { return {}; }virtual bool page_did_request_capture_session_history_snapshot_for_testing() { return false; }virtual bool page_did_request_restore_session_history_snapshot_for_testing() { return false; }virtual bool page_did_request_record_reported_session_history_for_testing() { return false; }diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cppindex 59a3f35b045..7163c2d1f7a 100644--- a/Libraries/LibWebView/ViewImplementation.cpp+++ b/Libraries/LibWebView/ViewImplementation.cpp@@ -121,7 +121,7 @@ ViewImplementation::ViewImplementation(IsPrivate is_private)m_tab_indicators.on_visibility_change = [this](TabIndicator indicator, bool visible) {if (indicator == TabIndicator::PlayingAudio)- ++m_playing_audio_indicator_change_count;+ m_playing_audio_indicator_transitions.append(visible);if (on_tab_indicator_change)on_tab_indicator_change(indicator, visible);};diff --git a/Libraries/LibWebView/ViewImplementation.h b/Libraries/LibWebView/ViewImplementation.hindex aef42cea855..c242075bc4f 100644--- a/Libraries/LibWebView/ViewImplementation.h+++ b/Libraries/LibWebView/ViewImplementation.h@@ -541,7 +541,7 @@ public:bool is_capturing_audio() const { return m_tab_indicators.is_active(TabIndicator::UsingMicrophone); }bool tab_indicator_visible(TabIndicator indicator) const { return m_tab_indicators.is_visible(indicator); }- u64 playing_audio_indicator_change_count() const { return m_playing_audio_indicator_change_count; }+ Vector<bool> const& playing_audio_indicator_transitions() const { return m_playing_audio_indicator_transitions; }void did_change_screen_wake_lock_state(Badge<WebContentPage>, Web::ScreenWakeLockState);void did_reset_state_for_testing(Badge<WebContentPage>, Web::HTML::SessionHistoryEntryDescriptor);@@ -1134,7 +1134,7 @@ protected:Optional<Web::HTML::CrossProcessId> m_webdriver_current_parent_navigable_id;TabIndicators m_tab_indicators;- u64 m_playing_audio_indicator_change_count { 0 };+ Vector<bool> m_playing_audio_indicator_transitions;Web::ScreenWakeLockState m_screen_wake_lock_state { Web::ScreenWakeLockState::Released };Web::HTML::MuteState m_mute_state { Web::HTML::MuteState::Unmuted };diff --git a/Libraries/LibWebView/WebContentPage.cpp b/Libraries/LibWebView/WebContentPage.cppindex 880c98b9c8d..e8bdc26def6 100644--- a/Libraries/LibWebView/WebContentPage.cpp+++ b/Libraries/LibWebView/WebContentPage.cpp@@ -3544,10 +3544,10 @@ void WebContentPage::retire_picture_in_picture_window_for_testing()PictureInPictureManager::the().close_window(*this);}-Messages::WebContentTestClient::DidRequestTabAudibilityChangeCountForTestingResponse WebContentPage::did_request_tab_audibility_change_count_for_testing()+Messages::WebContentTestClient::DidRequestTabAudibilityTransitionsForTestingResponse WebContentPage::did_request_tab_audibility_transitions_for_testing(){auto view = traversable().view();- return view.has_value() ? view->playing_audio_indicator_change_count() : 0;+ return view.has_value() ? view->playing_audio_indicator_transitions() : Vector<bool> {};}void WebContentPage::did_request_close_tab_for_testing()diff --git a/Libraries/LibWebView/WebContentPage.h b/Libraries/LibWebView/WebContentPage.hindex 2ad4f4dbaaf..9a9a1bd3302 100644--- a/Libraries/LibWebView/WebContentPage.h+++ b/Libraries/LibWebView/WebContentPage.h@@ -414,7 +414,7 @@ private:Messages::WebContentTestClient::DidRequestTabIsCapturingAudioForTestingResponse did_request_tab_is_capturing_audio_for_testing();void report_audio_capture_for_testing(Web::PageId labelled_page_id, bool capturing);void retire_picture_in_picture_window_for_testing();- Messages::WebContentTestClient::DidRequestTabAudibilityChangeCountForTestingResponse did_request_tab_audibility_change_count_for_testing();+ Messages::WebContentTestClient::DidRequestTabAudibilityTransitionsForTestingResponse did_request_tab_audibility_transitions_for_testing();virtual void did_request_crash_of_remote_frame_processes_for_testing() override;virtual void did_request_close_tab_for_testing() override;virtual void did_request_stop_loading_for_testing() override;diff --git a/Libraries/LibWebView/WebContentTestClient.cpp b/Libraries/LibWebView/WebContentTestClient.cppindex fb499d176c0..45c447ba3fe 100644--- a/Libraries/LibWebView/WebContentTestClient.cpp+++ b/Libraries/LibWebView/WebContentTestClient.cpp@@ -165,12 +165,12 @@ void WebContentTestClient::retire_picture_in_picture_window_for_testing(Web::Pagpage->retire_picture_in_picture_window_for_testing();}-Messages::WebContentTestClient::DidRequestTabAudibilityChangeCountForTestingResponse WebContentTestClient::did_request_tab_audibility_change_count_for_testing(Web::PageId page_id)+Messages::WebContentTestClient::DidRequestTabAudibilityTransitionsForTestingResponse WebContentTestClient::did_request_tab_audibility_transitions_for_testing(Web::PageId page_id){if (auto* page = m_client.page(page_id))- return page->did_request_tab_audibility_change_count_for_testing();+ return page->did_request_tab_audibility_transitions_for_testing();- return 0;+ return Vector<bool> {};}Messages::WebContentTestClient::DidRequestHasPopulatedDocumentForTestingResponse WebContentTestClient::did_request_has_populated_document_for_testing(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id)diff --git a/Libraries/LibWebView/WebContentTestClient.h b/Libraries/LibWebView/WebContentTestClient.hindex 10502a966c6..9357b0d366b 100644--- a/Libraries/LibWebView/WebContentTestClient.h+++ b/Libraries/LibWebView/WebContentTestClient.h@@ -43,7 +43,7 @@ private:virtual Messages::WebContentTestClient::DidRequestTabIsCapturingAudioForTestingResponse did_request_tab_is_capturing_audio_for_testing(Web::PageId page_id) override;virtual void report_audio_capture_for_testing(Web::PageId page_id, Web::PageId labelled_page_id, bool capturing) override;virtual void retire_picture_in_picture_window_for_testing(Web::PageId page_id) override;- virtual Messages::WebContentTestClient::DidRequestTabAudibilityChangeCountForTestingResponse did_request_tab_audibility_change_count_for_testing(Web::PageId page_id) override;+ virtual Messages::WebContentTestClient::DidRequestTabAudibilityTransitionsForTestingResponse did_request_tab_audibility_transitions_for_testing(Web::PageId page_id) override;virtual Messages::WebContentTestClient::DidRequestHasPopulatedDocumentForTestingResponse did_request_has_populated_document_for_testing(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) override;virtual Messages::WebContentTestClient::DidRequestCaptureSessionHistorySnapshotForTestingResponse did_request_capture_session_history_snapshot_for_testing(Web::PageId page_id) override;virtual Messages::WebContentTestClient::DidRequestRestoreSessionHistorySnapshotForTestingResponse did_request_restore_session_history_snapshot_for_testing(Web::PageId page_id) override;diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cppindex 2c38cef4c37..7a89ae96509 100644--- a/Services/WebContent/PageClient.cpp+++ b/Services/WebContent/PageClient.cpp@@ -1987,11 +1987,11 @@ void PageClient::page_did_retire_picture_in_picture_window_for_testing()(void)test_connection->send_sync_but_allow_failure<Messages::WebContentTestClient::RetirePictureInPictureWindowForTesting>(m_id);}-u64 PageClient::page_did_request_tab_audibility_change_count_for_testing()+Vector<bool> PageClient::page_did_request_tab_audibility_transitions_for_testing(){if (auto* test_connection = client().test_connection())- return test_connection->did_request_tab_audibility_change_count_for_testing(m_id);- return 0;+ return test_connection->did_request_tab_audibility_transitions_for_testing(m_id);+ return {};}String PageClient::dump_site_isolation_process_tree_for_testing()diff --git a/Services/WebContent/PageClient.h b/Services/WebContent/PageClient.hindex 77b32a3a0d5..23602057612 100644--- a/Services/WebContent/PageClient.h+++ b/Services/WebContent/PageClient.h@@ -350,7 +350,7 @@ private:virtual bool page_did_request_tab_is_capturing_audio_for_testing() override;virtual void page_did_report_audio_capture_for_testing(Web::PageId labelled_page_id, bool capturing) override;virtual void page_did_retire_picture_in_picture_window_for_testing() override;- virtual u64 page_did_request_tab_audibility_change_count_for_testing() override;+ virtual Vector<bool> page_did_request_tab_audibility_transitions_for_testing() override;virtual bool page_did_request_capture_session_history_snapshot_for_testing() override;virtual bool page_did_request_restore_session_history_snapshot_for_testing() override;virtual bool page_did_request_record_reported_session_history_for_testing() override;diff --git a/Services/WebContent/WebContentTestClient.ipc b/Services/WebContent/WebContentTestClient.ipcindex 7127a66454f..c646e68278a 100644--- a/Services/WebContent/WebContentTestClient.ipc+++ b/Services/WebContent/WebContentTestClient.ipc@@ -36,7 +36,7 @@ endpoint WebContentTestClient routed by Web::PageId page_id[NotRouted] did_request_tab_is_capturing_audio_for_testing(Web::PageId page_id) => (bool is_capturing_audio)[NotRouted] report_audio_capture_for_testing(Web::PageId page_id, Web::PageId labelled_page_id, bool capturing) => ()[NotRouted] retire_picture_in_picture_window_for_testing(Web::PageId page_id) => ()- [NotRouted] did_request_tab_audibility_change_count_for_testing(Web::PageId page_id) => (u64 change_count)+ [NotRouted] did_request_tab_audibility_transitions_for_testing(Web::PageId page_id) => (Vector<bool> transitions)[NotRouted] did_request_has_populated_document_for_testing(Web::PageId page_id, Web::HTML::CrossProcessId navigable_id) => (bool has_populated_document)did_request_crash_of_remote_frame_processes_for_testing(Web::PageId page_id) =|did_request_close_tab_for_testing(Web::PageId page_id) =|diff --git a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-keeps-playing-audio-heard-after-an-isolated-iframe-leaves.txt b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-keeps-playing-audio-heard-after-an-isolated-iframe-leaves.txtindex 5cbdfd26b19..9ac4749f61f 100644--- a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-keeps-playing-audio-heard-after-an-isolated-iframe-leaves.txt+++ b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-keeps-playing-audio-heard-after-an-isolated-iframe-leaves.txt@@ -3,4 +3,4 @@ stops being heard once the iframe is gone: trueis heard playing audio in this document: trueplays audio after it would have stopped: truestops playing audio once nothing is heard: true-changed whether it plays audio once: true+playing audio indicator: shown, hiddendiff --git a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-keeps-playing-audio-of-a-navigated-isolated-iframe-through-a-crash.txt b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-keeps-playing-audio-of-a-navigated-isolated-iframe-through-a-crash.txtindex 7428dc2783f..6d91c2d459f 100644--- a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-keeps-playing-audio-of-a-navigated-isolated-iframe-through-a-crash.txt+++ b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-keeps-playing-audio-of-a-navigated-isolated-iframe-through-a-crash.txt@@ -2,4 +2,4 @@ plays audio heard in the isolated iframe: truethe iframe's next process is gone: truestops playing audio a while later: truewent on playing audio for at least two and a half seconds after navigating: true-changed whether it plays audio once: true+playing audio indicator: shown, hiddendiff --git a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-plays-audio-heard-in-an-isolated-iframe.txt b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-plays-audio-heard-in-an-isolated-iframe.txtindex aa693875a33..ef9705ae035 100644--- a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-plays-audio-heard-in-an-isolated-iframe.txt+++ b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-plays-audio-heard-in-an-isolated-iframe.txt@@ -3,4 +3,4 @@ WebContent#0iframe#0: remote WebContent#1stops playing audio once the iframe is gone: truewent on playing audio for at least two and a half seconds: true-changed whether it plays audio once: true+playing audio indicator: shown, hiddendiff --git a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-stops-playing-audio-of-a-crashed-isolated-iframe.txt b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-stops-playing-audio-of-a-crashed-isolated-iframe.txtindex 108ef12b61e..4ba236e0761 100644--- a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-stops-playing-audio-of-a-crashed-isolated-iframe.txt+++ b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/tab-stops-playing-audio-of-a-crashed-isolated-iframe.txt@@ -2,7 +2,7 @@ plays audio heard in the isolated iframe: truestops being heard once the iframe's process is gone: truestops playing audio a while later: truewent on playing audio for at least two and a half seconds after the crash: true-changed whether it plays audio once: true+playing audio indicator: shown, hiddenis heard playing audio in this document: trueits process is gone: trueis still heard playing audio in this document: truediff --git a/Tests/LibWeb/Text/expected/SiteIsolation/tab-closed-through-ui-process-is-torn-down.txt b/Tests/LibWeb/Text/expected/SiteIsolation/tab-closed-through-ui-process-is-torn-down.txtindex 49880a65b5f..9ff6c94bec4 100644--- a/Tests/LibWeb/Text/expected/SiteIsolation/tab-closed-through-ui-process-is-torn-down.txt+++ b/Tests/LibWeb/Text/expected/SiteIsolation/tab-closed-through-ui-process-is-torn-down.txt@@ -1,10 +1,12 @@closed through the UI process: blob URL resolves while open: true-closed through the UI process: documents collected: true+closed through the UI process: documents of the tab while open: 1+closed through the UI process: documents of the tab left: []closed through the UI process: tab stopped: trueclosed through the UI process: worker stopped: trueclosed through the UI process: blob URL revoked: trueclosed by script: blob URL resolves while open: true-closed by script: documents collected: true+closed by script: documents of the tab while open: 1+closed by script: documents of the tab left: []closed by script: tab stopped: trueclosed by script: worker stopped: trueclosed by script: blob URL revoked: truediff --git a/Tests/LibWeb/Text/expected/SiteIsolation/tab-keeps-playing-audio-a-while-after-a-cross-site-navigation.txt b/Tests/LibWeb/Text/expected/SiteIsolation/tab-keeps-playing-audio-a-while-after-a-cross-site-navigation.txtindex b46b4de3163..e5c6572e3cc 100644--- a/Tests/LibWeb/Text/expected/SiteIsolation/tab-keeps-playing-audio-a-while-after-a-cross-site-navigation.txt+++ b/Tests/LibWeb/Text/expected/SiteIsolation/tab-keeps-playing-audio-a-while-after-a-cross-site-navigation.txt@@ -2,4 +2,4 @@ the popup's tab plays audio heard in another processplays audio once navigated to this site: truestops playing audio a while later: truewent on playing audio for at least two and a half seconds after navigating: true-changed whether it plays audio once: true+playing audio indicator: shown, hiddendiff --git a/Tests/LibWeb/Text/expected/css/inactive-document-css-images.txt b/Tests/LibWeb/Text/expected/css/inactive-document-css-images.txtindex d69f66010d6..9ed26042bdb 100644--- a/Tests/LibWeb/Text/expected/css/inactive-document-css-images.txt+++ b/Tests/LibWeb/Text/expected/css/inactive-document-css-images.txt@@ -1,3 +1,3 @@-imported inline image requests: 0-inactive stylesheet image requests: 0-images requested after adoption: 2+imported inline image requests: []+inactive stylesheet image requests: []+images requested after adoption: [inline, stylesheet]diff --git a/Tests/LibWeb/Text/input/DOM/HTMLCollection-live-mutations.html b/Tests/LibWeb/Text/input/DOM/HTMLCollection-live-mutations.htmlindex e1487de5dbe..47aa219c37d 100644--- a/Tests/LibWeb/Text/input/DOM/HTMLCollection-live-mutations.html+++ b/Tests/LibWeb/Text/input/DOM/HTMLCollection-live-mutations.html@@ -27,15 +27,16 @@const children = root.children;println(`initial children: ${Array.from(children, element => element.id)}`);- const initialGeneration = internals.htmlCollectionCacheGeneration(children);first.append(document.createTextNode("text"), document.createElement("span"));- println(`after descendant insertion: ${Array.from(children, element => element.id)}, cache preserved: ${internals.htmlCollectionCacheGeneration(children) === initialGeneration}`);+ const cachePreserved = internals.htmlCollectionHasValidCache(children);+ println(`after descendant insertion: ${Array.from(children, element => element.id)}, cache preserved: ${cachePreserved}`);const third = document.createElement("div");third.id = "third";root.append(third);- println(`after child insertion: ${Array.from(children, element => element.id)}, cache rebuilt: ${internals.htmlCollectionCacheGeneration(children) > initialGeneration}`);+ const cacheInvalidated = !internals.htmlCollectionHasValidCache(children);+ println(`after child insertion: ${Array.from(children, element => element.id)}, cache rebuilt: ${cacheInvalidated}`);root.moveBefore(third, first);println(`after atomic move: ${Array.from(children, element => element.id)}`);@@ -48,18 +49,17 @@const firstRow = rows[0];const cells = firstRow.cells;const firstText = cells[0].firstChild;- const rowsGeneration = internals.htmlCollectionCacheGeneration(rows);- const cellsGeneration = internals.htmlCollectionCacheGeneration(cells);cells[0].removeChild(firstText);cells[1].appendChild(firstText);+ const rowsCachePreserved = internals.htmlCollectionHasValidCache(rows);+ const cellsCachePreserved = internals.htmlCollectionHasValidCache(cells);- println(`rows after text move: ${rows.length}, same first row: ${rows[0] === firstRow}, cache preserved: ${internals.htmlCollectionCacheGeneration(rows) === rowsGeneration}`);- println(`cells after text move: ${cells.length}, same first cell: ${cells[0] === firstRow.firstElementChild}, cache preserved: ${internals.htmlCollectionCacheGeneration(cells) === cellsGeneration}`);+ println(`rows after text move: ${rows.length}, same first row: ${rows[0] === firstRow}, cache preserved: ${rowsCachePreserved}`);+ println(`cells after text move: ${cells.length}, same first cell: ${cells[0] === firstRow.firstElementChild}, cache preserved: ${cellsCachePreserved}`);firstRow.id = "first-row";- rows.length;- println(`rows after attribute change: cache preserved: ${internals.htmlCollectionCacheGeneration(rows) === rowsGeneration}`);+ println(`rows after attribute change: cache preserved: ${internals.htmlCollectionHasValidCache(rows)}`);}{@@ -92,12 +92,14 @@const moved = source.firstElementChild;const sourceChildren = source.children;const destinationChildren = destination.children;- const sourceGeneration = internals.htmlCollectionCacheGeneration(sourceChildren);- const destinationGeneration = internals.htmlCollectionCacheGeneration(destinationChildren);+ sourceChildren.length;+ destinationChildren.length;destination.moveBefore(moved, null);+ const sourceCacheInvalidated = !internals.htmlCollectionHasValidCache(sourceChildren);+ const destinationCacheInvalidated = !internals.htmlCollectionHasValidCache(destinationChildren);println(`after cross-root move: source=${Array.from(sourceChildren, element => element.id)}, destination=${Array.from(destinationChildren, element => element.id)}`);- println(`cross-root caches rebuilt: source=${internals.htmlCollectionCacheGeneration(sourceChildren) > sourceGeneration}, destination=${internals.htmlCollectionCacheGeneration(destinationChildren) > destinationGeneration}`);+ println(`cross-root caches rebuilt: source=${sourceCacheInvalidated}, destination=${destinationCacheInvalidated}`);}{@@ -109,19 +111,17 @@document.body.append(root);println(`initial attribute collections: class=${byClass.length}, link=${document.links.length}`);- const initialClassGeneration = internals.htmlCollectionCacheGeneration(byClass);candidate.title = "irrelevant";- byClass.length;- println(`after irrelevant attribute: cache preserved=${internals.htmlCollectionCacheGeneration(byClass) === initialClassGeneration}`);+ println(`after irrelevant attribute: cache preserved=${internals.htmlCollectionHasValidCache(byClass)}`);candidate.className = "wanted";candidate.href = "https://example.com/";candidate.name = "named";println(`after matching attributes: class=${byClass.length}, link=${document.links.length}, anchor=${document.anchors.length}`);println(`named candidate: ${links.namedItem("candidate") === candidate}`);- const linksGeneration = internals.htmlCollectionCacheGeneration(links);candidate.id = "renamed";- println(`after id change: old=${links.namedItem("candidate")}, new=${links.namedItem("renamed") === candidate}, cache preserved=${internals.htmlCollectionCacheGeneration(links) === linksGeneration}`);+ const linksCachePreserved = internals.htmlCollectionHasValidCache(links);+ println(`after id change: old=${links.namedItem("candidate")}, new=${links.namedItem("renamed") === candidate}, cache preserved=${linksCachePreserved}`);candidate.name = "aliased";println(`after name change: old=${links.namedItem("named")}, new=${links.namedItem("aliased") === candidate}, anchor=${document.anchors.length}`);@@ -140,13 +140,14 @@const direct = root.firstElementChild;const nested = direct.firstElementChild;println(`initial scoped names: direct=${children.namedItem("direct") === direct}, nested=${children.namedItem("nested")}`);- const generation = internals.htmlCollectionCacheGeneration(children);nested.id = "nested-renamed";- println(`after nested ID change: nested=${children.namedItem("nested-renamed")}, cache preserved=${internals.htmlCollectionCacheGeneration(children) === generation}`);+ let cachePreserved = internals.htmlCollectionHasValidCache(children);+ println(`after nested ID change: nested=${children.namedItem("nested-renamed")}, cache preserved=${cachePreserved}`);direct.id = "direct-renamed";- println(`after direct ID change: old=${children.namedItem("direct")}, new=${children.namedItem("direct-renamed") === direct}, cache preserved=${internals.htmlCollectionCacheGeneration(children) === generation}`);+ cachePreserved = internals.htmlCollectionHasValidCache(children);+ println(`after direct ID change: old=${children.namedItem("direct")}, new=${children.namedItem("direct-renamed") === direct}, cache preserved=${cachePreserved}`);}{diff --git a/Tests/LibWeb/Text/input/DOM/HTMLCollection-named-property-masks.html b/Tests/LibWeb/Text/input/DOM/HTMLCollection-named-property-masks.htmlindex 793779f4881..8fb849c21ca 100644--- a/Tests/LibWeb/Text/input/DOM/HTMLCollection-named-property-masks.html+++ b/Tests/LibWeb/Text/input/DOM/HTMLCollection-named-property-masks.html@@ -14,7 +14,7 @@`built-in length masks a supported name: ${Object.getOwnPropertyDescriptor(collection, "length") === undefined}`);println(- `built-in mask avoids cache rebuilding: ${internals.htmlCollectionCacheGeneration(collection) === 0}`+ `built-in mask avoids cache rebuilding: ${!internals.htmlCollectionHasValidCache(collection)}`);println(`initial length: ${collection.length}`);println(`unmasked supported name: ${collection.supported === element}`);@@ -40,7 +40,7 @@`ordinary mask of unsupported name: ${Object.getOwnPropertyDescriptor(collection, "missing") === undefined}`);println(- `ordinary masks avoid cache rebuilding: ${internals.htmlCollectionCacheGeneration(collection) === 0}`+ `ordinary masks avoid cache rebuilding: ${!internals.htmlCollectionHasValidCache(collection)}`);delete prototype.supported;println(`name exposed after deleting mask: ${collection.supported === element}`);@@ -78,7 +78,7 @@);println(`masked names avoid proxy traps: ${traps.length === 0}`);println(- `masked names avoid cache rebuilding: ${internals.htmlCollectionCacheGeneration(collection) === 0}`+ `masked names avoid cache rebuilding: ${!internals.htmlCollectionHasValidCache(collection)}`);Object.getOwnPropertyDescriptor(collection, "unlisted");println(`unsupported unmasked name avoids proxy traps: ${traps.length === 0}`);@@ -115,7 +115,7 @@Object.setPrototypeOf(collection, prototype);println(`exotic prototype mask: ${Object.getOwnPropertyDescriptor(collection, "supported") === undefined}`);println(- `exotic prototype keeps normal visibility checks: ${internals.htmlCollectionCacheGeneration(collection) === 1}`+ `exotic prototype keeps normal visibility checks: ${internals.htmlCollectionHasValidCache(collection)}`);}diff --git a/Tests/LibWeb/Text/input/HTML/HTMLFormControlsCollection-live-mutations.html b/Tests/LibWeb/Text/input/HTML/HTMLFormControlsCollection-live-mutations.htmlindex 186eced7f94..cd676631a0b 100644--- a/Tests/LibWeb/Text/input/HTML/HTMLFormControlsCollection-live-mutations.html+++ b/Tests/LibWeb/Text/input/HTML/HTMLFormControlsCollection-live-mutations.html@@ -19,17 +19,17 @@const secondControls = secondForm.elements;println(`initial: first=${firstControls.length}, second=${secondControls.length}, owner=${control.form.id}`);- let generation = internals.htmlCollectionCacheGeneration(firstControls);firstForm.id = "renamed";- println(`after form ID change: first=${firstControls.length}, owner=${control.form}, cache rebuilt=${internals.htmlCollectionCacheGeneration(firstControls) > generation}`);+ const invalidatedByRename = !internals.htmlCollectionHasValidCache(firstControls);+ println(`after form ID change: first=${firstControls.length}, owner=${control.form}, cache rebuilt=${invalidatedByRename}`);firstForm.id = "first";println(`after restoring form ID: first=${firstControls.length}, owner=${control.form.id}`);- generation = internals.htmlCollectionCacheGeneration(firstControls);blocker.id = "first";- println(`after introducing earlier matching ID: first=${firstControls.length}, owner=${control.form}, cache rebuilt=${internals.htmlCollectionCacheGeneration(firstControls) > generation}`);+ const invalidatedByEarlierMatch = !internals.htmlCollectionHasValidCache(firstControls);+ println(`after introducing earlier matching ID: first=${firstControls.length}, owner=${control.form}, cache rebuilt=${invalidatedByEarlierMatch}`);blocker.id = "blocker";println(`after removing earlier matching ID: first=${firstControls.length}, owner=${control.form.id}`);@@ -37,9 +37,9 @@control.setAttribute("form", "second");println(`after changing form attribute: first=${firstControls.length}, second=${secondControls.length}, owner=${control.form.id}`);- generation = internals.htmlCollectionCacheGeneration(secondControls);control.type = "image";- println(`after changing type to image: second=${secondControls.length}, cache rebuilt=${internals.htmlCollectionCacheGeneration(secondControls) > generation}`);+ const cacheInvalidated = !internals.htmlCollectionHasValidCache(secondControls);+ println(`after changing type to image: second=${secondControls.length}, cache rebuilt=${cacheInvalidated}`);control.type = "text";println(`after restoring type: second=${secondControls.length}`);diff --git a/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-keeps-playing-audio-heard-after-an-isolated-iframe-leaves.html b/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-keeps-playing-audio-heard-after-an-isolated-iframe-leaves.htmlindex 90aa2eb0eeb..bf0f8db465c 100644--- a/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-keeps-playing-audio-heard-after-an-isolated-iframe-leaves.html+++ b/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-keeps-playing-audio-heard-after-an-isolated-iframe-leaves.html@@ -13,6 +13,7 @@internals.setTestTimeout(30_000);// The tab can still be remembered as playing a previous test's sound.await waitForCondition(() => !internals.tabIsPlayingAudio());+ const earlierTransitions = internals.tabAudibilityTransitions().length;const httpServer = httpTestServer();// This document's audio runs silently from the start, so its sound is heard as soon as it is let through.@@ -39,7 +40,6 @@// This document's sound starts while the tab goes on playing the sound of the iframe's page that left it, and// keeps the tab playing audio past when it would have stopped.- const changes = internals.tabAudibilityChangeCount();iframe.remove();println(`stops being heard once the iframe is gone: ${await waitForCondition(() => !internals.tabIsHeardPlayingAudio())}`);const leftAt = performance.now();@@ -52,6 +52,6 @@await context.close();println(`stops playing audio once nothing is heard: ${await waitForCondition(() => !internals.tabIsPlayingAudio())}`);- println(`changed whether it plays audio once: ${internals.tabAudibilityChangeCount() - changes === 1}`);+ println(`playing audio indicator: ${internals.tabAudibilityTransitions().slice(earlierTransitions).join(", ")}`);});</script>diff --git a/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-keeps-playing-audio-of-a-navigated-isolated-iframe-through-a-crash.html b/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-keeps-playing-audio-of-a-navigated-isolated-iframe-through-a-crash.htmlindex ccd726905d8..2a881229749 100644--- a/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-keeps-playing-audio-of-a-navigated-isolated-iframe-through-a-crash.html+++ b/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-keeps-playing-audio-of-a-navigated-isolated-iframe-through-a-crash.html@@ -5,6 +5,7 @@internals.setTestTimeout(30_000);// The tab can still be remembered as playing a previous test's sound.await waitForCondition(() => !internals.tabIsPlayingAudio());+ const earlierTransitions = internals.tabAudibilityTransitions().length;const httpServer = httpTestServer();const nextMessage = () => new Promise(resolve => addEventListener("message", event => resolve(event.data), { once: true }));@@ -35,7 +36,6 @@// The iframe's page leaves the tab while it is heard, as the iframe navigates to another site. Losing the process// of the iframe's next document doesn't cut short how long the tab goes on playing audio.- const changes = internals.tabAudibilityChangeCount();const arrived = nextMessage();const navigatedAt = performance.now();iframe.src = nextUrl;@@ -45,6 +45,6 @@println(`stops playing audio a while later: ${await waitForCondition(() => !internals.tabIsPlayingAudio())}`);const heldFor = performance.now() - navigatedAt;println(`went on playing audio for at least two and a half seconds after navigating: ${heldFor >= 2500}`);- println(`changed whether it plays audio once: ${internals.tabAudibilityChangeCount() - changes === 1}`);+ println(`playing audio indicator: ${internals.tabAudibilityTransitions().slice(earlierTransitions).join(", ")}`);});</script>diff --git a/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-plays-audio-heard-in-an-isolated-iframe.html b/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-plays-audio-heard-in-an-isolated-iframe.htmlindex 86984c0e7b6..11259eb4942 100644--- a/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-plays-audio-heard-in-an-isolated-iframe.html+++ b/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-plays-audio-heard-in-an-isolated-iframe.html@@ -5,6 +5,7 @@internals.setTestTimeout(20_000);// The tab can still be remembered as playing a previous test's sound.await waitForCondition(() => !internals.tabIsPlayingAudio());+ const earlierTransitions = internals.tabAudibilityTransitions().length;const httpServer = httpTestServer();const childUrl = new URL(await httpServer.createEcho("GET", "/tab-plays-audio-heard-in-an-isolated-iframe-child", {@@ -28,12 +29,11 @@// The iframe's page leaves the tab while it is heard, so the tab goes on playing audio as though the page's// sound had stopped as it left.- const changes = internals.tabAudibilityChangeCount();const removedAt = performance.now();iframe.remove();println(`stops playing audio once the iframe is gone: ${await waitForCondition(() => !internals.tabIsPlayingAudio())}`);const heldFor = performance.now() - removedAt;println(`went on playing audio for at least two and a half seconds: ${heldFor >= 2500}`);- println(`changed whether it plays audio once: ${internals.tabAudibilityChangeCount() - changes === 1}`);+ println(`playing audio indicator: ${internals.tabAudibilityTransitions().slice(earlierTransitions).join(", ")}`);});</script>diff --git a/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-stops-playing-audio-of-a-crashed-isolated-iframe.html b/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-stops-playing-audio-of-a-crashed-isolated-iframe.htmlindex 28bf0fabbfc..813ce1b3fc7 100644--- a/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-stops-playing-audio-of-a-crashed-isolated-iframe.html+++ b/Tests/LibWeb/Text/input/SiteIsolation/iframe/tab-stops-playing-audio-of-a-crashed-isolated-iframe.html@@ -13,6 +13,7 @@internals.setTestTimeout(30_000);// The tab can still be remembered as playing a previous test's sound.await waitForCondition(() => !internals.tabIsPlayingAudio());+ const earlierTransitions = internals.tabAudibilityTransitions().length;const httpServer = httpTestServer();const appendPlayingIframe = async name => {const url = new URL(@@ -34,14 +35,13 @@// as it does whenever its sound stops.await appendPlayingIframe("tab-stops-playing-audio-of-a-crashed-isolated-iframe");println(`plays audio heard in the isolated iframe: ${await waitForCondition(() => internals.tabIsPlayingAudio())}`);- const changes = internals.tabAudibilityChangeCount();const crashedAt = performance.now();internals.crashRemoteFrameProcesses();println(`stops being heard once the iframe's process is gone: ${await waitForCondition(() => !internals.tabIsHeardPlayingAudio())}`);println(`stops playing audio a while later: ${await waitForCondition(() => !internals.tabIsPlayingAudio())}`);const heldFor = performance.now() - crashedAt;println(`went on playing audio for at least two and a half seconds after the crash: ${heldFor >= 2500}`);- println(`changed whether it plays audio once: ${internals.tabAudibilityChangeCount() - changes === 1}`);+ println(`playing audio indicator: ${internals.tabAudibilityTransitions().slice(earlierTransitions).join(", ")}`);// The sound of the tab's other pages goes on being heard.const context = play();diff --git a/Tests/LibWeb/Text/input/SiteIsolation/tab-closed-through-ui-process-is-torn-down.html b/Tests/LibWeb/Text/input/SiteIsolation/tab-closed-through-ui-process-is-torn-down.htmlindex afb30b36bee..462a60c9531 100644--- a/Tests/LibWeb/Text/input/SiteIsolation/tab-closed-through-ui-process-is-torn-down.html+++ b/Tests/LibWeb/Text/input/SiteIsolation/tab-closed-through-ui-process-is-torn-down.html@@ -5,28 +5,17 @@promiseTest(async () => {const httpServer = httpTestServer();+ const documentsOfTheTab = channelName => internals.documentsInThisProcess().filter(url => url.includes(channelName));+// A collection sweeps in slices, so a document goes some time after it. Collecting away from this script's stack// keeps a stale value on that stack from keeping a closed tab's objects alive.- const settledDocumentCount = async () => {- let count = internals.documentCountInThisProcess();- for (let stableRounds = 0; stableRounds < 10; ++stableRounds) {- await internals.gcAsync();- await timeout(20);- if (internals.documentCountInThisProcess() !== count) {- count = internals.documentCountInThisProcess();- stableRounds = 0;- }- }- return count;- };-- const collectUntilDocumentCountIs = async count => {+ const collectDocumentsOfTheTab = async channelName => {for (let attempt = 0; attempt < 1000; ++attempt) {await internals.gcAsync();- if (internals.documentCountInThisProcess() <= count) return true;+ if (documentsOfTheTab(channelName).length === 0) break;await timeout(10);}- return false;+ return documentsOfTheTab(channelName);};// A worker's process goes on for a while after its owner closes it.@@ -69,17 +58,16 @@window.open(tabUrl, "_blank", "noopener");while (!heard.tabPings || !heard.workerPings || !heard.blobUrl) await timeout(10);- return { channel, heard };+ return { channelName, channel, heard };};const closeTabAndReport = async (label, closeRequestHandler) => {- const documentCountWithoutTheTab = await settledDocumentCount();-- const { channel, heard } = await openTabAndHearFromIt(closeRequestHandler);+ const { channelName, channel, heard } = await openTabAndHearFromIt(closeRequestHandler);println(`${label}: blob URL resolves while open: ${(await fetch(heard.blobUrl)).ok}`);+ println(`${label}: documents of the tab while open: ${documentsOfTheTab(channelName).length}`);channel.postMessage({ type: "close" });- println(`${label}: documents collected: ${await collectUntilDocumentCountIs(documentCountWithoutTheTab)}`);+ println(`${label}: documents of the tab left: [${await collectDocumentsOfTheTab(channelName)}]`);println(`${label}: tab stopped: ${await stopsPinging(heard, "tabPings")}`);println(`${label}: worker stopped: ${await stopsPinging(heard, "workerPings")}`);diff --git a/Tests/LibWeb/Text/input/SiteIsolation/tab-keeps-playing-audio-a-while-after-a-cross-site-navigation.html b/Tests/LibWeb/Text/input/SiteIsolation/tab-keeps-playing-audio-a-while-after-a-cross-site-navigation.htmlindex c4493c89808..8df78aac580 100644--- a/Tests/LibWeb/Text/input/SiteIsolation/tab-keeps-playing-audio-a-while-after-a-cross-site-navigation.html+++ b/Tests/LibWeb/Text/input/SiteIsolation/tab-keeps-playing-audio-a-while-after-a-cross-site-navigation.html@@ -21,7 +21,7 @@(async () => {while (!internals.tabIsPlayingAudio())await new Promise(resolve => setTimeout(resolve, 25));- opener.postMessage(internals.tabAudibilityChangeCount(), "*");+ opener.postMessage("heard", "*");})();`));crossSiteUrl.hostname = uniqueLocalhostHostname("tab-keeps-playing-audio-cross-site");@@ -29,7 +29,7 @@const heard = nextMessage();const popup = window.open(crossSiteUrl.href);- const changes = await heard;+ await heard;println("the popup's tab plays audio heard in another process");// The popup's page leaves its tab while it is heard, as the popup's next document is displayed by this process.@@ -41,7 +41,7 @@println(`stops playing audio a while later: ${await waitForCondition(() => !popup.internals.tabIsPlayingAudio())}`);const heldFor = performance.now() - navigatedAt;println(`went on playing audio for at least two and a half seconds after navigating: ${heldFor >= 2500}`);- println(`changed whether it plays audio once: ${popup.internals.tabAudibilityChangeCount() - changes === 1}`);+ println(`playing audio indicator: ${popup.internals.tabAudibilityTransitions().join(", ")}`);popup.close();});</script>diff --git a/Tests/LibWeb/Text/input/css/inactive-document-css-images.html b/Tests/LibWeb/Text/input/css/inactive-document-css-images.htmlindex ff8b309406c..bb02deccd44 100644--- a/Tests/LibWeb/Text/input/css/inactive-document-css-images.html+++ b/Tests/LibWeb/Text/input/css/inactive-document-css-images.html@@ -10,6 +10,8 @@body: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",})));+ const requested = doc => internals.imageRequestURLs(doc).map(url => ["inline", "stylesheet"][urls.indexOf(url)] ?? url);+const source = document.createElement("select");source.style.backgroundImage = `url("${urls[0]}")`;const option = document.createElement("option");@@ -18,7 +20,7 @@const inactiveDocument = document.implementation.createHTMLDocument("");const copy = inactiveDocument.importNode(source, true);- println(`imported inline image requests: ${internals.imageRequestCount(inactiveDocument)}`);+ println(`imported inline image requests: [${requested(inactiveDocument)}]`);const style = inactiveDocument.createElement("style");style.textContent = `#target { background-image: url("${urls[1]}"); width: 10px; height: 10px; }`;@@ -26,12 +28,12 @@const target = inactiveDocument.createElement("div");target.id = "target";inactiveDocument.body.append(copy, target);- println(`inactive stylesheet image requests: ${internals.imageRequestCount(inactiveDocument)}`);+ println(`inactive stylesheet image requests: [${requested(inactiveDocument)}]`);- const before = internals.imageRequestCount(document);+ const before = requested(document);document.head.append(style);document.body.append(copy, target);internals.dumpLayoutTree(document);- println(`images requested after adoption: ${internals.imageRequestCount(document) - before}`);+ println(`images requested after adoption: [${requested(document).filter(name => !before.includes(name)).join(", ")}]`);});</script>