mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-06 09:36:08 +00:00
LibWeb: Implement TextEncoder.prototype.encode()
This commit is contained in:
parent
35d3a1e77b
commit
f37d00c07b
Notes:
sideshowbarker
2024-07-17 22:53:32 +09:00
Author: https://github.com/linusg
Commit: f37d00c07b
Pull-request: https://github.com/SerenityOS/serenity/pull/11231
Reviewed-by: https://github.com/alimpfard
6 changed files with 69 additions and 2 deletions
|
@ -0,0 +1,28 @@
|
|||
describe("normal behavior", () => {
|
||||
loadLocalPage("/res/html/misc/blank.html");
|
||||
|
||||
afterInitialPageLoad(page => {
|
||||
test("Basic functionality", () => {
|
||||
const textEncoder = new page.TextEncoder();
|
||||
|
||||
{
|
||||
const typedArray = textEncoder.encode("");
|
||||
expect(typedArray).toHaveLength(0);
|
||||
}
|
||||
|
||||
{
|
||||
const typedArray = textEncoder.encode("abc");
|
||||
expect(typedArray).toHaveLength(3);
|
||||
expect(Array.from(typedArray)).toEqual([97, 98, 99]);
|
||||
}
|
||||
|
||||
{
|
||||
const typedArray = textEncoder.encode("€");
|
||||
expect(typedArray).toHaveLength(3);
|
||||
expect(Array.from(typedArray)).toEqual([226, 130, 172]);
|
||||
// [255, 254, 172, 32] in UTF-16, but TextEncoder always converts JS UTF-16 strings to UTF-8
|
||||
}
|
||||
});
|
||||
});
|
||||
waitForPageToLoad();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue