Commit 84525819 authored by Surma's avatar Surma Committed by Commit Bot

[wasm] Stricter MIME type test on WebAssembly streaming APIs

The WebAssembly Web API spec[1] prescribes that the responses for
`WebAssembly.{compile,instantiate}Streaming()` must have the
`Content-Type` header `application/wasm` without any extra parameters.
So far we ignored extra parameters, causing interop
issues with Firefox.

[1]: https://www.w3.org/TR/wasm-web-api-1/#streaming-modules

Bug: 1057973
Change-Id: I2273e2b5577dc6a11343536d55fa72b9e518c0f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2085257
Commit-Queue: Surma <surma@chromium.org>
Reviewed-by: default avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747693}
parent b57d396b
......@@ -322,7 +322,10 @@ void StreamFromResponseCallback(
return;
}
if (response->MimeType() != "application/wasm") {
// The spec explicitly disallows any extras on the Content-Type header,
// so we check against ContentType() rather than MimeType(), which
// implicitly strips extras.
if (response->ContentType().LowerASCII() != "application/wasm") {
exception_state.ThrowTypeError(
"Incorrect response MIME type. Expected 'application/wasm'.");
return;
......
This is a testharness.js-based test.
PASS Response with Content-Type "": compileStreaming
PASS Response with Content-Type "": instantiateStreaming
PASS Response with Content-Type "application/javascript": compileStreaming
PASS Response with Content-Type "application/javascript": instantiateStreaming
PASS Response with Content-Type "application/octet-stream": compileStreaming
PASS Response with Content-Type "application/octet-stream": instantiateStreaming
PASS Response with Content-Type "text/wasm": compileStreaming
PASS Response with Content-Type "text/wasm": instantiateStreaming
FAIL Response with Content-Type "application/wasm;": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;x": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;x": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;charset=UTF-8": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;charset=UTF-8": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
PASS Response with Content-Type "application/wasm": compileStreaming
FAIL Response with Content-Type "application/wasm": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
PASS Response with Content-Type "APPLICATION/wasm": compileStreaming
FAIL Response with Content-Type "APPLICATION/wasm": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
PASS Response with Content-Type "APPLICATION/WASM": compileStreaming
FAIL Response with Content-Type "APPLICATION/WASM": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
Harness: the test ran to completion.
......@@ -40,6 +40,15 @@ for (const contenttype of validContentTypes) {
promise_test(async t => {
const response = fetch(`/wasm/incrementer.wasm?pipe=header(Content-Type,${encodeURIComponent(contenttype)})`);
const result = await WebAssembly.instantiateStreaming(response);
assert_WebAssemblyInstantiatedSource(result);
assert_WebAssemblyInstantiatedSource(
result,
{
"increment": {
"kind": "function",
"name": "0",
"length": 1
}
}
);
}, `Response with Content-Type ${format_value(contenttype)}: instantiateStreaming`);
}
This is a testharness.js-based test.
PASS Response with Content-Type "": compileStreaming
PASS Response with Content-Type "": instantiateStreaming
PASS Response with Content-Type "application/javascript": compileStreaming
PASS Response with Content-Type "application/javascript": instantiateStreaming
PASS Response with Content-Type "application/octet-stream": compileStreaming
PASS Response with Content-Type "application/octet-stream": instantiateStreaming
PASS Response with Content-Type "text/wasm": compileStreaming
PASS Response with Content-Type "text/wasm": instantiateStreaming
FAIL Response with Content-Type "application/wasm;": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;x": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;x": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;charset=UTF-8": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;charset=UTF-8": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
PASS Response with Content-Type "application/wasm": compileStreaming
FAIL Response with Content-Type "application/wasm": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
PASS Response with Content-Type "APPLICATION/wasm": compileStreaming
FAIL Response with Content-Type "APPLICATION/wasm": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
PASS Response with Content-Type "APPLICATION/WASM": compileStreaming
FAIL Response with Content-Type "APPLICATION/WASM": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Response with Content-Type "": compileStreaming
PASS Response with Content-Type "": instantiateStreaming
PASS Response with Content-Type "application/javascript": compileStreaming
PASS Response with Content-Type "application/javascript": instantiateStreaming
PASS Response with Content-Type "application/octet-stream": compileStreaming
PASS Response with Content-Type "application/octet-stream": instantiateStreaming
PASS Response with Content-Type "text/wasm": compileStreaming
PASS Response with Content-Type "text/wasm": instantiateStreaming
FAIL Response with Content-Type "application/wasm;": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;x": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;x": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;charset=UTF-8": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;charset=UTF-8": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
PASS Response with Content-Type "application/wasm": compileStreaming
FAIL Response with Content-Type "application/wasm": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
PASS Response with Content-Type "APPLICATION/wasm": compileStreaming
FAIL Response with Content-Type "APPLICATION/wasm": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
PASS Response with Content-Type "APPLICATION/WASM": compileStreaming
FAIL Response with Content-Type "APPLICATION/WASM": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Response with Content-Type "": compileStreaming
PASS Response with Content-Type "": instantiateStreaming
PASS Response with Content-Type "application/javascript": compileStreaming
PASS Response with Content-Type "application/javascript": instantiateStreaming
PASS Response with Content-Type "application/octet-stream": compileStreaming
PASS Response with Content-Type "application/octet-stream": instantiateStreaming
PASS Response with Content-Type "text/wasm": compileStreaming
PASS Response with Content-Type "text/wasm": instantiateStreaming
FAIL Response with Content-Type "application/wasm;": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;x": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;x": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;charset=UTF-8": compileStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL Response with Content-Type "application/wasm;charset=UTF-8": instantiateStreaming assert_unreached: Should have rejected: undefined Reached unreachable code
PASS Response with Content-Type "application/wasm": compileStreaming
FAIL Response with Content-Type "application/wasm": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
PASS Response with Content-Type "APPLICATION/wasm": compileStreaming
FAIL Response with Content-Type "APPLICATION/wasm": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
PASS Response with Content-Type "APPLICATION/WASM": compileStreaming
FAIL Response with Content-Type "APPLICATION/WASM": instantiateStreaming assert_array_equals: matching export keys lengths differ, expected array [] length 0, got ["increment"] length 1
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment