@@ -66,6 +66,9 @@ spec: WebAssembly; urlPrefix: https://webassembly.github.io/spec/core/
66
66
spec: WebAssembly-js-api; urlPrefix: https://webassembly.github.io/spec/js-api/
67
67
type: dfn
68
68
text: compiling a WebAssembly module; url: #compile-a-webassembly-module
69
+ spec: WebAssembly-web-api; urlPrefix: https://webassembly.github.io/spec/web-api/
70
+ type: dfn
71
+ text: compiling a potential WebAssembly response; url: #compile-a-potential-webassembly-response
69
72
spec: WebIDL; urlPrefix: https://webidl.spec.whatwg.org/
70
73
type: dfn
71
74
text: convert a Web IDL arguments list to an ECMAScript arguments list; url: #web-idl-arguments-list-converting
@@ -2054,23 +2057,52 @@ The <dfn http-header><code>Ad-Auction-Allowed</code></dfn> HTTP response header
2054
2057
[=structured header=] whose value must be a [=structured header/boolean=] .
2055
2058
2056
2059
<div algorithm>
2057
- To <dfn>validate fetching response</dfn> given a [=response=] |response|, null, failure, or a
2058
- [=byte sequence=] |responseBody|, and a [=string=] |mimeType|:
2060
+ To <dfn>validate fetching response headers</dfn> given a [=response=] |response|:
2059
2061
2060
- 1. If |responseBody| is null or failure, return false.
2061
2062
1. If [=header list/getting a structured field value|getting=] [:Ad-Auction-Allowed:] and
2062
- "`item`" from |response|'s [=response/header list=] does not return a true value, return false.
2063
+ "`item`" from |response|'s [=response/header list=] does not return a true value, return false.
2064
+ 1. If |response|'s [=response/status=] is not an [=ok status=] , return false.
2065
+ 1. Return true.
2066
+ </div>
2067
+
2068
+ <div algorithm>
2069
+ To <dfn>validate fetching response mime and body</dfn> given a [=response=] |response|, null,
2070
+ failure, or a [=byte sequence=] |responseBody|, and a [=string=] |mimeType|:
2071
+
2072
+ 1. If |responseBody| is null or failure, return false.
2063
2073
1. Let |headerMimeType| be the result of [=header list/extracting a MIME type=] from |response|'s
2064
2074
[=response/header list=] .
2065
2075
1. Return false if any of the following conditions hold:
2066
2076
* |headerMimeType| is failure;
2067
2077
* |mimeType| is "`text/javascript`" and |headerMimeType| is not a [=JavaScript MIME type=] ;
2068
2078
* |mimeType| is "`application/json`" and |headerMimeType| is not a [=JSON MIME type=] .
2069
- 1. Let |mimeTypeCharset| be |headerMimeType|'s [=MIME type/parameters=] ["`charset`"] .
2070
- 1. Return false if any of the following conditions hold:
2071
- * |mimeTypeCharset| does not [=map/exist=] , or |mimeTypeCharset| is "utf-8", and |responseBody|
2072
- is not [=UTF-8=] encoded;
2073
- * |mimeTypeCharset| is "us-ascii", and not all bytes in |responseBody| are [=ASCII bytes=] .
2079
+ * |mimeType| is "`application/wasm`" and the result of [=header list/getting=] "`Content-Type`"
2080
+ from |response|'s [=response/header list=] is null or not [=byte-case-insensitive=] equal to
2081
+ "`application/wasm`".
2082
+
2083
+ Note: This was intended to match the behavior of [=compiling a potential WebAssembly
2084
+ response=] , but diverges by failing to remove leading and trailing [=HTTP tab or space
2085
+ bytes=] .
2086
+
2087
+ 1. If |mimeType| is not "`application/wasm`":
2088
+ 1. Let |mimeTypeCharset| be "utf-8".
2089
+ 1. If |headerMimeType|'s [=MIME type/parameters=] ["`charset`"] exists, set |mimeTypeCharset|
2090
+ to |headerMimeType|'s [=MIME type/parameters=] ["`charset`"] .
2091
+ 1. Return true if any of the following conditions hold:
2092
+ * |mimeTypeCharset| is "utf-8", and |responseBody| is [=UTF-8=] encoded;
2093
+ * |mimeTypeCharset| is "us-ascii", and all bytes in |responseBody| are [=ASCII bytes=] .
2094
+ 1. Return false.
2095
+ 1. Return true.
2096
+ </div>
2097
+
2098
+ <div algorithm>
2099
+ To <dfn>validate fetching response</dfn> given a [=response=] |response|, null, failure, or a
2100
+ [=byte sequence=] |responseBody|, and a [=string=] |mimeType|:
2101
+
2102
+ 1. If the result of [=validating fetching response headers=] given |response| is false, then
2103
+ return false.
2104
+ 1. If the result of [=validating fetching response mime and body=] given |response|,
2105
+ |responseBody|, |mimeType| is false, then return false.
2074
2106
1. Return true.
2075
2107
</div>
2076
2108
@@ -2135,10 +2167,8 @@ To <dfn>fetch WebAssembly</dfn> given a [=URL=] |url|:
2135
2167
1. Let |moduleObject| be null.
2136
2168
1. [=Fetch=] |request| with [=fetch/processResponseConsumeBody=] set to the following steps given
2137
2169
a [=response=] |response| and null, failure, or a [=byte sequence=] |responseBody|:
2138
- 1. Set |moduleObject| to failure and return, if any of the following conditions hold:
2139
- * |responseBody| is null or failure;
2140
- * [=header list/getting a structured field value|Getting=] [:Ad-Auction-Allowed:] and "`item`"
2141
- from |response|'s [=response/header list=] does not return a true value.
2170
+ 1. If [=validate fetching response=] with |response|, |responseBody| and "`application/wasm`"
2171
+ returns false, set |moduleObject| to failure and return.
2142
2172
1. Let |module| be the result of [=compiling a WebAssembly module=] |response|.
2143
2173
1. If |module| is [=error=] , set |moduleObject| to failure.
2144
2174
1. Otherwise, set |moduleObject| to |module|.
0 commit comments