Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fetch/metadata/text.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

promise_test(async t => {
const key = "text-destination" + token();
await import("/fetch/metadata/resources/record-header.py?file=" + key);
await import("/fetch/metadata/resources/record-header.py?file=" + key, { with: { type: "text" } });
const expected = {"site": "same-origin", "user": "", "mode": "cors", "dest": "text"};
await validate_expectations(key, expected);
}, "The fetch metadata for text module");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const content_types = [
"text/json/json",

// Control Characters and Whitespace - Invalid Type
"applic\x00ation/vnd.api+json", // NULL in type
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removal of all 0x00 tests warrants some kind of explanation. Oh I guess the issue is that HTTP doesn't allow these so it's kinda moot. Anyway, please call that out in the final commit message.

"applic\x09ation/vnd.api+json", // TAB in type
"applic\x0Aation/vnd.api+json", // Line Feed in type
"applic\x0Dation/vnd.api+json", // Carriage Return in type
Expand All @@ -37,7 +36,6 @@ const content_types = [
"application\x1F/vnd.api+json", // Unit Separator at end of type

// Control Characters and Whitespace - Invalid Subtype
"application/vnd\x00.api+json", // NULL in subtype
"application/vnd\x09.api+json", // TAB in subtype
"application/vnd\x0A.api+json", // Line Feed in subtype
"application/vnd\x0D.api+json", // Carriage Return in subtype
Expand Down Expand Up @@ -106,7 +104,6 @@ const content_types = [
"applic=ation/vnd=api+json", // Equals in both
"申请/中文.api+json", // Chinese in both
"app™/vnd€.api+json", // Unicode symbols in both
"applic\x00ation/vnd\x00api+json", // NULL in both
"applic;ation/vnd;api+json", // Semicolons in both
"applic{ation/vnd{api+json", // Left curly brace in both
"applic}ation/vnd}api+json", // Right curly brace in both
Expand All @@ -120,7 +117,6 @@ const content_types = [
"application\"/vnd.api+json", // Quote at end of type
"application /vnd.api+json", // Trailing space in type
"/vnd.api+json", // Empty type
"app\x00lication/vnd.api+json", // NULL in middle of type

// Edge Cases - Subtype
"application/\"vnd.api+json", // Quote at start of subtype
Expand All @@ -132,11 +128,11 @@ const content_types = [
// Edge Cases - Multiple Invalid Positions
"\"application\"/\"vnd.api\"+json", // Quotes in multiple positions
"app(lic)ation/vnd(api)+json", // Parentheses in multiple positions
"application\x00/\x00vnd.api+json", // NULL in both parts
];

for (const content_type of content_types) {
promise_test(async test => {
await import(`./file.txt?pipe=header(Content-Type,${encodeURIComponent(content_type)})`, { with: { type: "text" } });
const enc_content_type = encodeURIComponent(content_type.replaceAll(',', '\\,').replaceAll(')', '\\)'));
await import(`./file.txt?pipe=header(Content-Type,${enc_content_type})`, { with: { type: "text" } });
}, `Import of a text module with MIME type ${content_type} should succeed`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
for (const name of ["file", "file.js", "file.json", "file.txt"]) {
promise_test(async t => {
const result = await import(`./${name}`, { with: { type: "text" } });
assert_equals(result, "text file\n");
assert_equals(result.default, "text file\n");
}, `Extension: ${name}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
window.mismatchesLog = [];
window.mismatchesEvents = [];
</script>
<script type="module" src="integrity-matches.js" integrity="sha384-kc1K2KFKQhnYE1AdnpmUUpFVnxz1GCgGbQ19e3zmXrZw23rgpwa9il4/pHp7NYWA" onload="window.matchesEvents.push('load');" onerror="window.matchesEvents.push('error')"></script>
<script type="module" src="integrity-matches.js" integrity="sha384-pjL0xfAOZ4ZBiE7HXzxD1TkqVgNikOnFFZY3SC2Z4jWAyaP76YUa5VrRInWayN7m" onload="window.matchesEvents.push('load');" onerror="window.matchesEvents.push('error')"></script>
<script type="module" src="integrity-mismatches.js" integrity="sha384-doesnotmatch" onload="window.mismatchesEvents.push('load');" onerror="window.mismatchesEvents.push('error')"></script>

<script type="module">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ promise_test(async test => {
const uuid_token = token();
// serve-js-then-text.py gives us JS the first time
const result_js = await import(`./serve-js-then-text.py?key=${uuid_token}`);
assert_equals(result_js.default, "hello");
assert_equals(result_js.default, "world");

// If this were to do another fetch, the import would fail because
// serve-js-then-text.py would give us text this time. But, the module map
// entry for this specifier/module type pair already exists, so we
// successfully reuse the entry instead of fetching again.
const result_js_2 = await import(`./serve-js-then-text.py?key=${uuid_token}`);
assert_equals(result_js_2.default, "hello");
assert_equals(result_js_2.default, "world");
}, "If an import previously succeeded for a given specifier with no type attribute, future uses of the same values should yield the same result");
Loading