From 645a64ef0fc3d26c479a685ecf3ed876cde04ebb Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Thu, 20 Oct 2022 16:53:29 +0100 Subject: [PATCH] LibWeb: Don't get impl in document_tree_child_browsing_context_count This caused `Object.getOwnPropertyNames(window)` to throw, as the `this` value is `Object`. All users of document_tree_child_browsing_context_count call it on an existing Window impl, including WP::internal_own_property_keys, so getting the impl from the JS VM is not necessary. --- Userland/Libraries/LibWeb/HTML/Window.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp index 7e1cf5b686..1bb224569d 100644 --- a/Userland/Libraries/LibWeb/HTML/Window.cpp +++ b/Userland/Libraries/LibWeb/HTML/Window.cpp @@ -1040,10 +1040,8 @@ JS_DEFINE_NATIVE_FUNCTION(Window::btoa) // https://html.spec.whatwg.org/multipage/window-object.html#number-of-document-tree-child-browsing-contexts JS::ThrowCompletionOr Window::document_tree_child_browsing_context_count() const { - auto* impl = TRY(impl_from(vm())); - // 1. If W's browsing context is null, then return 0. - auto* this_browsing_context = impl->associated_document().browsing_context(); + auto* this_browsing_context = associated_document().browsing_context(); if (!this_browsing_context) return 0;