Truly independent web browser
LibWeb: Keep XHR and WebSocket pending activity alive from the global
Shannon Booth7ebbcf33dbcf
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cppindex 300695e6b90..9fd5842fba9 100644--- a/Libraries/LibWeb/DOM/Document.cpp+++ b/Libraries/LibWeb/DOM/Document.cpp@@ -281,7 +281,6 @@#include <LibWeb/WebIDL/ObservableArray.h>#include <LibWeb/WebIDL/Promise.h>#include <LibWeb/WebRTC/WebRTCAgent.h>-#include <LibWeb/XHR/XMLHttpRequest.h>#include <LibWeb/XPath/XPath.h>#include <LibWebCommon/CSS/SystemColor.h>#include <LibWebCommon/Infra/CharacterTypes.h>@@ -6622,7 +6621,9 @@ void Document::run_unloading_cleanup_steps()// GC collects it. However, we need to be proactive about this when navigating for the sake of test-web.window.close_all_idb_connections();WebRTC::WebRTCAgent::the().close_connections_for_global(window.this_impl());- XHR::XMLHttpRequest::release_activity_roots_for_relevant_global_object(window.this_impl());++ // AD-HOC: An unloaded document's objects have no activity left to finish, so the window stops keeping them alive.+ window.clear_objects_with_pending_activity();FileAPI::run_unloading_cleanup_steps(*this);fully_exit_fullscreen();diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cppindex db5af897992..ca65cf962a2 100644--- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp+++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp@@ -142,6 +142,7 @@ void WindowOrWorkerGlobalScopeMixin::visit_edges(JS::Cell::Visitor& visitor)entry.value.visit_edges(visitor);visitor.visit(m_registered_event_sources);visitor.visit(m_strongly_referenced_broadcast_channels);+ visitor.visit(m_objects_with_pending_activity);// A PermissionStatus with a change listener must stay alive while its global does, so the listener can hear of a// change even when nothing else refers to the status.@@ -1469,6 +1470,19 @@ void WindowOrWorkerGlobalScopeMixin::unregister_web_socket(Badge<WebSockets::Webm_registered_web_sockets.remove(web_socket);}+void WindowOrWorkerGlobalScopeMixin::set_has_pending_activity(DOM::EventTarget& object, bool has_pending_activity)+{+ if (has_pending_activity)+ m_objects_with_pending_activity.set(object);+ else+ m_objects_with_pending_activity.remove(object);+}++bool WindowOrWorkerGlobalScopeMixin::has_pending_activity(DOM::EventTarget const& object) const+{+ return m_objects_with_pending_activity.contains(const_cast<DOM::EventTarget&>(object));+}+WindowOrWorkerGlobalScopeMixin::AffectedAnyWebSockets WindowOrWorkerGlobalScopeMixin::make_disappear_all_web_sockets(){auto affected_any_web_sockets = AffectedAnyWebSockets::No;diff --git a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.hindex 71f16c39cff..02e665e0b94 100644--- a/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h+++ b/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h@@ -101,6 +101,10 @@ public:};AffectedAnyWebSockets make_disappear_all_web_sockets();+ void set_has_pending_activity(DOM::EventTarget&, bool);+ bool has_pending_activity(DOM::EventTarget const&) const;+ void clear_objects_with_pending_activity() { m_objects_with_pending_activity.clear(); }+i32 run_steps_after_a_timeout(i32 timeout, Function<void()> completion_step);void document_visibility_state_changed(Badge<DOM::Document>);@@ -222,6 +226,10 @@ private:WebSockets::WebSocket::List m_registered_web_sockets;+ // Objects with pending activity, such as a WebSocket with a listener for events still to come, which this global+ // keeps alive. They're held here rather than rooted, so they can't keep their global alive.+ HashTable<GC::Ref<DOM::EventTarget>> m_objects_with_pending_activity;+// https://w3c.github.io/resource-timing/#sec-extensions-performance-interface// Each ECMAScript global environment has:// https://w3c.github.io/resource-timing/#dfn-resource-timing-buffer-size-limitdiff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cppindex 683f028722f..36d75db25f7 100644--- a/Libraries/LibWeb/Internals/Internals.cpp+++ b/Libraries/LibWeb/Internals/Internals.cpp@@ -123,7 +123,6 @@#include <LibWeb/WebDriver/InputState.h>#include <LibWeb/WebIDL/ExceptionOr.h>#include <LibWeb/WebIDL/Promise.h>-#include <LibWeb/WebSockets/WebSocket.h>#include <LibWeb/XHR/XMLHttpRequest.h>#include <LibWebCommon/CSS/PreferredColorScheme.h>#include <LibWebCommon/Clipboard/SystemClipboard.h>@@ -496,13 +495,10 @@ bool Internals::wrapper_is_preserved(JS::Object& object)return Bindings::wrapper_is_preserved(*platform_object);}-bool Internals::has_activity_root(JS::Object& object)+bool Internals::has_pending_activity(JS::Object& object){- if (auto* xhr = Bindings::impl_from<XHR::XMLHttpRequest>(&object))- return xhr->has_activity_root();- if (auto* web_socket = Bindings::impl_from<WebSockets::WebSocket>(&object))- return web_socket->has_activity_root();- return false;+ auto* target = Bindings::impl_from<DOM::EventTarget>(&object);+ return target && HTML::relevant_window_or_worker_global_scope(object).has_pending_activity(*target);}WebIDL::UnsignedLongLong Internals::message_port_pending_outgoing_message_count(HTML::MessagePort& port)diff --git a/Libraries/LibWeb/Internals/Internals.h b/Libraries/LibWeb/Internals/Internals.hindex ec5cfcae8f4..b9314a7e420 100644--- a/Libraries/LibWeb/Internals/Internals.h+++ b/Libraries/LibWeb/Internals/Internals.h@@ -77,7 +77,7 @@ public:WebIDL::UnsignedLongLong discard_decoded_image_frames();WebIDL::ExceptionOr<void> mark_as_garbage(Utf16String const& variable_name);bool wrapper_is_preserved(JS::Object&);- bool has_activity_root(JS::Object&);+ bool has_pending_activity(JS::Object&);WebIDL::UnsignedLongLong message_port_pending_outgoing_message_count(HTML::MessagePort&);WebIDL::UnsignedLongLong html_collection_cache_generation(DOM::HTMLCollection&);void fail_next_message_port_transfer(HTML::MessagePort&);diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idlindex c88064204ba..0711406bcd3 100644--- a/Libraries/LibWeb/Internals/Internals.idl+++ b/Libraries/LibWeb/Internals/Internals.idl@@ -36,7 +36,7 @@ interface Internals {// This does not work for values stored only in optimized locals or registers.undefined markAsGarbage(DOMString variableName);boolean wrapperIsPreserved(object object);- boolean hasActivityRoot(object object);+ boolean hasPendingActivity(object object);unsigned long long messagePortPendingOutgoingMessageCount(MessagePort port);unsigned long long htmlCollectionCacheGeneration(HTMLCollection collection);undefined failNextMessagePortTransfer(MessagePort port);diff --git a/Libraries/LibWeb/WebSockets/WebSocket.cpp b/Libraries/LibWeb/WebSockets/WebSocket.cppindex 07c9ae99964..d094d66ba28 100644--- a/Libraries/LibWeb/WebSockets/WebSocket.cpp+++ b/Libraries/LibWeb/WebSockets/WebSocket.cpp@@ -167,7 +167,6 @@ void WebSocket::finalize()m_websocket->close(1000);}- m_activity_root.release();relevant_global_scope().unregister_web_socket({}, *this);}@@ -290,17 +289,14 @@ bool WebSocket::should_be_kept_alive() constreturn false;}-void WebSocket::update_activity_root()+void WebSocket::update_pending_activity(){- if (should_be_kept_alive())- m_activity_root.take(*this);- else- m_activity_root.release();+ relevant_global_scope().set_has_pending_activity(*this, should_be_kept_alive());}void WebSocket::event_listener_list_changed(){- update_activity_root();+ update_pending_activity();}// https://websockets.spec.whatwg.org/#dom-websocket-readystate@@ -312,7 +308,7 @@ Requests::WebSocket::ReadyState WebSocket::ready_state() constvoid WebSocket::set_ready_state(Requests::WebSocket::ReadyState ready_state){m_ready_state = ready_state;- update_activity_root();+ update_pending_activity();}// https://websockets.spec.whatwg.org/#dom-websocket-extensions@@ -546,6 +542,7 @@ void WebSocket::on_close(u16 code, Utf16String reason, bool was_clean)void WebSocket::make_disappear(){m_has_disappeared = true;+ update_pending_activity();// -> If the WebSocket connection is not yet established [WSP]// - Fail the WebSocket connection. [WSP]@@ -555,13 +552,10 @@ void WebSocket::make_disappear()// - Do nothing.// NOTE: All of these are handled by the WebSocket Protocol when calling close()auto ready_state = this->ready_state();- if (!m_websocket || ready_state == Requests::WebSocket::ReadyState::Closing || ready_state == Requests::WebSocket::ReadyState::Closed) {- m_activity_root.release();+ if (!m_websocket || ready_state == Requests::WebSocket::ReadyState::Closing || ready_state == Requests::WebSocket::ReadyState::Closed)return;- }m_websocket->close(1001);- m_activity_root.release();}#undef __ENUMERATEdiff --git a/Libraries/LibWeb/WebSockets/WebSocket.h b/Libraries/LibWeb/WebSockets/WebSocket.hindex 11e3986ea0b..606a4dfd4b5 100644--- a/Libraries/LibWeb/WebSockets/WebSocket.h+++ b/Libraries/LibWeb/WebSockets/WebSocket.h@@ -10,7 +10,6 @@#include <AK/ByteBuffer.h>#include <AK/Utf16String.h>#include <LibCore/EventReceiver.h>-#include <LibGC/ActivityRoot.h>#include <LibJS/Forward.h>#include <LibRequests/Forward.h>#include <LibRequests/WebSocket.h>@@ -63,7 +62,6 @@ public:WebIDL::ExceptionOr<void> send(WebSocketSendData const& data);void make_disappear();- bool has_activity_root() const { return m_activity_root.is_taken(); }private:void on_open();@@ -85,7 +83,7 @@ private:HTML::WindowOrWorkerGlobalScopeMixin& relevant_global_scope() const;ErrorOr<void> establish_web_socket_connection(URL::URL const& url_record, Vector<Utf16String> const& protocols, HTML::EnvironmentSettingsObject& client);bool should_be_kept_alive() const;- void update_activity_root();+ void update_pending_activity();URL::URL m_url;Requests::WebSocket::ReadyState m_ready_state { Requests::WebSocket::ReadyState::Connecting };@@ -93,7 +91,6 @@ private:u64 m_buffered_amount { 0 };RefPtr<Requests::WebSocket> m_websocket;GC::Ref<DOM::EventTarget> m_global_object;- GC::ActivityRoot m_activity_root;bool m_has_disappeared { false };IntrusiveListNode<WebSocket> m_list_node;diff --git a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Libraries/LibWeb/XHR/XMLHttpRequest.cppindex ca96f9276b1..dc459491ee7 100644--- a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp+++ b/Libraries/LibWeb/XHR/XMLHttpRequest.cpp@@ -11,7 +11,6 @@#include <AK/ByteBuffer.h>#include <AK/Debug.h>#include <AK/GenericLexer.h>-#include <AK/NeverDestroyed.h>#include <AK/QuickSort.h>#include <LibGC/Heap.h>#include <LibHTTP/Method.h>@@ -73,19 +72,6 @@ namespace Web::XHR {GC_DEFINE_ALLOCATOR(XMLHttpRequest);-static Vector<GC::Weak<XMLHttpRequest>>& live_xml_http_requests()-{- static NeverDestroyed<Vector<GC::Weak<XMLHttpRequest>>> requests;- return *requests;-}--static void prune_live_xml_http_requests()-{- live_xml_http_requests().remove_all_matching([](auto const& request) {- return !request;- });-}-GC::Ref<XMLHttpRequest> XMLHttpRequest::create(GC::Ref<DOM::EventTarget> relevant_global_object){auto upload_object = GC::Heap::the().allocate<XMLHttpRequestUpload>();@@ -94,10 +80,7 @@ GC::Ref<XMLHttpRequest> XMLHttpRequest::create(GC::Ref<DOM::EventTarget> relevanauto& global_scope = HTML::relevant_window_or_worker_global_scope(*relevant_global_object);auto& relevant_agent = HTML::relevant_agent(HTML::relevant_global_object(global_scope));auto fetch_controller = Fetch::Infrastructure::FetchController::create(relevant_agent.fetch_controller_registry);- auto xhr = GC::Heap::the().allocate<XMLHttpRequest>(relevant_global_object, *upload_object, move(author_request_headers), *response, *fetch_controller);- live_xml_http_requests().append(xhr);- prune_live_xml_http_requests();- return xhr;+ return GC::Heap::the().allocate<XMLHttpRequest>(relevant_global_object, *upload_object, move(author_request_headers), *response, *fetch_controller);}GC::Ptr<Bindings::Wrappable> XMLHttpRequest::relevant_global_impl() const@@ -124,15 +107,6 @@ XMLHttpRequest::XMLHttpRequest(GC::Ref<DOM::EventTarget> relevant_global_object,XMLHttpRequest::~XMLHttpRequest() = default;-void XMLHttpRequest::release_activity_roots_for_relevant_global_object(DOM::EventTarget const& relevant_global_object)-{- prune_live_xml_http_requests();- for (auto const& xhr : live_xml_http_requests()) {- if (xhr && xhr->m_global_object.ptr() == &relevant_global_object)- xhr->m_activity_root.release();- }-}-JS::Object& XMLHttpRequest::relevant_global_object() const{return HTML::relevant_global_object(HTML::relevant_window_or_worker_global_scope(*m_global_object));@@ -669,7 +643,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::open(String const& method, Utf16Stringm_fetch_controller->terminate();stop_timeout_timer();m_async_request = nullptr;- m_activity_root.release();+ HTML::relevant_window_or_worker_global_scope(*m_global_object).set_has_pending_activity(*this, false);// 11. Set variables associated with the object as follows:// Unset this’s send() flag.@@ -868,7 +842,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(NullableDocumentOrXMLHttpRequestB// 10. Set this’s send() flag.m_send = true;- update_activity_root();+ update_pending_activity();dbgln_if(SPAM_DEBUG, "{}XHR send from {} to {}", m_synchronous ? "\033[33;1mSynchronous\033[0m " : "", relevant_settings_object().creation_url, m_request_url);@@ -975,7 +949,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(NullableDocumentOrXMLHttpRequestB// 4. Set this’s state to headers received.m_state = State::HeadersReceived;- update_activity_root();+ update_pending_activity();// 5. Fire an event named readystatechange at this.dispatch_event(create_associated_event(EventNames::readystatechange));@@ -1017,7 +991,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::send(NullableDocumentOrXMLHttpRequestB// 3. If this’s state is headers received, then set this’s state to loading.if (m_state == State::HeadersReceived)m_state = State::Loading;- update_activity_root();+ update_pending_activity();// 4. Fire an event named readystatechange at this.// Spec Note: Web compatibility is the reason readystatechange fires more often than this’s state changes.@@ -1305,7 +1279,7 @@ void XMLHttpRequest::abort()if (m_state == State::Done) {m_state = State::Unsent;m_response = Fetch::Infrastructure::ResponseView::network_error("Not yet sent"_string);- update_activity_root();+ update_pending_activity();}}@@ -1365,7 +1339,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::handle_response_end_of_body()// 8. Unset xhr’s send() flag.m_send = false;- update_activity_root();+ update_pending_activity();// 9. Fire an event named readystatechange at xhr.dispatch_event(create_associated_event(EventNames::readystatechange));@@ -1413,7 +1387,7 @@ WebIDL::ExceptionOr<void> XMLHttpRequest::request_error_steps(Utf16FlyString con// 2. Unset xhr’s send() flag.m_send = false;- update_activity_root();+ update_pending_activity();// 3. Set xhr’s response to a network error.m_response = Fetch::Infrastructure::ResponseView::network_error("Failed to load"_string);@@ -1471,17 +1445,14 @@ bool XMLHttpRequest::should_be_kept_alive() const|| has_event_listener(EventNames::loadend);}-void XMLHttpRequest::update_activity_root()+void XMLHttpRequest::update_pending_activity(){- if (should_be_kept_alive())- m_activity_root.take(*this);- else- m_activity_root.release();+ HTML::relevant_window_or_worker_global_scope(*m_global_object).set_has_pending_activity(*this, should_be_kept_alive());}void XMLHttpRequest::event_listener_list_changed(){- update_activity_root();+ update_pending_activity();}// https://xhr.spec.whatwg.org/#the-responseurl-attributediff --git a/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Libraries/LibWeb/XHR/XMLHttpRequest.hindex 957e2cf62d0..d283db3c59b 100644--- a/Libraries/LibWeb/XHR/XMLHttpRequest.h+++ b/Libraries/LibWeb/XHR/XMLHttpRequest.h@@ -14,7 +14,6 @@#include <AK/Time.h>#include <AK/Vector.h>#include <AK/Weakable.h>-#include <LibGC/ActivityRoot.h>#include <LibHTTP/HeaderList.h>#include <LibJS/Forward.h>#include <LibURL/URL.h>@@ -109,9 +108,6 @@ public:void set_blob_response_object(GC::Ref<FileAPI::Blob>);void set_document_response();MimeSniff::MimeType get_final_mime_type() const;- bool has_activity_root() const { return m_activity_root.is_taken(); }-- static void release_activity_roots_for_relevant_global_object(DOM::EventTarget const&);private:virtual void visit_edges(Cell::Visitor&) override;@@ -133,7 +129,7 @@ private:void restart_timeout_timer();void stop_timeout_timer();bool should_be_kept_alive() const;- void update_activity_root();+ void update_pending_activity();XMLHttpRequest(GC::Ref<DOM::EventTarget> relevant_global_object, XMLHttpRequestUpload&, NonnullRefPtr<HTTP::HeaderList>, Fetch::Infrastructure::ResponseView&, Fetch::Infrastructure::FetchController&);@@ -252,7 +248,6 @@ private:RefPtr<Fetch::Infrastructure::Request> m_async_request;MonotonicTime m_async_send_start_time;GC::Ptr<Platform::Timer> m_timeout_timer;- GC::ActivityRoot m_activity_root;};}diff --git a/Tests/LibWeb/Text/expected/WebSocket/activity-root-released-on-document-destroy.txt b/Tests/LibWeb/Text/expected/WebSocket/activity-root-released-on-document-destroy.txtdeleted file mode 100644index 2df4dcb87f5..00000000000--- a/Tests/LibWeb/Text/expected/WebSocket/activity-root-released-on-document-destroy.txt+++ /dev/null@@ -1,4 +0,0 @@-listenerless root: false-root with listener: true-root after removing listener: false-root after destroy: falsediff --git a/Tests/LibWeb/Text/expected/WebSocket/pending-activity-released-on-document-destroy.txt b/Tests/LibWeb/Text/expected/WebSocket/pending-activity-released-on-document-destroy.txtnew file mode 100644index 00000000000..6a7cf017d14--- /dev/null+++ b/Tests/LibWeb/Text/expected/WebSocket/pending-activity-released-on-document-destroy.txt@@ -0,0 +1,4 @@+listenerless: false+with listener: true+after removing listener: false+after destroy: falsediff --git a/Tests/LibWeb/Text/expected/XHR/activity-root-released-on-document-destroy.txt b/Tests/LibWeb/Text/expected/XHR/activity-root-released-on-document-destroy.txtdeleted file mode 100644index 2df4dcb87f5..00000000000--- a/Tests/LibWeb/Text/expected/XHR/activity-root-released-on-document-destroy.txt+++ /dev/null@@ -1,4 +0,0 @@-listenerless root: false-root with listener: true-root after removing listener: false-root after destroy: falsediff --git a/Tests/LibWeb/Text/expected/XHR/pending-activity-released-on-document-destroy.txt b/Tests/LibWeb/Text/expected/XHR/pending-activity-released-on-document-destroy.txtnew file mode 100644index 00000000000..6a7cf017d14--- /dev/null+++ b/Tests/LibWeb/Text/expected/XHR/pending-activity-released-on-document-destroy.txt@@ -0,0 +1,4 @@+listenerless: false+with listener: true+after removing listener: false+after destroy: falsediff --git a/Tests/LibWeb/Text/input/WebSocket/activity-root-released-on-document-destroy.html b/Tests/LibWeb/Text/input/WebSocket/pending-activity-released-on-document-destroy.htmlsimilarity index 71%rename from Tests/LibWeb/Text/input/WebSocket/activity-root-released-on-document-destroy.htmlrename to Tests/LibWeb/Text/input/WebSocket/pending-activity-released-on-document-destroy.htmlindex 9790d45a7a6..ff28f1c8583 100644--- a/Tests/LibWeb/Text/input/WebSocket/activity-root-released-on-document-destroy.html+++ b/Tests/LibWeb/Text/input/WebSocket/pending-activity-released-on-document-destroy.html@@ -6,14 +6,14 @@document.body.append(frame);const webSocket = new frame.contentWindow.WebSocket(`ws://localhost:${internals.getEchoServerPort()}/`);- println(`listenerless root: ${internals.hasActivityRoot(webSocket)}`);+ println(`listenerless: ${internals.hasPendingActivity(webSocket)}`);webSocket.onclose = () => {};await new Promise(resolve => webSocket.addEventListener("open", resolve, { once: true }));- println(`root with listener: ${internals.hasActivityRoot(webSocket)}`);+ println(`with listener: ${internals.hasPendingActivity(webSocket)}`);webSocket.onclose = null;- println(`root after removing listener: ${internals.hasActivityRoot(webSocket)}`);+ println(`after removing listener: ${internals.hasPendingActivity(webSocket)}`);webSocket.onclose = () => {};await new Promise(resolve => {@@ -22,6 +22,6 @@});// Collect after the unload task has finished destroying the document.await internals.gcAsync();- println(`root after destroy: ${internals.hasActivityRoot(webSocket)}`);+ println(`after destroy: ${internals.hasPendingActivity(webSocket)}`);});</script>diff --git a/Tests/LibWeb/Text/input/XHR/activity-root-released-on-document-destroy.html b/Tests/LibWeb/Text/input/XHR/pending-activity-released-on-document-destroy.htmlsimilarity index 71%rename from Tests/LibWeb/Text/input/XHR/activity-root-released-on-document-destroy.htmlrename to Tests/LibWeb/Text/input/XHR/pending-activity-released-on-document-destroy.htmlindex 2ce9234274b..9c039766ad4 100644--- a/Tests/LibWeb/Text/input/XHR/activity-root-released-on-document-destroy.html+++ b/Tests/LibWeb/Text/input/XHR/pending-activity-released-on-document-destroy.html@@ -3,7 +3,7 @@<script>promiseTest(async () => {const server = httpTestServer();- const url = await server.createEcho("GET", "/xhr-activity-root-release", {+ const url = await server.createEcho("GET", "/xhr-pending-activity-release", {status: 200,headers: { "Content-Type": "text/plain" },body: "done",@@ -16,14 +16,14 @@const xhr = new frame.contentWindow.XMLHttpRequest();xhr.open("GET", url);xhr.send();- println(`listenerless root: ${internals.hasActivityRoot(xhr)}`);+ println(`listenerless: ${internals.hasPendingActivity(xhr)}`);const listener = () => {};xhr.addEventListener("progress", listener);- println(`root with listener: ${internals.hasActivityRoot(xhr)}`);+ println(`with listener: ${internals.hasPendingActivity(xhr)}`);xhr.removeEventListener("progress", listener);- println(`root after removing listener: ${internals.hasActivityRoot(xhr)}`);+ println(`after removing listener: ${internals.hasPendingActivity(xhr)}`);xhr.addEventListener("loadend", listener);await new Promise(resolve => {@@ -32,6 +32,6 @@});// Collect after the unload task has finished destroying the document.await internals.gcAsync();- println(`root after destroy: ${internals.hasActivityRoot(xhr)}`);+ println(`after destroy: ${internals.hasPendingActivity(xhr)}`);});</script>