Bug 113425
| Summary: | Structured clone does not preserve array lengths | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Elliott Sprehn <esprehn> |
| Component: | New Bugs | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | abarth, adamk, rafaelw |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
Elliott Sprehn
ex.
postMessage(new Array(10), '*');
onmessage = function(event) {
console.log(event.data.length); // should be 10, but 0 in webkit.
});
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Elliott Sprehn
Relevant spec text:
http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#safe-passing-of-structured-data
If input is an Array object
Let output be a newly constructed empty Array object whose length is equal to the length of input.
This means that the length of sparse arrays is preserved.
Elliott Sprehn
This looks like a one line fix for v8:
virtual bool completeSparseArray(uint32_t numProperties, uint32_t length, v8::Handle<v8::Value>* value)
has array = v8::Array::New();
and completely ignores the length value. We should do ::New(length) instead.