mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibWeb: Start implementing "create and initialize a Document" from HTML
The way we've been creating DOM::Document has been pretty far from what the spec tells us to do, and this is a first big step towards getting us closer to spec. The new Document::create_and_initialize() is called by FrameLoader after loading a "text/html" resource. We create the JS Realm and the Window object when creating the Document (previously, we'd do it on first access to Document::interpreter().) The realm execution context is owned by the Environment Settings Object.
This commit is contained in:
parent
0781bdb23e
commit
602f927982
13 changed files with 315 additions and 78 deletions
|
@ -366,4 +366,28 @@ void queue_mutation_observer_microtask(DOM::Document& document)
|
|||
});
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#creating-a-new-javascript-realm
|
||||
NonnullOwnPtr<JS::ExecutionContext> create_a_new_javascript_realm(JS::VM& vm, Function<JS::Value(JS::Realm&)> create_global_object, Function<JS::Value(JS::Realm&)> create_global_this_value)
|
||||
{
|
||||
// 1. Perform InitializeHostDefinedRealm() with the provided customizations for creating the global object and the global this binding.
|
||||
// 2. Let realm execution context be the running JavaScript execution context.
|
||||
auto realm_execution_context = MUST(JS::Realm::initialize_host_defined_realm(vm, move(create_global_object), move(create_global_this_value)));
|
||||
|
||||
// 3. Remove realm execution context from the JavaScript execution context stack.
|
||||
vm.execution_context_stack().remove_first_matching([&realm_execution_context](auto* execution_context) {
|
||||
return execution_context == realm_execution_context.ptr();
|
||||
});
|
||||
|
||||
// NO-OP: 4. Let realm be realm execution context's Realm component.
|
||||
// NO-OP: 5. Set realm's agent to agent.
|
||||
|
||||
// FIXME: 6. If agent's agent cluster's cross-origin isolation mode is "none", then:
|
||||
// 1. Let global be realm's global object.
|
||||
// 2. Let status be ! global.[[Delete]]("SharedArrayBuffer").
|
||||
// 3. Assert: status is true.
|
||||
|
||||
// 7. Return realm execution context.
|
||||
return realm_execution_context;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue