LibWeb: Make global prototype chains immutable

Per https://webidl.spec.whatwg.org/#interface-prototype-object any
global platform object should reject prototype changes (besides
from ShadowRealmGlobalScope), and interface prototype objects on
global prototype chains must be immutable.

We already handled parts of this on the globals themselves, but not
the full chain.

Also align some spec comments to the latest WebIDL spec.
This commit is contained in:
Shannon Booth
2026-03-31 23:30:42 +02:00
committed by Shannon Booth
parent ce4861156b
commit 379461e047
Notes: github-actions[bot] 2026-04-03 16:35:00 +00:00
6 changed files with 93 additions and 2 deletions

View File

@@ -37,6 +37,16 @@ WorkerGlobalScope::WorkerGlobalScope(JS::Realm& realm, GC::Ref<Web::Page> page)
WorkerGlobalScope::~WorkerGlobalScope() = default;
// https://webidl.spec.whatwg.org/#platform-object-setprototypeof
JS::ThrowCompletionOr<bool> WorkerGlobalScope::internal_set_prototype_of(JS::Object* prototype)
{
// 1. If Os associated realms is global prototype chain mutable is true, return ? OrdinarySetPrototypeOf(O, V).
// NB: This is never the case for WorkerGlobalScope.
// 2. Return ? SetImmutablePrototype(O, V).
return set_immutable_prototype(prototype);
}
void WorkerGlobalScope::initialize_web_interfaces_impl()
{
auto& realm = this->realm();