Bug 1382645: Part 2 - Throw away schema StructuredCloneHolders in content process after deserialization. r?mixedpuppy draft
authorKris Maglione <maglione.k@gmail.com>
Thu, 20 Jul 2017 14:01:37 -0700
changeset 612586 42263850ff33ef1934e6678398376900d2ee540e
parent 612585 4924ca331db1c244410c9d816ef56353f64db1f3
child 612599 f70adf599bf4005b5cfc3bfed6b11fd3ce6fcac0
child 612647 46d8be5ca880a54ae533f58ce71401e07601c718
push id69543
push usermaglione.k@gmail.com
push dateThu, 20 Jul 2017 21:06:27 +0000
reviewersmixedpuppy
bugs1382645
milestone56.0a1
Bug 1382645: Part 2 - Throw away schema StructuredCloneHolders in content process after deserialization. r?mixedpuppy MozReview-Commit-ID: BBLF3zWxAyt
toolkit/components/extensions/Schemas.jsm
--- a/toolkit/components/extensions/Schemas.jsm
+++ b/toolkit/components/extensions/Schemas.jsm
@@ -2631,19 +2631,31 @@ this.Schemas = {
     this._needFlush = true;
 
     Object.defineProperty(this, "rootNamespace", {
       enumerable: true,
       configurable: true,
       value: new Namespace("", []),
     });
 
-    for (let blob of this.schemaJSON.values()) {
+    for (let [key, schema] of this.schemaJSON.entries()) {
       try {
-        this.loadSchema(blob.deserialize(global));
+        if (typeof schema.deserialize === "function") {
+          schema = schema.deserialize(global);
+
+          // If we're in the parent process, we need to keep the
+          // StructuredCloneHolder blob around in order to send to future child
+          // processes. If we're in a child, we have no further use for it, so
+          // just store the deserialized schema data in its place.
+          if (!isParentProcess) {
+            this.schemaJSON.set(key, schema);
+          }
+        }
+
+        this.loadSchema(schema);
       } catch (e) {
         Cu.reportError(e);
       }
     }
 
     return this.rootNamespace;
   },