Bug 1402066: Fix ordering of base schema data in extension child processes. r?aswan
MozReview-Commit-ID: FtLHJq5H5oD
--- a/toolkit/components/extensions/Schemas.jsm
+++ b/toolkit/components/extensions/Schemas.jsm
@@ -2713,26 +2713,34 @@ this.Schemas = {
Services.cpmm.addMessageListener("Schema:Add", this);
}
this.flushSchemas();
},
receiveMessage(msg) {
+ let {data} = msg;
switch (msg.name) {
case "Schema:Add":
- for (let [url, schema] of msg.data) {
+ // If we're given a Map, the ordering of the initial items
+ // matters, so swap with our current data to make sure its
+ // entries appear first.
+ if (typeof data.get === "function") {
+ [this.schemaJSON, data] = [new Map(data), this.schemaJSON];
+ }
+
+ for (let [url, schema] of data) {
this.schemaJSON.set(url, schema);
}
this.flushSchemas();
break;
case "Schema:Delete":
- this.schemaJSON.delete(msg.data.url);
+ this.schemaJSON.delete(data.url);
this.flushSchemas();
break;
}
},
_needFlush: true,
flushSchemas() {
if (this._needFlush) {
--- a/toolkit/components/extensions/extension-process-script.js
+++ b/toolkit/components/extensions/extension-process-script.js
@@ -375,16 +375,26 @@ ExtensionManager = {
case "Extension:FlushJarCache": {
ExtensionUtils.flushJarCache(data.path);
Services.cpmm.sendAsyncMessage("Extension:FlushJarCacheComplete");
break;
}
case "Schema:Add": {
+ // If we're given a Map, the ordering of the initial items
+ // matters, so swap with our current data to make sure its
+ // entries appear first.
+ if (typeof data.get === "function") {
+ [this.schemaJSON, data] = [data, this.schemaJSON];
+
+ Services.cpmm.initialProcessData["Extension:Schemas"] =
+ this.schemaJSON;
+ }
+
for (let [url, schema] of data) {
this.schemaJSON.set(url, schema);
}
break;
}
}
},
};