Bug 1454792 - Prevent duplicating arrays in Array type's read/write methods. r=jryans
MozReview-Commit-ID: 82GYGZUs6TH
--- a/devtools/shared/protocol.js
+++ b/devtools/shared/protocol.js
@@ -217,18 +217,28 @@ types.addArrayType = function(subtype) {
let name = "array:" + subtype.name;
// Arrays of primitive types are primitive types themselves.
if (subtype.primitive) {
return types.addType(name);
}
return types.addType(name, {
category: "array",
- read: (v, ctx) => [...v].map(i => subtype.read(i, ctx)),
- write: (v, ctx) => [...v].map(i => subtype.write(i, ctx))
+ read: (v, ctx) => {
+ if (isIterator(v)) {
+ v = [...v];
+ }
+ return v.map(i => subtype.read(i, ctx));
+ },
+ write: (v, ctx) => {
+ if (isIterator(v)) {
+ v = [...v];
+ }
+ return v.map(i => subtype.write(i, ctx));
+ }
});
};
/**
* Add a dict type to the type system. This allows you to serialize
* a JS object that contains non-primitive subtypes.
*
* Properties of the value that aren't included in the specializations