This commit adds support to the `wasm-bindgen-test-runner` binary to
perform headless testing via browsers. The previous commit introduced a
local server to serve up files and run tests in a browser, and this
commit adds support for executing that in an automated fashion.
The general idea here is that each browser has a binary that implements
the WebDriver specification. These binaries (typically `foodriver` for
the browser "Foo") are interfaced with using HTTP and JSON messages. The
implementation was simple enough and the crates.io support was lacking
enough that a small implementation of the WebDriver protocol was added
directly to this crate.
Currently Firefox (`geckodriver`), Chrome (`chromedriver`), and Safari
(`safaridriver`) are supported for running tests. The test harness will
recognize env vars like `GECKODRIVER=foo` to specifically use one or
otherwise detects the first driver in `PATH`. Eventually we may wish to
automatically download a driver if one isn't found, but that isn't
implemented yet.
Headless testing is turned on with the `CI=1` env var currently to be
amenable with things like Travis and AppVeyor, but this may wish to grow
an explicit option to run headless tests in the future.
This commit updates the test harness for in-browser testing. It now no longer
unconditionally uses `fs.writeSync`, for example. Instead a `Formatter` trait is
introduced for both Node/browser environments and at runtime we detect which is
the appropriate one to use.
This commit starts to add support for in-browser testing with
`wasm-bindgen-test-runner`. The current idea here is that somehow it'll be
configured and it'll spawn a little HTTP server serving up files from the
filesystem. This has been tested in various ways but isn't hooked up just yet,
wanted to make sure this was somewhat standalone! Future support for actually
running these tests will be coming in later commits.
This commit moves the `webidl/tests` folder to a new `crates/webidl-tests` crate
(to have a test-only build script) and ports them to the `#[wasm_bindgen_test]`
attribute, which should hopefully make testing much speedier for execution!
* Fix importing the same identifier from two modules
This needed a fix in two locations:
* First the generated descriptor function needed its hash to include the module
that the import came from in order to generate unique descriptor functions.
* Second the generation of the JS shim needed to handle duplicate identifiers in
a more uniform fashion, ensuring that imported names didn't clash.
* Fix importing the same name in two modules
Previously two descriptor functions with duplicate symbols were emitted, and now
only one function is emitted by using a global table to keep track of state
across macro invocations.
* Add renaming of conflicting constructors and operations
* Rename conflicting to overloaded
* Fix newlines
* Use or_insert_with, add a comment to TypeToString
* Use more Rust-like names
* Use opt instead of nullable
* Use argument names instead of argument types if possible
* Drop new for overloaded constructots
* Remove extra newline
* Move WebIDL files from unavailable_overloaded_fn
* Move RTCDataChannel, RTCPeerConnection and Selection to unavailable_option_primitive
* Create bindings for RegExp
* Address review comments
- Split the constructor into two: `new` and `new_regexp`. This way we
can write RegExp::new("foo", "g") rather than
RegExp::new(&JsValue::from("foo"), "g").
- The js_name for the setter for lastIndex should be `lastIndex` and
not `set_lastIndex`. But fixing this causes a panic. Remove the
method for now.
* Try to enable all webidls
* Separate out unavailable webidl files by reason.
* Create record of fully tested WebIDL files
* Update notes to reflect new situation with web-idl
* Make a blank ident fail, disable the necessary widls.
It turns out that all the blank idents came from blank enum variants,
which is allowed in webidl apparently.
* Adding in initial support for all HTML*Element interfaces.
* Fix camelcasing of short HTML interface names
* Disabling span test as breaks on taskcluster
The JS iterator protocol uses duck typing and we don't need separate
ArrayIterator and SetIterator etc types, we can have a single iterator type for
the whole protocol.
Currently it generates a lot of shim functions which delegate to the wasm module
when loaded, but it turns out with `export let` we can just update the bindings!
Instead of exporting a bunch of shims this updates the export functionality to
only update the `export let` directives with the direct values from the wasm
module once the module is done loading.
In addition to being more ergonomic these are much more efficient at reading
large files as they preallocate internally. This provides a nice speed boost
locally, reducing the overhead of `wasm-bindgen-test-runner` from 0.23s to
0.19s, yay!
This commit updates the test runner to only deserialize a `Module` once and then
directly pass it to the `wasm-bindgen` config, avoiding pulling in a public
dependency with the same strategy as the `wasm-gc-api` crate for now.
This reduces the runtime of this step for `wasm-bindgen-test-runner` from ~0.23s
to ~0.19s on my machine.
Since `wasmi` already has a public dependency on `parity_wasm` let's just use
it! A `clone` is much faster than a serialize + parse, reducing a `wasm-bindgen`
invocation on my machine from 0.2s to 0.18s.
Currently the `wasm-gc-api` crate doesn't expose `parity_wasm::Module` as a
public dependency which means that whenever we want to run a GC (which is twice
per `wasm-bindgen` invocation) we have to serialize and reparse the module a
lot! The `wasm-bindgen` has to serialize, `wasm-gc` then parses, `wasm-gc` then
serializes, and `wasm-bindgen` then parses.
This commit sidesteps all of these operations by ensuring that we always use the
same `parity_wasm::Module` instance, even when multiple versions of the
`parity_wasm` crate are in use. We'll get a speed boost when they happen to
align (which they always should for `wasm-bindgen`), but it'll work even if they
aren't aligned (by going through serialization).
Concretely on my machine this takes a `wasm-bindgen` invocation from 0.5s to
0.2s, a nice win!
This is a bit of a refinement of the solution from #548 to make sure that these
statics are only present on the `wasm32-*` targets, as otherwise these
descriptors are completely inert on other platforms!