summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
AgeCommit message (Collapse)Author
2021-07-01LibJS: Drop "Record" suffix from all the *Environment record classesAndreas Kling
"Records" in the spec are basically C++ classes, so let's drop this mouthful of a suffix.
2021-07-01LibJS: Bring JSON.stringify closer to the specificationIdan Horowitz
2021-07-01LibJS: Stop coercing this to object in Function's Symbol.hasInstanceIdan Horowitz
2021-07-01LibJS: Stop coercing Date.prototype[Symbol.toPrimitive] hint to stringIdan Horowitz
2021-07-01LibJS: Check for DataView in ArrayBuffer.isView()Idan Horowitz
2021-06-30LibJS: Use the GetFunctionRealm abstract-op in ArraySpeciesCreateIdan Horowitz
2021-06-30LibJS: Get the prototype of a new String from the constructor's realmIdan Horowitz
2021-06-30LibJS: Add a [[Realm]] getter to FunctionObject and use it where neededIdan Horowitz
Defined by https://tc39.es/ecma262/#sec-ordinaryfunctioncreate step #17 and by https://tc39.es/ecma262/#sec-createbuiltinfunction step #6.
2021-06-30LibJS: Ensure shift values in left_shift are modded by 32Idan Horowitz
This is equivalent to 58d6a2d0192b7860ecb2edb4aa5d36b389213a15 but for the left shift operation.
2021-06-30LibJS: Add String.prototype.split using the @@split methods on objectdavidot
2021-06-30LibJS: Add String.prototype.indexOf position argumentdavidot
2021-06-30LibJS: Optimize & Bring String.prototype.repeat closer to the specIdan Horowitz
Specifically, we immediately return an empty string when `this` is an empty string, instead of wasting time in a loop doing nothing N times.
2021-06-30LibJS: Bring the Array constructor slightly closer to the specificationIdan Horowitz
Specifically, we now cast to a u32 instead of an i32, as well as use the validity check required by the specification. The current constructor is still quite far from the specification, as we directly set the indexed properties' length instead of going through the Array's overriden DefineOwnProperty. (and as a result the checks imposed by the ArraySetLength abstract operation)
2021-06-29LibJS: Handle the different realms case in ArraySpeciesCreatedavidot
2021-06-29LibJS: Support the radix argument in BigInt.prototype.toStringIdan Horowitz
2021-06-29LibCrypto: Replace from_base{2,8,10,16}() & to_base10 with from_base(N)Idan Horowitz
This allows us to support parsing and serializing BigIntegers to and from any base N (such that 2 <= N <= 36).
2021-06-29LibJS: Check the target function of a bound function in is_constructorIdan Horowitz
This is not exactly compliant with the specification, but our current bound function implementation isn't either, so its not currently possible to implement it the way the specification requires.
2021-06-29LibJS: Make Array.of(...items) genericIdan Horowitz
As well as bring it generally closer to the specification.
2021-06-28LibJS/Tests: Fix toBeFalse() details prefixLinus Groh
Copy/paste error from toBeTrue().
2021-06-28LibJS: Mark FunctionObject::is_ordinary_function() as overrideLeon Albrecht
2021-06-28LibJS: Add the CreateMappedArgumentsObject abstract operationAndreas Kling
This patch adds a new ArgumentsObject class to represent what the spec calls "Arguments Exotic Objects" These are constructed by the new CreateMappedArgumentsObject when the `arguments` identifier is resolved in a callee context. The implementation is incomplete and doesn't yet support mapping of the parameter variables to the indexed properties of `arguments`.
2021-06-28LibJS: Bring Reflect.construct() closer to the specificationIdan Horowitz
This includes checking that the target is a constructor, not just a function, as well as switching the order of the list creation and argument validation to match the specification, to ensure correct exception throwing order.
2021-06-28LibJS: Rewrite String.raw() closer to the specificationIdan Horowitz
This includes not throwing a custom exception and using the length_of_array_like abstract operation where required.
2021-06-28LibJS: Use CreateUnmappedArgumentsObject for non-simple parameter listsAndreas Kling
This patch implements the IsSimpleParameterList static semantics for ordinary function objects. We now also create an unmapped arguments object for callee contexts with non-simple parameter lists, instead of only doing it in strict mode. Covered by test262.
2021-06-28LibJS: Add and use the %ThrowTypeError% intrinsicIdan Horowitz
2021-06-28LibJS: Accept FlyStrings in the NativeFunction constructorsIdan Horowitz
This makes the implicit run-time assertion in PropertyName::to_string() into an explicit compile-time requirement, removes a wasteful FlyString -> PropertyName -> FlyString construction from NativeFunction::create() and allows setting the function name to a null string for anonymous native functions.
2021-06-28LibJS: Handle values close to -0.5 correctly in Math.round(x)Idan Horowitz
This is done by just using the built-in ceiling and subtracting from the result if its in the 0.5 range.
2021-06-28LibJS: Implement the CreateUnmappedArgumentsObject abstract operationAndreas Kling
2021-06-27LibJS/Tests: Improve valueToString() outputLinus Groh
This regressed recently and would only output a bunch of '[object Foo]', the reason being that String(value) failed in some cases - which is easily fixed by trying that first and using Object.prototype.toString() as a fallback in the case of an exception :^)
2021-06-27LibJS: Unbreak test-js test that depended on function object class nameAndreas Kling
2021-06-27LibJS: Fix typo "sweeped" => "swept" everywhereAndreas Kling
2021-06-27LibJS: Stop qualifying AK::FunctionAndreas Kling
Now that JS function objects are JS::FunctionObject, we can stop qualifying AK::Function and just say "Function" everywhere. Nice. :^)
2021-06-27LibJS: Rename ScriptFunction => OrdinaryFunctionObjectAndreas Kling
These are basically what the spec calls "ordinary function objects", so let's have the name reflect that. :^)
2021-06-27LibJS: Rename Function => FunctionObjectAndreas Kling
2021-06-27LibJS: Ensure shift values in shift_right are modded by 32Andrew Kaster
The unsigned shift right implementation was already doing this, but the spec requires a mod32 of rhs before the shift for the signed shift right implementation as well. Caught by UBSAN and oss-fuzz.
2021-06-27LibJS: Avoid undefined static cast of negative values in to_u32Andrew Kaster
If the value we get after fmod in Value::to_u32 is negative, UBSAN complains that -N is out of bounds for u32. An extra static cast to i64 makes it stop complaining. An alternative implementation could add 2^32 if the fmod'd value is negative. Caught by UBSAN and oss-fuzz.
2021-06-27LibJS: Add content type check to IntegerIndexedElementSet()Linus Groh
Resolves a FIXME.
2021-06-27LibJS: Add content type check to InitializeTypedArrayFromTypedArray()Linus Groh
Resolves a FIXME.
2021-06-27LibJS: Implement the TypedArray [[ContentType]] internal slotLinus Groh
2021-06-27LibJS: Add 'is detached' check to InitializeTypedArrayFromTypedArray()Linus Groh
Resolves a FIXME.
2021-06-27LibJS: Make variables in InitializeTypedArrayFromTypedArray() match specLinus Groh
This makes it easier to follow the code and compare it to the spec.
2021-06-27LibJS: Add missing InitializeTypedArrayFromTypedArray() spec linkLinus Groh
Also move the others outside of their functions.
2021-06-27LibJS: Don't extend `arguments` object to match the parameter countAndreas Kling
The `arguments` object should only have the *arguments* as numeric properties, not the *parameters*. Given this function: function foo(a, b) { return arguments.length; } Calling foo() with no arguments now correctly returns 0 instead of 2.
2021-06-26AK: Undo bogus Variant::downcast() renameAndreas Kling
I accidentally renamed these to verify_cast() when doing the global AK::downcast() rename.
2021-06-26LibJS: Implement the GetMethod() abstract operation as a Value methodLinus Groh
This was a standalone function previously (get_method()), but instead of passing a Value to it, we can just make it a method. Also add spec step comments and fix the receiver value by using GetV().
2021-06-26LibJS: Implement the GetV() abstract operationLinus Groh
Like Get(), but with any value instead of an object - it's calling ToObject() for us and passes the value to [[Get]]() as the receiver. This will be used in GetMethod() (and a couple of other places, which can be updated over time). I also tried something new here: adding the three steps from the spec as inline comments :^)
2021-06-26LibJS: Move install_error_cause() from Object to ErrorLinus Groh
This is only used by Error and its subclasses, so it doesn't need to be available to all objects.
2021-06-26LibJS: Skip tests which broke with reversion of f102b563davidot
These tests are correct as other engines pass them but are now broken
2021-06-26Revert "LibJS: Fix this_value in native setters and getters"davidot
This reverts commit f102b563 The reverted to behavior is not correct for example with a double proxy But this change lead to problems with DOMNodes
2021-06-26LibJS: Fix propagation of setters and getters from prototypesdavidot
If we define a property with just a setter/getter (not both) we must: - take the previous getter/setter if defined on the actual object - overwrite the other to nullptr if it is from a prototype