LibWeb: Add method for "is CORS-same-origin"

This commit is contained in:
Sam Atkins 2024-12-20 16:51:31 +00:00 committed by Andreas Kling
commit a4db7e9e23
Notes: github-actions[bot] 2024-12-22 11:31:10 +00:00
3 changed files with 16 additions and 3 deletions

View file

@ -201,6 +201,20 @@ GC::Ref<Response> Response::unsafe_response()
return *this;
}
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-same-origin
bool Response::is_cors_same_origin() const
{
// A response whose type is "basic", "cors", or "default" is CORS-same-origin. [FETCH]
switch (type()) {
case Type::Basic:
case Type::CORS:
case Type::Default:
return true;
default:
return false;
}
}
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-cross-origin
bool Response::is_cors_cross_origin() const
{

View file

@ -116,6 +116,7 @@ public:
[[nodiscard]] GC::Ref<Response> unsafe_response();
[[nodiscard]] bool is_cors_same_origin() const;
[[nodiscard]] bool is_cors_cross_origin() const;
[[nodiscard]] bool is_fresh() const;