summaryrefslogtreecommitdiff
path: root/Tests/LibJS
AgeCommit message (Collapse)Author
2022-10-12test262-runner: Use names for the different exit codesdavidot
These are not used by test-test262 but can be used to quickly distinguish the type of problem if the runner fails when running manually.
2022-10-12test262-runner: Port to Core::Streamdavidot
2022-10-12test-test262: Port to Core::Stream and use TRY moredavidot
The only complication here is that Core::Stream::File is not RefCounted meaning we have to use OwnPtr instead of RefPtr. Unfortunately we cannot propagate errors as some errors must be caught and dealt with as the runner can do anything (like stop at any moment or close pipes).
2022-10-12test-test262: Close the output file stream after writingdavidot
Without this the runner is waiting for new tests which will never come and test-test262 is waiting for output which never comes since the runner is blocked. Also finish off a comment, and make the variables follow serenity style.
2022-10-10Everywhere: Replace uses of __serenity__ with AK_OS_SERENITYAndrew Kaster
Now that we have OS macros for essentially every supported OS, let's try to use them everywhere.
2022-09-21AK+LibJS: Handle NaN-boxing pointers on AArch64Daniel Bertalan
JS::Value stores 48 bit pointers to separately allocated objects in its payload. On x86-64, canonical addresses have their top 16 bits set to the same value as bit 47, effectively meaning that the value has to be sign-extended to get the pointer. AArch64, however, expects the topmost bits to be all zeros. This commit gates sign extension behind `#if ARCH(X86_64)`, and adds an `#error` for unsupported architectures, so that we do not forget to think about pointer handling when porting to a new architecture. Fixes #15290 Fixes SerenityOS/ladybird#56
2022-09-14Everywhere: Fix a variety of typosBrian Gianforcaro
Spelling fixes found by `codespell`.
2022-09-13LibJS: Mark test262's __assert_fail as `extern "C"` and useHendiadyoin1
...`__attribute__((__noreturn__))` This is more inline with the definition in glibc's version of the file, and stops clang from complaining about it originally not being declared as `[[no_return]]`.
2022-09-11LibJS: Add the test-test262 utilitydavidot
This allows running of test262 (like) tests with any runner. And thus allows running the full test262 suite on Serenity itself. The functionality of test-test262 is intentionally limited at first. It does support: - Progress updates including the special serenity terminal commands - Outputting a per-file, to compare against other runs - Passing any number of parameters to the runner - Setting the batch size of the amount of tests per runner process - Outputting a summary of the test results
2022-09-11test262-runner: Don't create a VM and Interpreter if just parsingdavidot
If a test is supposed to fail during parse or early phase we can stop after parsing. Because phases in modules are not as clear we don't skip the other parts for modules.
2022-09-11test262-runner: Convert dbgln to warnlndavidot
Since this application is now supposed to be used from within Serenity we should make sure to warn the actual user.
2022-09-11test262-runner: Add option to disable core dumpingdavidot
When running a larger set of tests in Serenity the runner would otherwise trigger a lot of crash reporters. This would then in turn lead to memory starvation causes more crashes.
2022-09-11test262-runner: Attempt to resolve harness for test262 automaticallydavidot
This makes it easier to use the runner directly.
2022-09-11test262-runner: Overwrite __assertion_failed when compiling for Serenitydavidot
We also protect against recursive assert failures, for example due to being out of memory. With this change the runner now compiles and runs on Serenity :^).
2022-09-11test262-runner: Rename variable stdin to standard_inputdavidot
This was shadowing a name in LibC triggering warnings.
2022-09-11test262-runner: Use alarm instead of setitimerdavidot
Since setitimer is not implemented in Serenity we use alarm which triggers SIGALRM after the timeout. We also don't use a signal handler as we are doing things that serenity doesn't like/doesn't allow. Linux dealt with allocating and writing in a signal handler but it is undefined, so instead we just let the process die by SIGALRM. This means we instead of reading the output can detect timeouts by checking how the process died.
2022-09-11LibJS: Import the libjs-test262-runner from linusg/libjs-test262davidot
For now this is a lagom only application as it is not compatible with serenity in its current state. The only change is that it is released under a different license with permission from all the authors.
2022-09-10LibJS: Allow negative pointers in Valuedavidot
Also ensure that all a nullptr input gives null object and you don't accidentally dereference a nullptr.
2022-09-05LibUnicode+Userland: Migrate generated CLDR data to LibLocaleDataTimothy Flynn
Currently, LibUnicodeData contains the generated UCD and CLDR data. Move the UCD data to the main LibUnicode library, and rename LibUnicodeData to LibLocaleData. This is another prepatory change to migrate to LibLocale.
2022-08-23LibJS: Remove {Bytecode::,}Interpreter::global_object()Linus Groh
The basic idea is that a global object cannot just come out of nowhere, it must be associated to a realm - so get it from there, if needed. This is to enforce the changes from all the previous commits by not handing out global objects unless you actually have an initialized realm (either stored somewhere, or the VM's current realm).
2022-08-23LibJS: Replace GlobalObject with VM in ArrayBuffer AOs [Part 11/19]Linus Groh
2022-08-23LibJS: Replace GlobalObject with VM in Reference AOs [Part 6/19]Linus Groh
2022-08-23LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]Linus Groh
This is where the fun begins. :^)
2022-08-23LibJS: Remove GlobalObject from VM::throw_completion()Linus Groh
This is a continuation of the previous five commits. A first big step into the direction of no longer having to pass a realm (or currently, a global object) trough layers upon layers of AOs! Unlike the create() APIs we can safely assume that this is only ever called when a running execution context and therefore current realm exists. If not, you can always manually allocate the Error and put it in a Completion :^) In the spec, throw exceptions implicitly use the current realm's intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-06-23LibJS: Implement WeakMap changes from 'Symbol as WeakMap Keys Proposal'Idan Horowitz
2022-05-03LibJS: Remove implicit wrapping/unwrapping of completion recordsLinus Groh
This is an editorial change in the ECMA-262 spec, with similar changes in some proposals. See: - https://github.com/tc39/ecma262/commit/7575f74 - https://github.com/tc39/proposal-array-grouping/commit/df899eb - https://github.com/tc39/proposal-shadowrealm/commit/9eb5a12 - https://github.com/tc39/proposal-shadowrealm/commit/c81f527
2022-04-08test-js: Define detachArrayBuffer global functionTimothy Flynn
2022-03-16LibTest: Provide detailed per-file JSON output with --per-fileAli Mohammad Pur
This makes test-js style runners dump out output in the same format as libjs-test262's per-file output.
2022-02-23LibTest+Spreadsheet: Add some basic spreadsheet runtime behaviour testsAli Mohammad Pur
As there's a somewhat active development going on, let's keep the expected behaviour under tests to make sure nothing blows up :^)
2022-02-13Tests: Wrap test-bytecode-js source in an IIFEAli Mohammad Pur
Putting everything in the global scope will lead to mayhem and failing tests with an actually correct implementation of scoping :^) Also adds in a tiny debug log of the exception, otherwise we'd be staring at failing tests with no info on what failed.
2022-02-13LibJS: Make ASTNode::generate_bytecode() fallibleAli Mohammad Pur
Instead of crashing on the spot, return a descriptive error that will eventually continue its days as a javascript "InternalError" exception. This should make random crashes with BC less likely.
2022-02-08LibJS+Everywhere: Remove VM::exception() and most related functionsdavidot
This commit removes all exception related code: Remove VM::exception(), VM::throw_exception() etc. Any leftover throw_exception calls are moved to throw_completion. The one method left is clear_exception() which is now a no-op. Most of these calls are just to clear whatever exception might have been thrown when handling a Completion. So to have a cleaner commit this will be removed in a next commit. It also removes the actual Exception and TemporaryClearException classes since these are no longer used. In any spot where the exception was actually used an attempt was made to preserve that behavior. However since it is no longer tracked by the VM we cannot access exceptions which were thrown in previous calls. There are two such cases which might have different behavior: - In Web::DOM::Document::interpreter() the on_call_stack_emptied hook used to print any uncaught exception but this is now no longer possible as the VM does not store uncaught exceptions. - In js the code used to be interruptable by throwing an exception on the VM. This is no longer possible but was already somewhat fragile before as you could happen to throw an exception just before a VERIFY.
2022-02-08LibJS: Convert Instruction::execute in bytecode to ThrowCompletionOrdavidot
This allows us to use TRY in these functions :^).
2022-01-31LibJS: Store ECMAScriptFunctionObject bytecode in an OwnPtrAndreas Kling
Using an Optional was extremely wasteful for function objects that don't even have a bytecode executable. This allows ECMAScriptFunctionObject to fit in a smaller size class.
2022-01-25Tests+LibJS: Add very simple bytecode LibJS testsdavidot
These tests are not meant as a replacement to test-js with the -b option but are meant to test simple cases until that works. Before this it was very easy to accidentally break bytecode since no tests were run in bytecode mode. This hopefully makes it easier to spot such regressions :^).
2022-01-04Tests: Link some tests directly against LibUnicodeDataTimothy Flynn
These were missed in 565a880ce5a14bac817c73916e91ebfa04c8b99b. This wasn't an issue because these tests don't pledge/unveil anything, so they could happily dlopen() the library at runtime. But this is now needed in order to migrate LibUnicode towards weak symbols instead.
2021-12-30LibJS: Convert resolve_binding() to ThrowCompletionOrdavidot
The spec has a note stating that resolve binding will always return a reference whose [[ReferencedName]] field is name. However this is not correct as the underlying method GetIdentifierReference may throw on env.HasBinding(name) thus it can throw. However, there are some scenarios where it cannot throw because the reference is known to exist in that case we use MUST with a comment.
2021-12-29LibJS: Detect invalid unicode and stop lexing at that pointdavidot
Previously we might swallow invalid unicode point which would skip valid ascii characters. This could be dangerous as we might skip a '"' thus not closing a string where we should. This might have been exploitable as it would not have been clear what code gets executed when looking at a script. Another approach to this would be simply replacing all invalid characters with the replacement character (this is what v8 does). But our lexer and parser are currently not set up for such a change.
2021-12-05Tests: Cast unused smart-pointer return values to voidSam Atkins
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-02LibJS: Convert the GetValue AO to ThrowCompletionOrIdan Horowitz
2021-11-02LibJS: Convert reference deletion to ThrowCompletionOrIdan Horowitz
2021-10-20LibJS: Convert test-js/test-web/test-wasm to ThrowCompletionOrIdan Horowitz
2021-10-13LibJS: Convert to_object() to ThrowCompletionOrLinus Groh
2021-10-13LibJS: Convert to_string() to ThrowCompletionOrLinus Groh
Also update get_function_name() to use ThrowCompletionOr, but this is not a standard AO and should be refactored out of existence eventually.
2021-10-03LibJS: Add a specific test for invalid unicode characters in the lexerdavidot
Also fixes that it tried to make substrings past the end of the source if we overran the source length.
2021-09-30LibJS + test-js: Get results from the global object directlydavidot
This is as the spec would require you to do it and necessary for changes to come in the following commits.
2021-09-14LibJS+LibTest: Use JS::Script and JS::SourceTextModule in test-jsAndreas Kling
Instead of creating a Parser and Lexer manually in test-js, we now use either JS::Script::parse() or JS::SourceTextModule::parse() to load tests.
2021-09-12LibJS: Use ErrorType::NotAnObjectOfType instead of NotATimothy Flynn