diff options
author | Linus Groh <mail@linusgroh.de> | 2021-04-12 00:08:28 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-12 09:38:57 +0200 |
commit | da177c6517ab0ba77facfe4ff5a078562f887e96 (patch) | |
tree | 33123a6ad6e98f09b4390796dc20f26458c0800e /Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js | |
parent | 6e9eb0a284661803d634ce0bd8c1656a156878bb (diff) | |
download | serenity-da177c6517ab0ba77facfe4ff5a078562f887e96.zip |
LibJS: Make Errors fully spec compliant
The previous handling of the name and message properties specifically
was breaking websites that created their own error types and relied on
the error prototype working correctly - not assuming an JS::Error this
object, that is.
The way it works now, and it is supposed to work, is:
- Error.prototype.name and Error.prototype.message just have initial
string values and are no longer getters/setters
- When constructing an error with a message, we create a regular
property on the newly created object, so a lookup of the message
property will either get it from the object directly or go though the
prototype chain
- Internal m_name/m_message properties are no longer needed and removed
This makes printing errors slightly more complicated, as we can no
longer rely on the (safe) internal properties, and cannot trust a
property lookup either - get_without_side_effects() is used to solve
this, it's not perfect but something we can revisit later.
I did some refactoring along the way, there was some really old stuff in
there - accessing vm.call_frame().arguments[0] is not something we (have
to) do anymore :^)
Fixes #6245.
Diffstat (limited to 'Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js')
-rw-r--r-- | Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js b/Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js index 177bb2d675..c4e3d6f5f9 100644 --- a/Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js +++ b/Userland/Libraries/LibJS/Tests/runtime-error-call-stack-size.js @@ -7,7 +7,7 @@ test("infinite recursion", () => { infiniteRecursion(); } catch (e) { expect(e).toBeInstanceOf(Error); - expect(e.name).toBe("RuntimeError"); + expect(e.name).toBe("Error"); expect(e.message).toBe("Call stack size limit exceeded"); } |