mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
LibWeb: Update generated code in Bindings/FetchMethod.cpp
Also update the incomplete and slightly incorrect dummy interface code snippet I used to generate this.
This commit is contained in:
parent
d68623698c
commit
9afcbdf452
1 changed files with 31 additions and 26 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -21,9 +21,14 @@
|
||||||
#include <LibWeb/URL/URLSearchParams.h>
|
#include <LibWeb/URL/URLSearchParams.h>
|
||||||
|
|
||||||
// NOTE: This file contains code generated by BindingsGenerator from the following input:
|
// NOTE: This file contains code generated by BindingsGenerator from the following input:
|
||||||
|
// ```idl
|
||||||
|
// #import <Fetch/Request.idl>
|
||||||
|
// #import <Fetch/Response.idl>
|
||||||
|
// [Exposed=Window]
|
||||||
// interface Dummy {
|
// interface Dummy {
|
||||||
// static Promise<Response> fetch(RequestInfo input, optional RequestInfo init = {});
|
// static Promise<Response> fetch(RequestInfo input, optional RequestInit init = {});
|
||||||
// };
|
// };
|
||||||
|
// ```
|
||||||
// This is because the spec defines the fetch() method as a 'partial interface mixin' on
|
// This is because the spec defines the fetch() method as a 'partial interface mixin' on
|
||||||
// WindowOrWorkerGlobalScope, which we don't support yet - and even if we did, the Window object is
|
// WindowOrWorkerGlobalScope, which we don't support yet - and even if we did, the Window object is
|
||||||
// not generated from IDL currently, so we couldn't add a mixin to it that way. The generated code
|
// not generated from IDL currently, so we couldn't add a mixin to it that way. The generated code
|
||||||
|
@ -102,19 +107,19 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
||||||
if (!cache_property_value.is_undefined()) {
|
if (!cache_property_value.is_undefined()) {
|
||||||
RequestCache cache_value { RequestCache::Default };
|
RequestCache cache_value { RequestCache::Default };
|
||||||
if (!cache_property_value.is_undefined()) {
|
if (!cache_property_value.is_undefined()) {
|
||||||
auto cache_property_value_string = TRY(cache_property_value.to_deprecated_string(vm));
|
auto cache_property_value_string = TRY(cache_property_value.to_string(vm));
|
||||||
if (cache_property_value_string == "only-if-cached"sv)
|
if (cache_property_value_string == "default"sv)
|
||||||
cache_value = RequestCache::OnlyIfCached;
|
|
||||||
else if (cache_property_value_string == "default"sv)
|
|
||||||
cache_value = RequestCache::Default;
|
cache_value = RequestCache::Default;
|
||||||
else if (cache_property_value_string == "no-store"sv)
|
else if (cache_property_value_string == "no-store"sv)
|
||||||
cache_value = RequestCache::NoStore;
|
cache_value = RequestCache::NoStore;
|
||||||
else if (cache_property_value_string == "force-cache"sv)
|
|
||||||
cache_value = RequestCache::ForceCache;
|
|
||||||
else if (cache_property_value_string == "reload"sv)
|
else if (cache_property_value_string == "reload"sv)
|
||||||
cache_value = RequestCache::Reload;
|
cache_value = RequestCache::Reload;
|
||||||
else if (cache_property_value_string == "no-cache"sv)
|
else if (cache_property_value_string == "no-cache"sv)
|
||||||
cache_value = RequestCache::NoCache;
|
cache_value = RequestCache::NoCache;
|
||||||
|
else if (cache_property_value_string == "force-cache"sv)
|
||||||
|
cache_value = RequestCache::ForceCache;
|
||||||
|
else if (cache_property_value_string == "only-if-cached"sv)
|
||||||
|
cache_value = RequestCache::OnlyIfCached;
|
||||||
else
|
else
|
||||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::InvalidEnumerationValue, cache_property_value_string, "RequestCache");
|
return vm.throw_completion<JS::TypeError>(JS::ErrorType::InvalidEnumerationValue, cache_property_value_string, "RequestCache");
|
||||||
}
|
}
|
||||||
|
@ -126,13 +131,13 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
||||||
if (!credentials_property_value.is_undefined()) {
|
if (!credentials_property_value.is_undefined()) {
|
||||||
RequestCredentials credentials_value { RequestCredentials::Omit };
|
RequestCredentials credentials_value { RequestCredentials::Omit };
|
||||||
if (!credentials_property_value.is_undefined()) {
|
if (!credentials_property_value.is_undefined()) {
|
||||||
auto credentials_property_value_string = TRY(credentials_property_value.to_deprecated_string(vm));
|
auto credentials_property_value_string = TRY(credentials_property_value.to_string(vm));
|
||||||
if (credentials_property_value_string == "same-origin"sv)
|
if (credentials_property_value_string == "omit"sv)
|
||||||
|
credentials_value = RequestCredentials::Omit;
|
||||||
|
else if (credentials_property_value_string == "same-origin"sv)
|
||||||
credentials_value = RequestCredentials::SameOrigin;
|
credentials_value = RequestCredentials::SameOrigin;
|
||||||
else if (credentials_property_value_string == "include"sv)
|
else if (credentials_property_value_string == "include"sv)
|
||||||
credentials_value = RequestCredentials::Include;
|
credentials_value = RequestCredentials::Include;
|
||||||
else if (credentials_property_value_string == "omit"sv)
|
|
||||||
credentials_value = RequestCredentials::Omit;
|
|
||||||
else
|
else
|
||||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::InvalidEnumerationValue, credentials_property_value_string, "RequestCredentials");
|
return vm.throw_completion<JS::TypeError>(JS::ErrorType::InvalidEnumerationValue, credentials_property_value_string, "RequestCredentials");
|
||||||
}
|
}
|
||||||
|
@ -144,7 +149,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
||||||
if (!duplex_property_value.is_undefined()) {
|
if (!duplex_property_value.is_undefined()) {
|
||||||
RequestDuplex duplex_value { RequestDuplex::Half };
|
RequestDuplex duplex_value { RequestDuplex::Half };
|
||||||
if (!duplex_property_value.is_undefined()) {
|
if (!duplex_property_value.is_undefined()) {
|
||||||
auto duplex_property_value_string = TRY(duplex_property_value.to_deprecated_string(vm));
|
auto duplex_property_value_string = TRY(duplex_property_value.to_string(vm));
|
||||||
if (duplex_property_value_string == "half"sv)
|
if (duplex_property_value_string == "half"sv)
|
||||||
duplex_value = RequestDuplex::Half;
|
duplex_value = RequestDuplex::Half;
|
||||||
else
|
else
|
||||||
|
@ -267,7 +272,7 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
||||||
if (!mode_property_value.is_undefined()) {
|
if (!mode_property_value.is_undefined()) {
|
||||||
RequestMode mode_value { RequestMode::Navigate };
|
RequestMode mode_value { RequestMode::Navigate };
|
||||||
if (!mode_property_value.is_undefined()) {
|
if (!mode_property_value.is_undefined()) {
|
||||||
auto mode_property_value_string = TRY(mode_property_value.to_deprecated_string(vm));
|
auto mode_property_value_string = TRY(mode_property_value.to_string(vm));
|
||||||
if (mode_property_value_string == "navigate"sv)
|
if (mode_property_value_string == "navigate"sv)
|
||||||
mode_value = RequestMode::Navigate;
|
mode_value = RequestMode::Navigate;
|
||||||
else if (mode_property_value_string == "same-origin"sv)
|
else if (mode_property_value_string == "same-origin"sv)
|
||||||
|
@ -287,13 +292,13 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
||||||
if (!redirect_property_value.is_undefined()) {
|
if (!redirect_property_value.is_undefined()) {
|
||||||
RequestRedirect redirect_value { RequestRedirect::Follow };
|
RequestRedirect redirect_value { RequestRedirect::Follow };
|
||||||
if (!redirect_property_value.is_undefined()) {
|
if (!redirect_property_value.is_undefined()) {
|
||||||
auto redirect_property_value_string = TRY(redirect_property_value.to_deprecated_string(vm));
|
auto redirect_property_value_string = TRY(redirect_property_value.to_string(vm));
|
||||||
if (redirect_property_value_string == "follow"sv)
|
if (redirect_property_value_string == "follow"sv)
|
||||||
redirect_value = RequestRedirect::Follow;
|
redirect_value = RequestRedirect::Follow;
|
||||||
else if (redirect_property_value_string == "manual"sv)
|
|
||||||
redirect_value = RequestRedirect::Manual;
|
|
||||||
else if (redirect_property_value_string == "error"sv)
|
else if (redirect_property_value_string == "error"sv)
|
||||||
redirect_value = RequestRedirect::Error;
|
redirect_value = RequestRedirect::Error;
|
||||||
|
else if (redirect_property_value_string == "manual"sv)
|
||||||
|
redirect_value = RequestRedirect::Manual;
|
||||||
else
|
else
|
||||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::InvalidEnumerationValue, redirect_property_value_string, "RequestRedirect");
|
return vm.throw_completion<JS::TypeError>(JS::ErrorType::InvalidEnumerationValue, redirect_property_value_string, "RequestRedirect");
|
||||||
}
|
}
|
||||||
|
@ -318,25 +323,25 @@ JS::ThrowCompletionOr<JS::Value> fetch(JS::VM& vm)
|
||||||
if (!referrer_policy_property_value.is_undefined()) {
|
if (!referrer_policy_property_value.is_undefined()) {
|
||||||
ReferrerPolicy referrer_policy_value { ReferrerPolicy::Empty };
|
ReferrerPolicy referrer_policy_value { ReferrerPolicy::Empty };
|
||||||
if (!referrer_policy_property_value.is_undefined()) {
|
if (!referrer_policy_property_value.is_undefined()) {
|
||||||
auto referrer_policy_property_value_string = TRY(referrer_policy_property_value.to_deprecated_string(vm));
|
auto referrer_policy_property_value_string = TRY(referrer_policy_property_value.to_string(vm));
|
||||||
if (referrer_policy_property_value_string == ""sv)
|
if (referrer_policy_property_value_string == ""sv)
|
||||||
referrer_policy_value = ReferrerPolicy::Empty;
|
referrer_policy_value = ReferrerPolicy::Empty;
|
||||||
|
else if (referrer_policy_property_value_string == "no-referrer"sv)
|
||||||
|
referrer_policy_value = ReferrerPolicy::NoReferrer;
|
||||||
|
else if (referrer_policy_property_value_string == "no-referrer-when-downgrade"sv)
|
||||||
|
referrer_policy_value = ReferrerPolicy::NoReferrerWhenDowngrade;
|
||||||
else if (referrer_policy_property_value_string == "same-origin"sv)
|
else if (referrer_policy_property_value_string == "same-origin"sv)
|
||||||
referrer_policy_value = ReferrerPolicy::SameOrigin;
|
referrer_policy_value = ReferrerPolicy::SameOrigin;
|
||||||
else if (referrer_policy_property_value_string == "origin"sv)
|
else if (referrer_policy_property_value_string == "origin"sv)
|
||||||
referrer_policy_value = ReferrerPolicy::Origin;
|
referrer_policy_value = ReferrerPolicy::Origin;
|
||||||
else if (referrer_policy_property_value_string == "origin-when-cross-origin"sv)
|
|
||||||
referrer_policy_value = ReferrerPolicy::OriginWhenCrossOrigin;
|
|
||||||
else if (referrer_policy_property_value_string == "strict-origin"sv)
|
else if (referrer_policy_property_value_string == "strict-origin"sv)
|
||||||
referrer_policy_value = ReferrerPolicy::StrictOrigin;
|
referrer_policy_value = ReferrerPolicy::StrictOrigin;
|
||||||
else if (referrer_policy_property_value_string == "no-referrer"sv)
|
else if (referrer_policy_property_value_string == "origin-when-cross-origin"sv)
|
||||||
referrer_policy_value = ReferrerPolicy::NoReferrer;
|
referrer_policy_value = ReferrerPolicy::OriginWhenCrossOrigin;
|
||||||
else if (referrer_policy_property_value_string == "unsafe-url"sv)
|
|
||||||
referrer_policy_value = ReferrerPolicy::UnsafeUrl;
|
|
||||||
else if (referrer_policy_property_value_string == "no-referrer-when-downgrade"sv)
|
|
||||||
referrer_policy_value = ReferrerPolicy::NoReferrerWhenDowngrade;
|
|
||||||
else if (referrer_policy_property_value_string == "strict-origin-when-cross-origin"sv)
|
else if (referrer_policy_property_value_string == "strict-origin-when-cross-origin"sv)
|
||||||
referrer_policy_value = ReferrerPolicy::StrictOriginWhenCrossOrigin;
|
referrer_policy_value = ReferrerPolicy::StrictOriginWhenCrossOrigin;
|
||||||
|
else if (referrer_policy_property_value_string == "unsafe-url"sv)
|
||||||
|
referrer_policy_value = ReferrerPolicy::UnsafeUrl;
|
||||||
else
|
else
|
||||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::InvalidEnumerationValue, referrer_policy_property_value_string, "ReferrerPolicy");
|
return vm.throw_completion<JS::TypeError>(JS::ErrorType::InvalidEnumerationValue, referrer_policy_property_value_string, "ReferrerPolicy");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue