diff options
author | MacDue <macdue@dueutil.tech> | 2022-08-25 19:04:27 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-26 00:21:10 +0200 |
commit | 8d2c2f7c52b6a1ef975bb32026f14fd1584c737c (patch) | |
tree | 3cfd2ef26e6768722ef67e2c357206f1b91d039b | |
parent | 9643a5c63f61741f82f91a49821f9b6b5d2e4e68 (diff) | |
download | serenity-8d2c2f7c52b6a1ef975bb32026f14fd1584c737c.zip |
LibWeb: Determine the origin when navigating across documents
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/BrowsingContext.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/FrameLoader.cpp | 11 |
4 files changed, 14 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index b9d9aaa6d5..f45b4af4f3 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -216,7 +216,7 @@ NonnullRefPtr<Document> Document::create_and_initialize(Type type, String conten // 8. Let document be a new Document, // whose type is type, // content type is contentType, - // FIXME: origin is navigationParams's origin, + // origin is navigationParams's origin, // FIXME: policy container is navigationParams's policy container, // FIXME: permissions policy is permissionsPolicy, // FIXME: active sandboxing flag set is navigationParams's final sandboxing flag set, @@ -226,6 +226,7 @@ NonnullRefPtr<Document> Document::create_and_initialize(Type type, String conten auto document = Document::create(); document->m_type = type; document->m_content_type = content_type; + document->set_origin(navigation_params.origin); document->m_window = window; window->set_associated_document(*document); diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 918f5671c2..e45dba2e6d 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -59,7 +59,7 @@ static HTML::Origin url_origin(AK::URL const& url) } // https://html.spec.whatwg.org/multipage/browsers.html#determining-the-origin -static HTML::Origin determine_the_origin(BrowsingContext const& browsing_context, Optional<AK::URL> url, SandboxingFlagSet sandbox_flags, Optional<HTML::Origin> invocation_origin) +HTML::Origin determine_the_origin(BrowsingContext const& browsing_context, Optional<AK::URL> url, SandboxingFlagSet sandbox_flags, Optional<HTML::Origin> invocation_origin) { // 1. If sandboxFlags has its sandboxed origin browsing context flag set, then return a new opaque origin. if (sandbox_flags.flags & SandboxingFlagSet::SandboxedOrigin) { diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index f96bc7a72d..f48ef6d4f5 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -157,4 +157,6 @@ private: String m_name; }; +HTML::Origin determine_the_origin(BrowsingContext const& browsing_context, Optional<AK::URL> url, SandboxingFlagSet sandbox_flags, Optional<HTML::Origin> invocation_origin); + } diff --git a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp index 6343f1f7dc..f22b75642a 100644 --- a/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -367,15 +367,22 @@ void FrameLoader::resource_did_load() dbgln_if(RESOURCE_DEBUG, "This content has MIME type '{}', encoding unknown", resource()->mime_type()); } + auto final_sandboxing_flag_set = HTML::SandboxingFlagSet {}; + + // (Part of https://html.spec.whatwg.org/#navigating-across-documents) + // 3. Let responseOrigin be the result of determining the origin given browsingContext, resource's url, finalSandboxFlags, and incumbentNavigationOrigin. + // FIXME: Pass incumbentNavigationOrigin + auto response_origin = HTML::determine_the_origin(browsing_context(), url, final_sandboxing_flag_set, {}); + auto response = make<Fetch::Infrastructure::Response>(); response->url_list().append(url); HTML::NavigationParams navigation_params { .id = {}, .request = nullptr, .response = move(response), - .origin = HTML::Origin {}, + .origin = move(response_origin), .policy_container = HTML::PolicyContainer {}, - .final_sandboxing_flag_set = HTML::SandboxingFlagSet {}, + .final_sandboxing_flag_set = move(final_sandboxing_flag_set), .cross_origin_opener_policy = HTML::CrossOriginOpenerPolicy {}, .coop_enforcement_result = HTML::CrossOriginOpenerPolicyEnforcementResult {}, .reserved_environment = {}, |