LibWeb: Don't cache property accesses on WindowProxy

Since the underlying HTML::Window can change, caching property accesses
on WindowProxy is not as simple as remembering the shape. Let's disable
caching here for now. We can come back to it in the future when we have
no low-hanging fruit left. :^)

Fixes an assertion failure on https://twinings.co.uk/
This commit is contained in:
Andreas Kling 2023-07-10 20:50:24 +02:00 committed by Linus Groh
parent cf6792ec40
commit 06d9451551
Notes: sideshowbarker 2024-07-18 22:57:59 +09:00
3 changed files with 17 additions and 2 deletions

View file

@ -0,0 +1,2 @@
123
undefined

View file

@ -0,0 +1,13 @@
<script src="include.js"></script>
<script>
test(() => {
function ic(o) {
return o.foo
}
window.foo = 123
println(ic(window))
delete window.foo
println(ic(window))
});
</script>

View file

@ -144,7 +144,7 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_define_own_property(JS::Proper
}
// 7.4.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-get
JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const& property_key, JS::Value receiver, JS::CacheablePropertyMetadata* cacheable_metadata) const
JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const& property_key, JS::Value receiver, JS::CacheablePropertyMetadata*) const
{
auto& vm = this->vm();
@ -156,7 +156,7 @@ JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const
// 3. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver).
// NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method.
if (is_platform_object_same_origin(*m_window))
return JS::Object::internal_get(property_key, receiver, cacheable_metadata);
return JS::Object::internal_get(property_key, receiver);
// 4. Return ? CrossOriginGet(this, P, Receiver).
// NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method.