summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp
AgeCommit message (Collapse)Author
2021-11-14LibJS: Annotate Promise implementation with spec commentsLinus Groh
I wanted to do this for a long time. The guts of Promise are pretty complex, and it's easier to understand with the spec right next to it. Also found a couple of issues along the way :^)
2021-10-23LibJS: Convert the NewPromiseCapability AO to ThrowCompletionOrIdan Horowitz
2021-10-23LibJS: Remove vm.construct and it's usagesIdan Horowitz
2021-10-20LibJS: Convert NativeFunction callback to ThrowCompletionOrIdan Horowitz
2021-08-23LibJS: Set the function names for the resolve, reject, and executorTimothy Flynn
These should all have a name with an empty string. Not only does test262 verify this, but it also verifies that (for the executor) the name property is defined after the length property.
2021-08-21LibJS: Fix copy-paste mistake in GetCapabilitiesExecutorTimothy Flynn
2021-07-06LibJS: Add define_direct_property and remove the define_property helperIdan Horowitz
This removes all usages of the non-standard define_property helper method and replaces all it's usages with the specification required alternative or with define_direct_property where appropriate.
2021-06-17LibJS: Fix .length attributes of various native functionsLinus Groh
Namely the Proxy revocation, Promise resolving, Promise then/catch finally, and Promise GetCapabilitiesExecutor functions. They were all missing an explicit 'Attribute::Configurable' argument and therefore incorrectly used the default attributes (writable, enumerable, configurable).
2021-06-13LibJS: Add ECMA-262 section/title/URL comments almost everywhereLinus Groh
As mentioned on Discord earlier, we'll add these to all new functions going forward - this is the backfill. Reasons: - It makes you look at the spec, implementing based on MDN or V8 behavior is a no-go - It makes finding the various functions that are non-compliant easier, in the future everything should either have such a comment or, if it's not from the spec at all, a comment explaining why that is the case - It makes it easier to check whether a certain abstract operation is implemented in LibJS, not all of them use the same name as the spec. E.g. RejectPromise() is Promise::reject() - It makes it easier to reason about vm.arguments(), e.g. when the function has a rest parameter - It makes it easier to see whether a certain function is from a proposal or Annex B Also: - Add arguments to all functions and abstract operations that already had a comment - Fix some outdated section numbers - Replace some ecma-international.org URLs with tc39.es
2021-06-10LibJS: Remove GlobalObject& argument from VM::construct()Andreas Kling
We can just get the global object from the constructor function.
2021-04-22Everywhere: Use linusg@serenityos.org for my copyright headersLinus Groh
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-02LibJS: Add initial support for PromisesLinus Groh
Almost a year after first working on this, it's finally done: an implementation of Promises for LibJS! :^) The core functionality is working and closely following the spec [1]. I mostly took the pseudo code and transformed it into C++ - if you read and understand it, you will know how the spec implements Promises; and if you read the spec first, the code will look very familiar. Implemented functions are: - Promise() constructor - Promise.prototype.then() - Promise.prototype.catch() - Promise.prototype.finally() - Promise.resolve() - Promise.reject() For the tests I added a new function to test-js's global object, runQueuedPromiseJobs(), which calls vm.run_queued_promise_jobs(). By design, queued jobs normally only run after the script was fully executed, making it improssible to test handlers in individual test() calls by default [2]. Subsequent commits include integrations into LibWeb and js(1) - pretty-printing, running queued promise jobs when necessary. This has an unusual amount of dbgln() statements, all hidden behind the PROMISE_DEBUG flag - I'm leaving them in for now as they've been very useful while debugging this, things can get quite complex with so many asynchronously executed functions. I've not extensively explored use of these APIs for promise-based functionality in LibWeb (fetch(), Notification.requestPermission() etc.), but we'll get there in due time. [1]: https://tc39.es/ecma262/#sec-promise-objects [2]: https://tc39.es/ecma262/#sec-jobs-and-job-queues