WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 939d97e

Browse files
authored
[js-api][web-api] Use the 'react' algorithm from WebIDL (#1835)
* [web-api] Use the 'react' algorithm from WebIDL Fixes #1834. * [js-api] Use the 'react' algorithm from WebIDL
1 parent f915557 commit 939d97e

File tree

2 files changed

+35
-31
lines changed

2 files changed

+35
-31
lines changed

document/js-api/index.bs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,15 +639,17 @@ The verification of WebAssembly type requirements is deferred to the
639639
To <dfn>instantiate a promise of a module</dfn> |promiseOfModule| with imports |importObject|, perform the following steps:
640640

641641
1. Let |promise| be [=a new promise=].
642-
1. [=Upon fulfillment=] of |promiseOfModule| with value |module|:
643-
1. [=asynchronously instantiate a WebAssembly module|Instantiate the WebAssembly module=] |module| importing |importObject|, and let |innerPromise| be the result.
644-
1. [=Upon fulfillment=] of |innerPromise| with value |instance|.
645-
1. Let |result| be the {{WebAssemblyInstantiatedSource}} value «[ "{{WebAssemblyInstantiatedSource/module}}" → |module|, "{{WebAssemblyInstantiatedSource/instance}}" → |instance| ]».
646-
1. [=Resolve=] |promise| with |result|.
647-
1. [=Upon rejection=] of |innerPromise| with reason |reason|:
642+
1. [=React=] to |promiseOfModule|:
643+
* If |promiseOfModule| was fulfilled with value |module|:
644+
1. [=asynchronously instantiate a WebAssembly module|Instantiate the WebAssembly module=] |module| importing |importObject|, and let |innerPromise| be the result.
645+
1. [=React=] to |innerPromise|:
646+
* If |innerPromise| was fulfilled with value |instance|.
647+
1. Let |result| be the {{WebAssemblyInstantiatedSource}} value «[ "{{WebAssemblyInstantiatedSource/module}}" → |module|, "{{WebAssemblyInstantiatedSource/instance}}" → |instance| ]».
648+
1. [=Resolve=] |promise| with |result|.
649+
* If |innerPromise| was rejected with reason |reason|:
650+
1. [=Reject=] |promise| with |reason|.
651+
* If |promiseOfModule| was rejected with reason |reason|:
648652
1. [=Reject=] |promise| with |reason|.
649-
1. [=Upon rejection=] of |promiseOfModule| with reason |reason|:
650-
1. [=Reject=] |promise| with |reason|.
651653
1. Return |promise|.
652654
</div>
653655

document/web-api/index.bs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,30 +117,32 @@ Note: This algorithm accepts a {{Response}} object, or a
117117
{{CompileError}} or other relevant error type, depending on the cause of failure.
118118

119119

120-
1. Let |returnValue| be [=a new promise=]
121-
1. [=Upon fulfillment=] of |source| with value |unwrappedSource|:
122-
1. Let |response| be |unwrappedSource|'s [=Response/response=].
123-
1. Let |mimeType| be the result of [=header list/getting=] `` `Content-Type` `` from |response|'s [=response/header list=].
124-
1. If |mimeType| is null, reject |returnValue| with a {{TypeError}} and abort these substeps.
125-
1. Remove all [=HTTP tab or space byte=] from the start and end of |mimeType|.
126-
1. If |mimeType| is not a [=byte-case-insensitive=] match for `` `application/wasm` ``, reject |returnValue| with a {{TypeError}} and abort these substeps.
127-
128-
Note: extra parameters are not allowed, including the empty `` `application/wasm;` ``.
129-
130-
1. If |response| is not [=CORS-same-origin=], [=reject=] |returnValue| with a {{TypeError}} and abort these substeps.
131-
1. If |response|'s [=response/status=] is not an [=ok status=], [=reject=] |returnValue| with a {{TypeError}} and abort these substeps.
132-
1. [=Consume body|Consume=] |response|'s body as an {{ArrayBuffer}}, and let |bodyPromise| be the result.
133-
134-
Note: Although it is specified here that the response is consumed entirely before compilation proceeds, that is purely for ease of specification; implementations are likely to instead perform processing in a streaming fashion. The difference is unobservable, and thus the simpler model is specified. <!-- Using consume is a bit silly as it creates an ArrayBuffer but then we just want the underlying bytes. This is because of how streams is specced in terms of promises and JS objects whereas we want to operate more directly on the underlying concept. We can revisit this if things change in the Streams/Fetch specs. -->
135-
136-
1. [=Upon fulfillment=] of |bodyPromise| with value |bodyArrayBuffer|:
137-
1. Let |stableBytes| be a [=get a copy of the buffer source|copy of the bytes held by the buffer=] |bodyArrayBuffer|.
138-
1. [=Asynchronously compile a WebAssembly module|Asynchronously compile the WebAssembly module=] |stableBytes| using the [=networking task source=] and |options| and [=resolve=] |returnValue| with the result.
139-
1. [=Upon rejection=] of |bodyPromise| with reason |reason|:
120+
1. Let |returnValue| be [=a new promise=].
121+
1. [=React=] to |source|:
122+
* If |source| was fulfilled with value |unwrappedSource|:
123+
1. Let |response| be |unwrappedSource|'s [=Response/response=].
124+
1. Let |mimeType| be the result of [=header list/getting=] `` `Content-Type` `` from |response|'s [=response/header list=].
125+
1. If |mimeType| is null, reject |returnValue| with a {{TypeError}} and abort these substeps.
126+
1. Remove all [=HTTP tab or space byte=] from the start and end of |mimeType|.
127+
1. If |mimeType| is not a [=byte-case-insensitive=] match for `` `application/wasm` ``, reject |returnValue| with a {{TypeError}} and abort these substeps.
128+
129+
Note: extra parameters are not allowed, including the empty `` `application/wasm;` ``.
130+
131+
1. If |response| is not [=CORS-same-origin=], [=reject=] |returnValue| with a {{TypeError}} and abort these substeps.
132+
1. If |response|'s [=response/status=] is not an [=ok status=], [=reject=] |returnValue| with a {{TypeError}} and abort these substeps.
133+
1. [=Consume body|Consume=] |response|'s body as an {{ArrayBuffer}}, and let |bodyPromise| be the result.
134+
135+
Note: Although it is specified here that the response is consumed entirely before compilation proceeds, that is purely for ease of specification; implementations are likely to instead perform processing in a streaming fashion. The difference is unobservable, and thus the simpler model is specified. <!-- Using consume is a bit silly as it creates an ArrayBuffer but then we just want the underlying bytes. This is because of how streams is specced in terms of promises and JS objects whereas we want to operate more directly on the underlying concept. We can revisit this if things change in the Streams/Fetch specs. -->
136+
137+
1. [=React=] to |bodyPromise|:
138+
* If |bodyPromise| was fulfilled with value |bodyArrayBuffer|:
139+
1. Let |stableBytes| be a [=get a copy of the buffer source|copy of the bytes held by the buffer=] |bodyArrayBuffer|.
140+
1. [=Asynchronously compile a WebAssembly module|Asynchronously compile the WebAssembly module=] |stableBytes| using the [=networking task source=] and |options| and [=resolve=] |returnValue| with the result.
141+
* If |bodyPromise| was rejected with reason |reason|:
142+
1. [=Reject=] |returnValue| with |reason|.
143+
* If |source| was rejected with reason |reason|:
140144
1. [=Reject=] |returnValue| with |reason|.
141-
1. [=Upon rejection=] of |source| with reason |reason|:
142-
1. [=Reject=] |returnValue| with |reason|.
143-
1. Return |returnValue|.
145+
1. Return |returnValue|.
144146
</div>
145147

146148
<h2 id="serialization">Serialization</h2>

0 commit comments

Comments
 (0)