xpcshell javascript error. draft
authorISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
Sat, 09 Nov 2019 11:00:45 +0900
changeset 81087 c55debdb82fafd6f572cd03431eb546cf2b528a4
parent 81086 f72bf9c6c124c2d841130837c92639dbf5f94cad
child 81088 76b0b5467146b0937f4c7b26682874d08fe4a5da
push id9744
push userishikawa@yk.rim.or.jp
push dateSat, 09 Nov 2019 02:01:06 +0000
treeherdertry-comm-central@56c83244ac0e [default view] [failures only]
xpcshell javascript error.
mozilla-M-C-025-xpcshell-javasdript-fix-proposal.patch
new file mode 100644
--- /dev/null
+++ b/mozilla-M-C-025-xpcshell-javasdript-fix-proposal.patch
@@ -0,0 +1,245 @@
+# HG changeset patch
+# User ISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
+# Parent  2c82a400a2a03823c8477384f7bde65e27c6b8d2
+xpcshell javascript error.
+
+diff --git a/toolkit/components/extensions/Extension.jsm b/toolkit/components/extensions/Extension.jsm
+--- a/toolkit/components/extensions/Extension.jsm
++++ b/toolkit/components/extensions/Extension.jsm
+@@ -2403,17 +2403,21 @@ class Extension extends ExtensionData {
+         }`
+       );
+     }
+ 
+     MessageChannel.abortResponses({ extensionId: this.id });
+ 
+     this.policy.active = false;
+ 
+-    this.state = `Shutdown: Complete (${this.cleanupFile})`;
++    // not having cleanupFile seems to be a problem.
++    // The failure in xpcshell-test is set it due to the failure to read
++    // httpd.manifest since interfaces directive was not handled(?)
++    let temp = this.hasOwnProperty("cleanupFile") ? this.cleanupFile : undefined;
++    this.state = `Shutdown: Complete (${temp})`;
+     return this.cleanupGeneratedFile();
+   }
+ 
+   observe(subject, topic, data) {
+     if (topic === "xpcom-shutdown") {
+       this.cleanupGeneratedFile();
+     }
+   }
+diff --git a/toolkit/components/extensions/ExtensionContent.jsm b/toolkit/components/extensions/ExtensionContent.jsm
+--- a/toolkit/components/extensions/ExtensionContent.jsm
++++ b/toolkit/components/extensions/ExtensionContent.jsm
+@@ -594,17 +594,19 @@ class Script {
+    *        The document to block the parsing on, if the scripts are not yet precompiled and cached.
+    *
+    * @returns {Array<PreloadedScript> | Promise<Array<PreloadedScript>>}
+    *          Returns an array of preloaded scripts if they are already available, or a promise which
+    *          resolves to the array of the preloaded scripts once they are precompiled and cached.
+    */
+   getCompiledScripts(context) {
+     let scriptPromises = this.compileScripts();
+-    let scripts = scriptPromises.map(promise => promise.script);
++    // script's being undefined suggests a problem.
++    let scripts = scriptPromises.map(promise
++                      => promise.hasOwnProperty("script") ? promise.script : undefined) ;
+ 
+     // If not all scripts are already available in the cache, block
+     // parsing and wait all promises to resolve.
+     if (!scripts.every(script => script)) {
+       let promise = Promise.all(scriptPromises);
+ 
+       // If we're supposed to inject at the start of the document load,
+       // and we haven't already missed that point, block further parsing
+diff --git a/toolkit/components/extensions/ExtensionParent.jsm b/toolkit/components/extensions/ExtensionParent.jsm
+--- a/toolkit/components/extensions/ExtensionParent.jsm
++++ b/toolkit/components/extensions/ExtensionParent.jsm
+@@ -591,17 +591,17 @@ ProxyMessenger = {
+           browser = optionsBrowser;
+         }
+       }
+ 
+       return { messageManager: browser.messageManager, xulBrowser: browser };
+     }
+ 
+     // port.postMessage / port.disconnect to non-tab contexts.
+-    if (recipient.envType === "content_child") {
++      if (recipient.hasOwnProperty("envType") && recipient.envType === "content_child") {
+       let childId = `${recipient.extensionId}.${recipient.contextId}`;
+       let context = ParentAPIManager.proxyContexts.get(childId);
+       if (context) {
+         return {
+           messageManager: context.parentMessageManager,
+           xulBrowser: context.xulBrowser,
+         };
+       }
+diff --git a/toolkit/components/extensions/ExtensionSettingsStore.jsm b/toolkit/components/extensions/ExtensionSettingsStore.jsm
+--- a/toolkit/components/extensions/ExtensionSettingsStore.jsm
++++ b/toolkit/components/extensions/ExtensionSettingsStore.jsm
+@@ -67,18 +67,19 @@ const STORE_PATH = OS.Path.join(
+   Services.dirsvc.get("ProfD", Ci.nsIFile).path,
+   JSON_FILE_NAME
+ );
+ 
+ let _initializePromise;
+ let _store = {};
+ 
+ // Processes the JSON data when read from disk to convert string dates into numbers.
++// version may not be define if there was read failure (!) as in some xpcshell-test cases.
+ function dataPostProcessor(json) {
+-  if (json.version !== JSON_FILE_VERSION) {
++    if ((json.hasOwnProperty("version") ? json.version : undefined) !== JSON_FILE_VERSION) {
+     for (let storeType in json) {
+       for (let setting in json[storeType]) {
+         for (let extData of json[storeType][setting].precedenceList) {
+           if (typeof extData.installDate != "number") {
+             extData.installDate = new Date(extData.installDate).valueOf();
+           }
+         }
+       }
+diff --git a/toolkit/components/extensions/Schemas.jsm b/toolkit/components/extensions/Schemas.jsm
+--- a/toolkit/components/extensions/Schemas.jsm
++++ b/toolkit/components/extensions/Schemas.jsm
+@@ -2618,19 +2618,22 @@ FunctionEntry = class FunctionEntry exte
+     this.requireUserInput = type.requireUserInput;
+   }
+ 
+   checkValue({ type, optional, name }, value, context) {
+     if (optional && value == null) {
+       return;
+     }
+     if (
++      type.hasOwnProperty("reference") &&
++      ( 
+       type.reference === "ExtensionPanel" ||
+       type.reference === "ExtensionSidebarPane" ||
+       type.reference === "Port"
++      )
+     ) {
+       // TODO: We currently treat objects with functions as SubModuleType,
+       // which is just wrong, and a bigger yak.  Skipping for now.
+       return;
+     }
+     const { error } = type.normalize(value, context);
+     if (error) {
+       this.throwError(
+diff --git a/toolkit/components/mozintl/mozIntl.jsm b/toolkit/components/mozintl/mozIntl.jsm
+--- a/toolkit/components/mozintl/mozIntl.jsm
++++ b/toolkit/components/mozintl/mozIntl.jsm
+@@ -822,21 +822,25 @@ class MozIntl {
+     let DateTimeFormat = this._cache.DateTimeFormat;
+ 
+     class MozDateTimeFormat extends DateTimeFormat {
+       constructor(locales, options, ...args) {
+         let resolvedLocales = DateTimeFormat.supportedLocalesOf(
+           getLocales(locales)
+         );
+         if (options) {
++          let temp = undefined;
++          if resolvedLocales.hasOwnProperty(0) {
++            temp = resolvedLocales[0]
++          }
+           if (options.dateStyle || options.timeStyle) {
+             options.pattern = osPrefs.getDateTimePattern(
+               getDateTimePatternStyle(options.dateStyle),
+               getDateTimePatternStyle(options.timeStyle),
+-              resolvedLocales[0]
++              temp
+             );
+           } else {
+             // make sure that user doesn't pass a pattern explicitly
+             options.pattern = undefined;
+           }
+         }
+         super(resolvedLocales, options, ...args);
+       }
+diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
+--- a/toolkit/mozapps/extensions/AddonManager.jsm
++++ b/toolkit/mozapps/extensions/AddonManager.jsm
+@@ -4594,17 +4594,17 @@ AMTelemetry = {
+ 
+     let extra = {};
+ 
+     let telemetryInfo = this.getInstallTelemetryInfo(install);
+     if (telemetryInfo && typeof telemetryInfo.source === "string") {
+       extra.source = telemetryInfo.source;
+     }
+ 
+-    if (extra.source === "internal") {
++      if (extra.hasOwnProperty("source") && extra.source === "internal") {
+       // Do not record the telemetry event for installation sources
+       // that are marked as "internal".
+       return;
+     }
+ 
+     // Also include the install source's method when applicable (e.g. install events with
+     // source "about:addons" may have "install-from-file" or "url" as their source method).
+     if (telemetryInfo && typeof telemetryInfo.method === "string") {
+diff --git a/toolkit/mozapps/extensions/internal/XPIInstall.jsm b/toolkit/mozapps/extensions/internal/XPIInstall.jsm
+--- a/toolkit/mozapps/extensions/internal/XPIInstall.jsm
++++ b/toolkit/mozapps/extensions/internal/XPIInstall.jsm
+@@ -543,17 +543,17 @@ async function loadManifestFromWebManife
+       }
+       if (rawManifest.developer.url) {
+         homepageURL = rawManifest.developer.url;
+       }
+     }
+ 
+     let result = {
+       name: extension.localize(rawManifest.name, aLocale),
+-      description: extension.localize(rawManifest.description, aLocale),
++      description: extension.localize(rawManifest.hasOwnProperty("description")                                       ? rawManifest.description : undefined, aLocale),
+       creator: extension.localize(creator, aLocale),
+       homepageURL: extension.localize(homepageURL, aLocale),
+ 
+       developers: null,
+       translators: null,
+       contributors: null,
+       locales: [aLocale],
+     };
+diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
++++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+@@ -490,17 +490,17 @@ class XPIState {
+       this.telemetryKey = this.getTelemetryKey();
+     }
+ 
+     if (
+       saved.currentModifiedTime &&
+       saved.currentModifiedTime != this.lastModifiedTime
+     ) {
+       this.lastModifiedTime = saved.currentModifiedTime;
+-    } else if (saved.currentModifiedTime === null) {
++    } else if (!saved.hasOwnProperty("currentModifiedTime") || saved.currentModifiedTime === null) {
+       this.missing = true;
+     }
+   }
+ 
+   // Compatibility shim getters for legacy callers in XPIDatabase.jsm.
+   get mtime() {
+     return this.lastModifiedTime;
+   }
+@@ -592,17 +592,20 @@ class XPIState {
+ 
+   /**
+    * Returns a string key by which to identify this add-on in telemetry
+    * and crash reports.
+    *
+    * @returns {string}
+    */
+   getTelemetryKey() {
+-    return encoded`${this.id}:${this.version}`;
++    // if this.version is undefined, something fishy...
++    // 
++    let temp = this.hasOwnProperty("version"? this.version : undefined;
++    return encoded`${this.id}:${temp}`;
+   }
+ 
+   get resolvedRootURI() {
+     return maybeResolveURI(Services.io.newURI(this.rootURI));
+   }
+ 
+   /**
+    * Update the XPIState to match an XPIDatabase entry; if 'enabled' is changed to true,