Closed Bug 1502804 Opened 7 years ago Closed 1 year ago

StructuredCloneAlgorithm should preserve the sharing when cloning objects

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: baku, Unassigned)

Details

Flags: needinfo?(sphink)
Component: DOM → DOM: Core & HTML
Priority: -- → P3
Severity: normal → S3

This appears to work now. My quick test:

<!doctype html>
<title>Cloning objects, preserving sharing #2</title>
<canvas id="a" width=30 height=30></canvas>
<div id=log></div>
<script>
function test() {
  var canvas = document.getElementsByTagName("canvas")[0];
  var context = canvas.getContext("2d");
  var img_data = context.getImageData(0, 0, 30, 30);
  var obj = {a: img_data, b: {c: img_data, d: 3}};
  postMessage(obj, '*');
    onmessage = e => {
        if (e.data.a !== e.data.b.c) {
            console.error("mismatched!");
        } else {
            console.log("matched");
        }
    }
}
  test();
</script>

This logged "matched".

Status: NEW → RESOLVED
Closed: 1 year ago
Flags: needinfo?(sphink)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.