1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:58:12 +00:00
serenity/Userland/Libraries/LibJS/Tests/builtins
Luke Wilde a54fdd5212 LibJS: Apply source's byte offset in TA#set when both TAs have same type
On the code path where we are setting a TypedArray from another
TypedArray of the same type, we forgo the spec text and simply do a
memmove between the two ArrayBuffers. However, we forgot to apply
source's byte offset on this code path.

This meant if we tried setting a TypedArray from a TypedArray we got
from .subarray(), we would still copy from the start of the subarray's
ArrayBuffer.

This is because .subarray() returns a new TypedArray with the same
ArrayBuffer but the new TypedArray has a smaller length and a byte
offset that the rest of the codebase is responsible for applying.

This affected pako when it was decompressing a zlib stream that has
multiple zlib chunks in it. To read from the second chunk, it would
set the zlib window TypedArray from the .subarray() of the chunk offset
in the stream's TypedArray. This effectively made the decompressed data
from the second chunk a mis-mash of old data that looked completely
scrambled. It would also cause all future decompression using the same
pako Inflate instance to also appear scrambled.

As a pako comment aptly puts it:
> Call updatewindow() to create and/or update the window state.
> Note: a memory error from inflate() is non-recoverable.

This allows us to properly decompress the large compressed payloads
that Discord Gateway sends down to the Discord client. For example,
for an account that's only in the Serenity Discord, one of the payloads
is a 20 KB zlib compressed blob that has two chunks in it.

Surprisingly, this is not covered by test262! I imagine this would have
been caught earlier if there was such a test :^)
2022-03-11 22:20:23 +01:00
..
AggregateError LibJS: Implement the Error Cause proposal 2021-06-11 21:34:05 +01:00
Array LibJS: Add tests for all the unscopable Array prototype properties 2022-01-05 20:31:25 +01:00
ArrayBuffer LibJS: Implement and test ArrayBuffer.prototype.resize 2022-03-02 20:53:18 +01:00
Atomics LibJS: Implement Atomics.isLockFree 2021-07-14 22:13:15 +01:00
BigInt LibJS: Implement BigInt.asUintN 2022-02-06 15:49:54 +00:00
Boolean LibJS: Change wording of ErrorType::NotA to be independent of context 2021-09-12 00:16:39 +02:00
DataView LibJS: Use Checked<T> for offsets in the SetViewValue AO 2021-08-11 22:56:58 +01:00
Date LibJS: Be more lenient when parsing milliseconds for Date 2022-03-09 14:18:59 +01:00
Error LibJS: Implement the Error.prototype.stack setter 2022-03-08 22:59:09 +01:00
FinalizationRegistry test-js: Add a mark_as_garbage method to force GC to collect that object 2021-09-08 08:53:02 +01:00
Function LibJS: Add [[InitialName]] and use it in Function.prototype.toString() 2022-02-20 23:21:40 +00:00
functions LibJS: Correcly handle surrogates in escape() 2022-01-14 10:59:46 +01:00
Infinity Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Intl LibJS: Define the Intl.Collator's compare function name to be empty 2022-02-21 16:30:19 +00:00
JSON AK: Fix userland parsing of rounded floating point numbers 2022-02-16 07:22:51 -05:00
Map LibJS: Fix Map Iterators when elements are deleted during iteration 2022-02-10 14:09:39 +00:00
Math LibJS: Correctly handle mixing +0 and -0 in Math.{min,max}() 2021-04-23 20:51:48 +02:00
NaN Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Number LibJS: Fix rounding issues in Number.toFixed 2022-03-02 08:34:04 +01:00
Object Everywhere: Fix spelling mistakes 2022-01-07 15:44:42 +01:00
Promise LibJS: Don't coerce this value to object in Promise.prototype.finally() 2021-11-14 15:27:46 +00:00
Proxy LibJS: Throw InternalErrors instead of Errors on CallStackSizeExceeded 2021-11-27 01:58:05 +02:00
Reflect LibJS: Implement [[Call]] and [[Construct]] internal slots properly 2021-10-09 14:29:20 +01:00
RegExp LibJS: Create the RegExpExec result's "input" field last 2021-11-08 01:36:29 +01:00
Set LibJS: Add tests for Set.prototype.keys which is an alias for values 2022-02-10 14:09:39 +00:00
ShadowRealm LibJS: Remove the name prefix for wrapped functions 2022-02-12 16:06:37 +00:00
String LibJS: Re-implement String.localeCompare using the StringCompare AO 2022-02-20 22:05:59 -05:00
Symbol LibJS: Rename OrdinaryFunctionObject to ECMAScriptFunctionObject 2021-09-25 17:51:30 +02:00
Temporal LibJS: Add missing check in ParseTemporalInstant 2022-03-10 23:20:39 +01:00
TypedArray LibJS: Apply source's byte offset in TA#set when both TAs have same type 2022-03-11 22:20:23 +01:00
WeakMap test-js: Add a mark_as_garbage method to force GC to collect that object 2021-09-08 08:53:02 +01:00
WeakRef LibJS: Add the WeakRef.prototype.deref method 2021-06-12 18:39:23 +01:00
WeakSet test-js: Add a mark_as_garbage method to force GC to collect that object 2021-09-08 08:53:02 +01:00