1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

LibWeb: Support [de]serialization for {Map, Set, Object, Array} objects

This commit is contained in:
Idan Horowitz 2023-11-11 20:14:46 +02:00 committed by Andreas Kling
parent 4e89ec7fd5
commit 20734ac335
8 changed files with 447 additions and 190 deletions

View file

@ -8,5 +8,10 @@ This is a String object
/abc/gimsuy
Error
URIError: hello
{"1":2,"a":"b"}
1,4,aaaa
true
1
true
[object ArrayBuffer]
ERROR: DataCloneError: Cannot serialize Symbol

View file

@ -8,7 +8,7 @@ originParsedBeforeSerializeError.message: Invalid URL for targetOrigin: 'aaaa'
originParsedBeforeSerializeError.constructor === window.DOMException: true
serializeError instanceof DOMException: true
serializeError.name: DataCloneError
serializeError.message: Unsupported type
serializeError.message: Cannot serialize platform objects
serializeError.constructor === window.DOMException: true
originIframeError instanceof DOMException: false
originIframeError instanceof iframe.contentWindow.DOMException: true
@ -25,7 +25,7 @@ originParsedBeforeSerializeIframeError.constructor === iframe.contentWindow.DOME
serializeIframeError instanceof DOMException: false
serializeIframeError instanceof iframe.contentWindow.DOMException: true
serializeIframeError.name: DataCloneError
serializeIframeError.message: Unsupported type
serializeIframeError.message: Cannot serialize platform objects
serializeIframeError.constructor === DOMException: false
serializeIframeError.constructor === iframe.contentWindow.DOMException: true
Message 1 data: undefined

View file

@ -11,6 +11,15 @@
println(structuredClone(/abc/gimsuy));
println(structuredClone(new Error()));
println(structuredClone(new URIError("hello")));
println(structuredClone(JSON.stringify({"a": "b", 1: 2})));
println(structuredClone([1, 4, "aaaa"]));
println(structuredClone(new Set(["a", "b", "c"])).has("b"));
println(structuredClone(new Map([["a", 0], ["b", 1], ["c", 2]])).get("b"));
const obj = {"a": 1, "c": 3};
obj["b"] = obj;
const result = structuredClone(obj);
println(result === result["b"]);
{
let arrayBuffer = new ArrayBuffer(6);