diff --git a/third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule.cc b/third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule.cc index 8c53a6ccee3c2a..cc3b453d4c5a6e 100644 --- a/third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule.cc +++ b/third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule.cc @@ -69,10 +69,10 @@ absl::optional ScriptWebBundleRule::ParseJson( } HashSet scope_urls = - ParseJSONArrayAsURLs(json_obj->GetArray("scopes"), base_url); + ParseJSONArrayAsURLs(json_obj->GetArray("scopes"), source_url); HashSet resource_urls = - ParseJSONArrayAsURLs(json_obj->GetArray("resources"), base_url); + ParseJSONArrayAsURLs(json_obj->GetArray("resources"), source_url); return ScriptWebBundleRule(source_url, credentials_mode, std::move(scope_urls), std::move(resource_urls)); diff --git a/third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule_test.cc b/third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule_test.cc index 80a007a4fedac7..054940b1455742 100644 --- a/third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule_test.cc +++ b/third_party/blink/renderer/core/loader/web_bundle/script_web_bundle_rule_test.cc @@ -64,6 +64,36 @@ TEST(ScriptWebBundleRuleTest, InvalidType) { EXPECT_TRUE(rule.resource_urls().IsEmpty()); } +TEST(ScriptWebBundleRuleTest, ResourcesShouldBeResolvedOnBundleURL) { + const KURL base_url("https://example.com/"); + auto result = ScriptWebBundleRule::ParseJson( + R"({ + "source": "hello/foo.wbn", + "resources": ["dir/a.css"] + })", + base_url); + ASSERT_TRUE(result); + ScriptWebBundleRule& rule = *result; + EXPECT_EQ(rule.source_url(), "https://example.com/hello/foo.wbn"); + EXPECT_THAT(rule.resource_urls(), testing::UnorderedElementsAre( + "https://example.com/hello/dir/a.css")); +} + +TEST(ScriptWebBundleRuleTest, ScopesShouldBeResolvedOnBundleURL) { + const KURL base_url("https://example.com/"); + auto result = ScriptWebBundleRule::ParseJson( + R"({ + "source": "hello/foo.wbn", + "scopes": ["js"] + })", + base_url); + ASSERT_TRUE(result); + ScriptWebBundleRule& rule = *result; + EXPECT_EQ(rule.source_url(), "https://example.com/hello/foo.wbn"); + EXPECT_THAT(rule.scope_urls(), + testing::UnorderedElementsAre("https://example.com/hello/js")); +} + TEST(ScriptWebBundleRuleTest, CredentialsDefaultIsSameOrigin) { const KURL base_url("https://example.com/"); auto result = ScriptWebBundleRule::ParseJson( diff --git a/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url-resources.https.tentative.html b/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url-resources.https.tentative.html new file mode 100644 index 00000000000000..9fd35c6f1179ae --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url-resources.https.tentative.html @@ -0,0 +1,81 @@ + +Subresource loading using relative URLs in the 'resources' + + + + + + + + + diff --git a/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url-scopes.https.tentative.html b/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url-scopes.https.tentative.html new file mode 100644 index 00000000000000..b3ecd8fee30d6d --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url-scopes.https.tentative.html @@ -0,0 +1,84 @@ + + + Subresource loading using relative URLs in the 'scopes' + + + + + + + + + + diff --git a/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url-static-element.https.tentative.html b/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url-static-element.https.tentative.html new file mode 100644 index 00000000000000..55030e234bf8a3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url-static-element.https.tentative.html @@ -0,0 +1,34 @@ + +WebBundle subresource loading with relative URLs for static elements + + + + + + + + + + diff --git a/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url.https.tentative.html b/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url.https.tentative.html deleted file mode 100644 index 8b9a1cae9ef806..00000000000000 --- a/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-relative-url.https.tentative.html +++ /dev/null @@ -1,24 +0,0 @@ - -Subresource loading using relative URLs in the 'resources' attribute - - - - - - - - - - - - \ No newline at end of file diff --git a/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-reuse-web-bundle-resource.https.tentative.html b/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-reuse-web-bundle-resource.https.tentative.html index 7429ae0a033145..55b7e9d85fae34 100644 --- a/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-reuse-web-bundle-resource.https.tentative.html +++ b/third_party/blink/web_tests/external/wpt/web-bundle/subresource-loading/script-reuse-web-bundle-resource.https.tentative.html @@ -16,8 +16,11 @@ }); const wbn_url = "../resources/wbn/subresource.wbn"; - const resource1 = "../resources/wbn/root.js"; - const resource2 = "../resources/wbn/submodule.js"; + const resource1 = "root.js"; + const resource2 = "submodule.js"; + + const resource1_url = `../resources/wbn/${resource1}`; + const resource2_url = `../resources/wbn/${resource2}`; let script1; let script2; @@ -32,18 +35,18 @@ } async function assertResource1CanBeFetched() { - const response = await fetch(resource1); + const response = await fetch(resource1_url); const text = await response.text(); assert_equals(text, "export * from './submodule.js';\n"); } async function assertResource1CanNotBeFetched() { - const response = await fetch(resource1); + const response = await fetch(resource1_url); assert_equals(response.status, 404); } async function assertResource2CanBeFetched() { - const response = await fetch(resource2); + const response = await fetch(resource2_url); const text = await response.text(); assert_equals(text, "export const result = 'OK';\n"); }