mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibWeb: Make factory method of HTML::BrowsingContext fallible
This commit is contained in:
parent
3f50025126
commit
459959b297
4 changed files with 10 additions and 7 deletions
|
@ -211,12 +211,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> Document::create_and_initialize(
|
||||||
|
|
||||||
// FIXME: Why do we assume `creation_url` is non-empty here? Is this a spec bug?
|
// FIXME: Why do we assume `creation_url` is non-empty here? Is this a spec bug?
|
||||||
// FIXME: Why do we assume `top_level_creation_url` is non-empty here? Is this a spec bug?
|
// FIXME: Why do we assume `top_level_creation_url` is non-empty here? Is this a spec bug?
|
||||||
HTML::WindowEnvironmentSettingsObject::setup(
|
TRY(HTML::WindowEnvironmentSettingsObject::setup(
|
||||||
creation_url.value(),
|
creation_url.value(),
|
||||||
move(realm_execution_context),
|
move(realm_execution_context),
|
||||||
navigation_params.reserved_environment,
|
navigation_params.reserved_environment,
|
||||||
top_level_creation_url.value(),
|
top_level_creation_url.value(),
|
||||||
top_level_origin);
|
top_level_origin));
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: 7. Let loadTimingInfo be a new document load timing info with its navigation start time set to response's timing info's start time.
|
// FIXME: 7. Let loadTimingInfo be a new document load timing info with its navigation start time set to response's timing info's start time.
|
||||||
|
|
|
@ -139,7 +139,8 @@ JS::NonnullGCPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context
|
||||||
move(realm_execution_context),
|
move(realm_execution_context),
|
||||||
{},
|
{},
|
||||||
top_level_creation_url,
|
top_level_creation_url,
|
||||||
top_level_origin);
|
top_level_origin)
|
||||||
|
.release_value_but_fixme_should_propagate_errors();
|
||||||
|
|
||||||
// 12. Let loadTimingInfo be a new document load timing info with its navigation start time set to the result of calling
|
// 12. Let loadTimingInfo be a new document load timing info with its navigation start time set to the result of calling
|
||||||
// coarsen time with unsafeContextCreationTime and the new environment settings object's cross-origin isolated capability.
|
// coarsen time with unsafeContextCreationTime and the new environment settings object's cross-origin isolated capability.
|
||||||
|
|
|
@ -27,7 +27,7 @@ void WindowEnvironmentSettingsObject::visit_edges(JS::Cell::Visitor& visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/window-object.html#set-up-a-window-environment-settings-object
|
// https://html.spec.whatwg.org/multipage/window-object.html#set-up-a-window-environment-settings-object
|
||||||
void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, Optional<Environment> reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin)
|
WebIDL::ExceptionOr<void> WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, Optional<Environment> reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin)
|
||||||
{
|
{
|
||||||
// 1. Let realm be the value of execution context's Realm component.
|
// 1. Let realm be the value of execution context's Realm component.
|
||||||
auto* realm = execution_context->realm;
|
auto* realm = execution_context->realm;
|
||||||
|
@ -38,7 +38,7 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull
|
||||||
|
|
||||||
// 3. Let settings object be a new environment settings object whose algorithms are defined as follows:
|
// 3. Let settings object be a new environment settings object whose algorithms are defined as follows:
|
||||||
// NOTE: See the functions defined for this class.
|
// NOTE: See the functions defined for this class.
|
||||||
auto settings_object = realm->heap().allocate<WindowEnvironmentSettingsObject>(*realm, window, move(execution_context)).release_allocated_value_but_fixme_should_propagate_errors();
|
auto settings_object = MUST_OR_THROW_OOM(realm->heap().allocate<WindowEnvironmentSettingsObject>(*realm, window, move(execution_context)));
|
||||||
|
|
||||||
// 4. If reservedEnvironment is non-null, then:
|
// 4. If reservedEnvironment is non-null, then:
|
||||||
if (reserved_environment.has_value()) {
|
if (reserved_environment.has_value()) {
|
||||||
|
@ -71,13 +71,15 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull
|
||||||
|
|
||||||
// 7. Set realm's [[HostDefined]] field to settings object.
|
// 7. Set realm's [[HostDefined]] field to settings object.
|
||||||
// Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object
|
// Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object
|
||||||
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm).release_allocated_value_but_fixme_should_propagate_errors();
|
auto intrinsics = MUST_OR_THROW_OOM(realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm));
|
||||||
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
|
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
|
||||||
realm->set_host_defined(move(host_defined));
|
realm->set_host_defined(move(host_defined));
|
||||||
|
|
||||||
// Non-Standard: We cannot fully initialize window object until *after* the we set up
|
// Non-Standard: We cannot fully initialize window object until *after* the we set up
|
||||||
// the realm's [[HostDefined]] internal slot as the internal slot contains the web platform intrinsics
|
// the realm's [[HostDefined]] internal slot as the internal slot contains the web platform intrinsics
|
||||||
window.initialize_web_interfaces({});
|
window.initialize_web_interfaces({});
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:responsible-document
|
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:responsible-document
|
||||||
|
|
|
@ -15,7 +15,7 @@ class WindowEnvironmentSettingsObject final : public EnvironmentSettingsObject {
|
||||||
JS_CELL(WindowEnvironmentSettingsObject, EnvironmentSettingsObject);
|
JS_CELL(WindowEnvironmentSettingsObject, EnvironmentSettingsObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext>, Optional<Environment>, AK::URL top_level_creation_url, Origin top_level_origin);
|
static WebIDL::ExceptionOr<void> setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext>, Optional<Environment>, AK::URL top_level_creation_url, Origin top_level_origin);
|
||||||
|
|
||||||
virtual ~WindowEnvironmentSettingsObject() override;
|
virtual ~WindowEnvironmentSettingsObject() override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue