Commit Graph

442 Commits

Author SHA1 Message Date
data-pup
32fa5724dd Set.prototype.forEach and Array.prototype.forEach (#504)
* Array.prototype.forEach binding.

* Set.prototype.forEach binding.
2018-07-18 13:32:07 -05:00
data-pup
f0dcdc249c Map.prototype.forEach binding. (#501) 2018-07-18 10:30:52 -05:00
Sendil Kumar N
bc474aceba Expose math.random, string.endswith, string.normalize, string.repeat, escape() JSBindings (#499)
* add math.random

* add ends with

replace length with variable

* add normalize

* add repeat

* add escape
2018-07-18 09:56:15 -05:00
Craig Disselkoen
a05d930a38 Bindings for TypedArray subclasses (#486)
* Bindings for TypedArray subclasses

* Fill with Rust values rather than JsValues
2018-07-17 18:24:56 -05:00
Alex Crichton
bf64f74cab
Fix symbol conflicts defined in two crates (#496)
Not a lot of attention has been paid to dealing with conflicts of symbols
between crates and different `#[wasm_bindgen]` blocks. This commit starts to fix
this issue by unblocking #486 which first ran into this. Currently there's a bug
where if two independent crates bind the same JS API they'll generate the same
symbol which causes conflicts for things like LTO or linking in general.

This commit starts to add a "salt" to all symbols generated by `wasm-bindgen`
(these are all transparent to the user) to ensure that each crate's invocations
are kept apart from one another and using the correct bindings.
2018-07-17 18:24:48 -05:00
data-pup
c26caf6354 String - padEnd, padStart (#493) 2018-07-17 16:56:16 -05:00
data-pup
5f2f30dba1 String - lastIndexOf (#490) 2018-07-17 12:12:36 -05:00
Alex Crichton
ed05c7b945
Fix compile on latest nightly (#489) 2018-07-17 09:11:30 -05:00
Tomohide Takao
babc2134e1 Remove target_args from Array.find_index() (#479) 2018-07-14 23:10:27 -05:00
R. Andrew Ohana
16cbca74e2 deal with yet another locale/platform issue (#480)
This test fails on my system. As previously decided, until we can
figure out a better solution for this issue, for now we just check
to make sure the output is a non-empty string.
2018-07-14 22:45:49 -05:00
Tomohide Takao
7a7bc6d22e Bindings for Array.prototype.toLocaleString() 2018-07-14 19:45:22 +09:00
Tomohide Takao
f5035c3841 Bindings for Array.prototype.findIndex() 2018-07-14 19:33:48 +09:00
Tomohide Takao
a7deb69e80 Bindings for Array.prototype.reduce(Right) 2018-07-12 23:53:26 +09:00
Liigo Zhuang
e666371ae3 some fix 2018-07-12 10:11:44 +08:00
Liigo Zhuang
823e5a4fd9 fix test 2018-07-12 09:55:34 +08:00
Liigo Zhuang
79f53b567b js::DataView binding 2018-07-12 09:55:33 +08:00
T. Nagasawa
5ce424e57b bindings for Date.prototype.setUTCXXX() (#456) 2018-07-11 09:27:59 -05:00
Tomohide Takao
d7857da262 binding for Array.prototype.map() 2018-07-11 07:20:52 +09:00
Nick Fitzgerald
92dd8e859f Move webidl tests to the webidl crate's test suite (#451)
* webidl: Remove exact-output tests

These have not been as effective, nor as easy to write and maintain, as the
project()-based integration tests.

* tests: Move webidl tests into the webidl crate's test suite
2018-07-10 16:17:33 -05:00
Nick Fitzgerald
42938792c7
Merge pull request #430 from FreeMasen/js_docs
Js docs
2018-07-10 10:08:41 -07:00
Nick Fitzgerald
7200d36fb6
Merge pull request #438 from toVersus/js_date
bindings for Date.setXXX
2018-07-10 10:04:36 -07:00
Satoshi Amemiya
8be0a98386 Add support for methods of Symbol (#437) 2018-07-10 09:46:05 -05:00
toversus
d2feddcf90 fix to have no impact on timezones difference 2018-07-10 23:31:25 +09:00
Robert Masen
c7d98b9ee1 add js doc @param and @returns annotations 2018-07-10 08:42:34 -05:00
toversus
91d6ae5f04 binding for Date.prototype.setTime() 2018-07-10 21:46:44 +09:00
toversus
c185897eff binding for Date.prototype.setSeconds() 2018-07-10 21:45:33 +09:00
toversus
609d457301 binding for Date.prototype.setMonth() 2018-07-10 21:27:12 +09:00
toversus
a81827caf9 binding for Date.prototype.setMinutes() 2018-07-10 21:20:18 +09:00
toversus
11a58a1bd0 binding for Date.prototype.setMilliseconds() 2018-07-10 20:55:45 +09:00
toversus
524628e1e1 binding for Date.prototype.setHours() 2018-07-10 20:51:39 +09:00
toversus
d555b7f068 binding for Date.prototype.setFullYear() 2018-07-10 20:45:25 +09:00
toversus
1a8da45340 binding for Date.prototype.setDate() 2018-07-10 20:38:54 +09:00
Nick Fitzgerald
f2f2d7231a
Create the web-sys crate mechanically from WebIDL (#409)
* Create a new `web-sys` crate

This will eventually contain all the WebIDL-generated bindings to Web APIs.

* ci: Test the new `web-sys` crate in CI

* web-sys: Add a small README

* web-sys: Vendor all the WebIDL files from mozilla-central

* backend: Add a pass to remove AST items that use undefined imports

This is necessary for the WebIDL frontend, which can't translate many WebIDL
constructs into equivalent wasm-bindgen AST things yet. It lets us make
incremental progress: we can generate bindings to methods we can support right
now even though there might be methods on the same interface that we can't
support yet.

* webidl: Add a bunch of missing semicolons

* webidl: Make parsing private

It was only `pub` so that we could test it, but we ended up moving towards
integration tests rather than unit tests that assert particular ASTs are parsed
from WebIDL files.

* webidl: Remove uses of undefined import types

* test-project-builder: Build projects in "very verbose" mode

This helps for debugging failing WebIDL-related tests.

* test-project-builder: Add more profiling timers

* test-project-builder: Detect when webpack-dev-server fails

Instead of going into an infinite loop, detect when webpack-dev-server fails to
start up and early exit the test.

* webidl: Specify version for dev-dependency on wasm-bindgen-backend

Instead of only a relative path.

* guide: Add section about contributing to `web-sys`

* WIP enable Event.webidl

Still need to fix and finish the test.

* Update expected webidl output

* Start out a test's status as incomplete

That way if we don't fill it in the error message doesn't look quite so bizarre

* Fix onerror function in headless mode

Otherwise we don't see any output!

* Fix package.json/node_modules handling in project generation

Make sure these are looked up in the git project root rather than the crate root

* Avoid logging body text

This was meant for debugging and is otherwise pretty noisy

* Fix a relative path

* More expected test fixes

* Fix a typo

* test-project-builder: Allow asynchronous tests

* webidl: Convert [Unforgeable] attributes into `#[wasm_bindgen(structural)]`

Fixes #432

* test-project-builder: Print generated WebIDL bindings for debugging purposes

Helps debug bad WebIDL bindings generation inside tests.

* When we can't find a descriptor, say which one can't be found

This helps when debugging things that need to become structural.

* web-sys: Test bindings for Event

* ci: Use `--manifest-path dir` instead of `cd dir && ...`

* web-sys: Just move .webidl files isntead of symlinking to enable them

* tests: Polyfill Array.prototype.values for older browsers in CI

* test-project-builder: Don't panic on poisoned headless test mutex

We only use it to serialize headless tests so that we don't try to bind the port
concurrently. Its OK to run another headless test if an earlier one panicked.

* JsValue: Add {is,as}_{object,function} methods

Allows dynamically casting values to `js::Object` and `js::Function`.

* tidy: Fix whitespace and missing semicolons

* Allow for dynamic feature detection of methods

If we create bindings to a method that doesn't exist in this implementation,
then it shouldn't fail until if/when we actually try and invoke that missing
method.

* tests: Do feature detection in Array.prototype.values test

* Add JsValue::{is_string, as_js_string} methods

And document all the cast/convert/check methods for js value.

* eslint: allow backtick string literals

* Only generate a fallback import function for non-structural imports
2018-07-09 16:35:25 -07:00
Nick Fitzgerald
2b5dd430a8
Merge pull request #428 from alexcrichton/missing-docs
Fix some cases with `#[deny(missing_docs)]`
2018-07-09 11:01:05 -07:00
Michael Hoffmann
bae324c951 Add Array.prototype.values binding (#395) 2018-07-09 12:42:30 -05:00
Nick Fitzgerald
21cb50ef05
Merge pull request #412 from matiasinsaurralde/intl
Add bindings for `Intl`
2018-07-09 10:31:22 -07:00
Alex Crichton
b4c7a5c1e1 Fix some cases with #[deny(missing_docs)]
Generated functions by wasm-bindgen should either be `#[doc(hidden)]` or include
the docs on the original item!

Closes #425
2018-07-09 08:49:16 -07:00
Liigo Zhuang
bfec9e6401 bindings for parseInt/parseFloat (#384)
* parseInt, parseFloat, JsValue::is_nan

* Number.parseInt, Number.parseFloat

* remove `JsValue::is_nan`

* parse_int/float returns f64
2018-07-09 08:59:54 -05:00
toversus
5bfde7778d binding for Date.prototype.getUTCSeconds() 2018-07-09 18:20:04 +09:00
toversus
15d9f743ec binding for Date.prototype.getUTCMonth() 2018-07-09 18:08:38 +09:00
toversus
2e85bbd9e0 binding for Date.prototype.getUTCMinutes() 2018-07-09 18:04:20 +09:00
toversus
c260ac7c3e binding for Date.prototype.getUTCMilliseconds() 2018-07-09 17:59:15 +09:00
toversus
6aa3661e11 binding for Date.prototype.getUTCHours() 2018-07-09 17:54:19 +09:00
toversus
975818a1f6 binding for Date.prototype.getUTCFullYear() 2018-07-09 17:50:13 +09:00
toversus
ea19848691 binding for Date.prototype.getUTCDay() 2018-07-09 17:46:21 +09:00
toversus
792baefc22 binding for Date.prototype.getUTCDate() 2018-07-09 17:42:30 +09:00
toversus
d3a17d4014 binding for Date.prototype.getTimezoneOffset() 2018-07-09 17:38:38 +09:00
Alexander Kryvomaz
6758525980 bindings for isFinite(), Number.isFinite() and Number.isSafeInteger() (#420)
* bindings for isFinite()

* bindings for Number.isFiniter(), refactoring of Number.isInteger()

* bindings for Number.isSafeInteger()
2018-07-08 10:03:10 -05:00
Alex Crichton
791e69a5c0
Generate normal Rust functions for imported bindings (#410)
* Generate normal Rust functions for imported bindings

No need to use the C ABI, it just mixes up the documentation!

* Update expected webidl output
2018-07-07 12:20:42 -05:00
T. Nagasawa
056b45aeed bindings for Date.parse and Date.getXXX (#414)
* binding for Date.prototype.getHours()

* binding for Date.prototype.getMilliseconds()

* binding for Date.prototype.getMinutes()

* binding for Date.prototype.getMonth()

* binding for Date.prototype.getSeconds()

* binding for Date.prototype.getTime()

* binding for Date.parse()
2018-07-07 12:09:46 -05:00
Matias Insaurralde
8352b4610f
Add bindings for Intl.getCanonicalLocales 2018-07-07 08:00:22 -04:00
Alex Crichton
ef807a8068 Tweak some docs and fixup some symbol tests 2018-07-06 20:00:53 -07:00
Nick Fitzgerald
a526be9baf
Merge pull request #401 from rail44/support-symbol
Add support for static props of Symbol
2018-07-06 09:15:36 -07:00
Marcin Baraniecki
83a7d5bfdc
Merge pull request #399 from alexcrichton/jsvalue-debug
Implement `Debug for JsValue`
2018-07-06 13:36:17 +02:00
Marcin Baraniecki
c9f4a266b0
Merge pull request #386 from jannikkeye/bindings-reflect
Reflect.xx bindings
2018-07-06 13:34:59 +02:00
Marcin Baraniecki
f7dc819289
Merge pull request #387 from Hywan/webassembly
feat(js) Implement the `WebAssembly.validate` binding.
2018-07-06 13:33:37 +02:00
Ivan Enderlin
b4bf8fbfba
test(js) New WebAssembly.validate_with_invalid_input test case. 2018-07-06 10:41:51 +02:00
Ivan Enderlin
d1955c91b7
test(js) Don't unwrap to false. 2018-07-06 10:41:32 +02:00
Satoshi Amemiya
6e4948d983 Add support for static props of Symbol 2018-07-06 17:07:43 +09:00
Jannik Keye
2022b44416 fix: convert tests to plain js 2018-07-06 09:41:08 +02:00
Jannik Keye
99d66ad6ed merge master 2018-07-06 09:31:58 +02:00
Sendil Kumar N
a65b6c7003
Merge pull request #397 from ZerothLaw/Issue275/ArrayFind
Issue #275: Added Array.prototype.find binding
2018-07-06 09:22:46 +02:00
Sendil Kumar N
142d7377e2
Merge pull request #400 from alexcrichton/derive-import
Forward attributes on `type` declaration to definition
2018-07-06 09:21:01 +02:00
Satoshi Amemiya
1bcfcaf1ed TypeScript is no longer enabled 2018-07-06 15:41:07 +09:00
Satoshi Amemiya
bd068207a1 Fix test of Symbol.hasInstance 2018-07-06 14:57:22 +09:00
Satoshi Amemiya
2518048f25 Add support Symbol.hasInstance as sample of static prop getter 2018-07-06 14:57:17 +09:00
Alex Crichton
5a776c16b2 Forward attributes on type declaration to definition
This'll allow things like `#[derive(Clone)]` or `#[derive(Debug)]` to control
traits for these types.
2018-07-05 20:28:52 -07:00
Alex Crichton
d930a5a97a Implement Debug for JsValue 2018-07-05 20:24:28 -07:00
Tyler Laing
d29b17f158 Issue #275: Added Array.prototype.find binding 2018-07-05 15:05:23 -07:00
Nick Fitzgerald
bc2eab1434
Merge pull request #396 from fitzgen/pull-project-testing-out-into-its-own-crate
tests: Pull the `project()` builder out into its own crate
2018-07-05 15:01:21 -07:00
Nick Fitzgerald
549e5a9be9 tests: Pull the project() builder out into its own crate
The WebIDL-based -sys crate will also use this, but I want its tests to be a
separate suite that we can run separately and in parallel in CI. Therefore, this
testing infrastructure code needs to be share-able between them :)
2018-07-05 14:27:26 -07:00
Nick Fitzgerald
7ff90f1490 js: Return scalar types instead of Number objects
99% of the time we don't want to deal with opaque handles to `Number`
objects.
2018-07-05 13:02:40 -07:00
Sendil Kumar N
52a00d5e16
Merge pull request #392 from brisad/add-more-bindings
Add bindings in Date and Number
2018-07-05 19:51:58 +02:00
Michael Hoffmann
9f3722bbd9 Change assert to assert.ok to fix test 2018-07-05 17:34:45 +02:00
Michael Hoffmann
260183a522 Add binding for Number.isInteger 2018-07-05 17:09:59 +02:00
Michael Hoffmann
9d3b26341e Add binding for Date.prototype.getDate 2018-07-05 17:09:59 +02:00
Nick Fitzgerald
59b3b4dc8d Headless browser testing infrastructure (#371)
* tests: Add newlines between impl methods for Project

* WIP headless browser testing with geckodriver and selenium

* Get some more of headless testing working

* Extract `console.log` invocations and print them from the console
* Ship the error message from an exception from the browser back to the command
  line
* Cleanup some "if headless" and `else` branches
* Fix killing `webpack-dev-server` in the background with `--watch-stdin`

* Fix path appending logic for Windows

* Always log logs/errors in headless mode

* Install Firefox on Travis

* Don't duplicate full test suite with `yarn`

No need to run that many tests, we should be able to get by with a smoke test
that it just works.

* headless tests: Move `run-headless.js` to its own file and `include_str!` it

* Run `rustfmt` on `tests/all/main.rs`

* guide: Add note about headless browser tests and configuration

* test: Log WASM_BINDGEN_FIREFOX_BIN_PATH in run-headless.js

* TEMP only run add_headless test in CI

* Add more logging to headless testing

* Allow headless tests to run for 60 seconds before timeout

* TEMP add logging to add_headless test

* Fix headless browser tests

* Another attempt to fix Travis

* More attempts at debugging

* Fix more merge conflicts

* Touch up an error message

* Fixup travis again

* Enable all travis tests again

* Test everything on AppVeyor
2018-07-05 09:22:01 -05:00
Stephan Renatus
06b8d3535d js_globals::Proxy::*: make tests plain JS
Signed-off-by: Stephan Renatus <srenatus@chef.io>
2018-07-05 09:03:16 +02:00
Jannik Keye
8dd8475000 fix: Reflec.defineProperty no longer returns Result 2018-07-05 08:33:22 +02:00
Stephan Renatus
b704ceeb3a Bindings for Proxy.revocable()
Signed-off-by: Stephan Renatus <srenatus@chef.io>
2018-07-05 08:04:41 +02:00
Stephan Renatus
2b8e789c9c Bindings for Proxy.new()
Signed-off-by: Stephan Renatus <srenatus@chef.io>
2018-07-05 08:04:41 +02:00
Alex Crichton
efa4a2b8fa
Speed up Travis by running Webpack in fewer tests (#381)
* Reorganize Travis configuration

* Add a `JOB` env var descriptor to all matrix entries. Not used anywhere but is
  useful when viewing the whole build on Travis's web interface.
* Reorganize where builds are located, moving slow builds first and fast ones
  last.
* Change checking the CLI builds from `cargo build` to `cargo check`
* Use YAML references to reduce some duplication

* Print some more timing statistics for each test

* Extract `Project` helper in tests to a module

This'll help make it a bit more extensible over time. At the same time the
methods are also slightly reorganized to read more clearly from top to bottom.

* Migrate all tests away from Webpack

Wepback can take a significant amount of time to execute and when it's
multiplied by hundreds of tests that adds up really quickly! After investigating
Node's `--experimental-modules` option it looks like it's suitable for our use
so this switches all tests to using JS files (moving away from TypeScript as
well) with `--experimental-modules` with Node.

Tests will be selectively re-enabled with webpack and node.js specific output
(that doesn't require `--experimental-modules`), coming in later commits.

* Restore the node test for node.js output

Ensures it's workable as-is

* Only generate typescript with webpack

* Only read wasm files for webpack

* Skip package.json/node_modules for now

* Only generate webpack config if needed

* Start a dedicated test module for typescript

Will hopefully verify the generated Typescript compiles OK.

* Remove unneeded `node` method

* Fixup some rebase conflicts

* Don't run asmjs example on travis

* Fixup generator tests

* Attempt to fix windows

* Comment windows fix

* More test fixes

* More exclusions

* More test fixes

* Relax eslint regex

Catch mjs modules as well

* Fix eslint

* Speed up travis on examples slightly
2018-07-04 22:37:09 -05:00
Sendil Kumar N
e912b9d2a2
Merge pull request #374 from Hywan/js_test_date_locale
test(js) Fix expectations regarding given locales
2018-07-04 22:25:05 +02:00
Ivan Enderlin
43de00b347 feat(js) Add ArrayBuffer::new, ::is_view & ::slice bindings. (#388)
* feat(js) Add `ArrayBuffer::new`, `::is_view` & `::slice` bindings.

* fix(js) Fix number units, comments, add `slice_with_end`.

* test(js) Fix a function name.
2018-07-04 13:53:49 -05:00
Ivan Enderlin
f5d4751c0b
test(js) Check the types and lightly the data, but not that much.
Because NodeJS can have different i18n behaviors depending of the
version, let's keep things simple. In this case, we want to test the
types,
period. Cf. https://github.com/rustwasm/wasm-bindgen/pull/374#issuecomment-402447333
2018-07-04 16:47:51 +02:00
Jannik Keye
7790b34c07 fix: simplify signatures to avoid Result usage 2018-07-04 16:10:17 +02:00
Jannik Keye
40b7b069bc fix: return actual error message 2018-07-04 15:52:12 +02:00
Ivan Enderlin
c450fbf237
feat(js) Support exception on WebAssembly::validate. 2018-07-04 15:51:55 +02:00
Jannik Keye
008f17143b fix: Reflect.has target should be &Object 2018-07-04 15:32:34 +02:00
Ivan Enderlin
fe25a9a268
feat(js) Implement the WebAssembly.validate binding. 2018-07-04 15:27:01 +02:00
Marcin Baraniecki
2694dd4dee
Merge pull request #385 from toVersus/js_date
bindings for date.getDay/getFullYear
2018-07-04 14:56:22 +02:00
Jannik Keye
1397f9b05a feat: add Reflect.setPrototypeOf 2018-07-04 13:13:35 +02:00
Jannik Keye
eb3f67a36f feat: add Reflect.set 2018-07-04 13:08:43 +02:00
Jannik Keye
fc82ba4ec3 feat: add Reflect.preventExtensions 2018-07-04 12:56:37 +02:00
Jannik Keye
e36f982391 feat: add Reflect.ownKeys 2018-07-04 12:53:38 +02:00
toversus
e95994fd19 bindings for Date.prototype.getFullYear() 2018-07-04 19:52:12 +09:00
Jannik Keye
eb245d5503 feat: add Reflect.isExtensible 2018-07-04 12:49:07 +02:00
Jannik Keye
7c297ccfb4 feat: add Reflect.has 2018-07-04 12:44:49 +02:00
toversus
3007e813ea bindings for Date.prototype.getDay() 2018-07-04 19:41:06 +09:00
Jannik Keye
edddd4b08e feat: add Reflect.getPrototypeOf 2018-07-04 12:39:56 +02:00