Skip to content

Commit

Permalink
Rename Response based compile + instantiate *Streaming. (#1068)
Browse files Browse the repository at this point in the history
Clarify how the source parameter is resolved.
Clarify how the result of instantiate* is described.
  • Loading branch information
flagxor authored May 18, 2017
1 parent abb557a commit 89cfa62
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
13 changes: 10 additions & 3 deletions JS.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,19 @@ If neither of the following overloads match, then the returned `Promise` is
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).

```
Promise<{module:WebAssembly.Module, instance:WebAssembly.Instance}>
dictionary WebAssemblyInstantiatedSource {
required WebAssembly.Module module;
required WebAssembly.Instance instance;
};
Promise<WebAssemblyInstantiatedSource>
instantiate(BufferSource bytes [, importObject])
```

This description applies if the first argument is a
[`BufferSource`](https://heycam.github.io/webidl/#common-BufferSource).
If the given `bytes` argument is not a
[`BufferSource`](https://heycam.github.io/webidl/#common-BufferSource),
the returned `Promise` is [rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).

This function starts an asynchronous task that first compiles a `WebAssembly.Module`
from `bytes` as described in the [`WebAssembly.Module` constructor](#webassemblymodule-constructor)
Expand Down
51 changes: 26 additions & 25 deletions Web.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,24 @@ Non-web embeddings are not required to support these additional methods.

:cyclone: Added for milestone 2, developers must feature detect.

In Web embeddings, the following overloads are added (in addition to the core
JS API method of the same name).
In Web embeddings, the following methods are added.

```
Promise<WebAssembly.Module> compile(Response source)
Promise<WebAssembly.Module> compile(Promise<Response> source)
Promise<WebAssembly.Module> compileStreaming(source)
```

Developers can set the argument `source` with either a promise that resolves
with a
`source` is unconditionally passed through the built-in value
of `Promise.resolve`.
If the result is not a `Response` object, then the returned `Promise` is
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
This allows developers to pass either a promise that resolves
to a
[`Response`](https://fetch.spec.whatwg.org/#response-class)
object or a
[`Response`](https://fetch.spec.whatwg.org/#response-class)
object (which is automatically cast to a
promise).
If when unwrapped that `Promise` is not a `Response` object, then the returned `Promise` is
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
promise) for the `source`.
Renderer-side
security checks about tainting for cross-origin content are tied to the types
of filtered responses defined in
Expand All @@ -62,7 +61,7 @@ with the resulting `WebAssembly.Module` object. On failure, the `Promise` is
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise) with a
`WebAssembly.CompileError`.

The `Promise<Response>` is used as the source of the bytes to compile.
The resolved `Response` is used as the source of the bytes to compile.
MIME type information is
[`extracted`](https://fetch.spec.whatwg.org/#concept-header-extract-mime-type)
from the `Response`, WebAssembly `source` data must have a MIME type of `application/wasm`,
Expand All @@ -75,27 +74,29 @@ MIME type mismatch or `opaque` response types

:cyclone: Added for milestone 2, developers must feature detect.

In Web embeddings, the following overloads are added (in addition to the core
JS API method of the same name).
In Web embeddings, the following methods are added.

```
Promise<{module:WebAssembly.Module, instance:WebAssembly.Instance}>
instantiate(Response source [, importObject])
dictionary WebAssemblyInstantiatedSource {
required WebAssembly.Module module;
required WebAssembly.Instance instance;
};
Promise<{module:WebAssembly.Module, instance:WebAssembly.Instance}>
instantiate(Promise<Response> source [, importObject])
Promise<InstantiatedSource> instantiateStreaming(source [, importObject])
```

Developers can set the argument `source` with either a promise that resolves
with a
`source` is unconditionally passed through the built-in value
of `Promise.resolve`.
If the result is not a `Response` object, then the returned `Promise` is
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
This allows developers to pass either a promise that resolves
to a
[`Response`](https://fetch.spec.whatwg.org/#response-class)
object or a
[`Response`](https://fetch.spec.whatwg.org/#response-class)
object (which is automatically cast to a
promise).
If when unwrapped that `Promise` is not a `Response` object, then the returned `Promise` is
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise)
with a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
promise) for the `source`.
Renderer-side
security checks about tainting for cross-origin content are tied to the types
of filtered responses defined in
Expand All @@ -114,7 +115,7 @@ On failure, the `Promise` is
[rejected](http://tc39.github.io/ecma262/#sec-rejectpromise) with a
`WebAssembly.CompileError`, `WebAssembly.LinkError`, or `WebAssembly.RuntimeError`, depending on the cause of failure.

The `Promise<Response>` is used as the source of the bytes to compile.
The resolved `Response` is used as the source of the bytes to compile.
MIME type information is
[`extracted`](https://fetch.spec.whatwg.org/#concept-header-extract-mime-type)
from the `Response`, WebAssembly `source` data must have a MIME type of `application/wasm`,
Expand Down

0 comments on commit 89cfa62

Please sign in to comment.