mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 10:04:59 +00:00
LibWeb: Ignore window-forwarded document.body.onfoo in detached DOM
Normally, assigning to e.g document.body.onload will forward to window.onload. However, in a detached DOM tree, there is no associated window, so we have nowhere to forward to, making this a no-op. The bulk of this change is making Document::window() return a nullable pointer, as documents created by DOMParser or DOMImplementation do not have an associated window object, and so must be able to return null from here.
This commit is contained in:
parent
7139d5945f
commit
b98a2be96b
28 changed files with 92 additions and 61 deletions
|
@ -227,15 +227,15 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page,
|
|||
|
||||
// 1. Let window be the associated window of the current browsing context’s active document.
|
||||
// FIXME: This will need adjusting when WebDriver supports frames.
|
||||
auto& window = page.top_level_browsing_context().active_document()->window();
|
||||
auto window = page.top_level_browsing_context().active_document()->window();
|
||||
|
||||
// 2. Let environment settings be the environment settings object for window.
|
||||
auto& environment_settings = Web::HTML::relevant_settings_object(window);
|
||||
auto& environment_settings = Web::HTML::relevant_settings_object(*window);
|
||||
|
||||
// 3. Let global scope be environment settings realm’s global environment.
|
||||
auto& global_scope = environment_settings.realm().global_environment();
|
||||
|
||||
auto& realm = window.realm();
|
||||
auto& realm = window->realm();
|
||||
|
||||
bool contains_direct_call_to_eval = false;
|
||||
auto source_text = ByteString::formatted("function() {{ {} }}", body);
|
||||
|
@ -271,7 +271,7 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page,
|
|||
// 9. Let completion be Function.[[Call]](window, parameters) with function as the this value.
|
||||
// NOTE: This is not entirely clear, but I don't think they mean actually passing `function` as
|
||||
// the this value argument, but using it as the object [[Call]] is executed on.
|
||||
auto completion = function->internal_call(&window, move(parameters));
|
||||
auto completion = function->internal_call(window, move(parameters));
|
||||
|
||||
// 10. Clean up after running a callback with environment settings.
|
||||
environment_settings.clean_up_after_running_callback();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue