Skip to content

Commit

Permalink
LibWeb: Get Page from principal realm during resource loading
Browse files Browse the repository at this point in the history
Fixes a crash for module loading for a shadow realm.
  • Loading branch information
shannonbooth authored and ADKaster committed Nov 24, 2024
1 parent b677844 commit 4913dac
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2240,7 +2240,7 @@ WebIDL::ExceptionOr<GC::Ref<PendingResponse>> nonstandard_resource_loader_file_o

auto request = fetch_params.request();

auto& page = Bindings::principal_host_defined_page(realm);
auto& page = Bindings::principal_host_defined_page(HTML::principal_realm(realm));

// NOTE: Using LoadRequest::create_for_url_on_page here will unconditionally add cookies as long as there's a page available.
// However, it is up to http_network_or_cache_fetch to determine if cookies should be added to the request.
Expand Down
1 change: 1 addition & 0 deletions Tests/LibWeb/Text/data/external-module.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = "Well hello shadows";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Well hello shadows
10 changes: 10 additions & 0 deletions Tests/LibWeb/Text/input/HTML/ShadowRealm-importValue.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script src="../include.js"></script>
<script>
asyncTest(async done => {
const shadowRealm = new ShadowRealm();
const promise = shadowRealm.importValue("../../data/external-module.mjs", "foo");
const value = await promise;
println(value);
done();
});
</script>

0 comments on commit 4913dac

Please sign in to comment.