Backed out changeset 74f015f58be9 (bug 1037235) under suspicion of causing various failures on a CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Thu, 24 Jul 2014 13:37:05 -0700
changeset 217497 fb981404745a71e4eb1a9cafc261a190c2180917
parent 217496 d3e90a9d7ef64f338efcd38712bd4672eddad1c0
child 217532 613e7926224083a8761e7884c564009db076f5d4
child 217545 c0560ab11ad26aacef6bbd66fcaf4d5ff2f16239
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1037235
milestone34.0a1
backs out74f015f58be923a38a91fcfd6104e86abb96bd53
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 74f015f58be9 (bug 1037235) under suspicion of causing various failures on a CLOSED TREE
addon-sdk/source/lib/sdk/loader/cuddlefish.js
addon-sdk/source/lib/toolkit/loader.js
addon-sdk/source/modules/system/XulApp.js
addon-sdk/source/test/test-cuddlefish.js
addon-sdk/source/test/test-loader.js
--- a/addon-sdk/source/lib/sdk/loader/cuddlefish.js
+++ b/addon-sdk/source/lib/sdk/loader/cuddlefish.js
@@ -9,44 +9,94 @@ module.metadata = {
 
 // This module is manually loaded by bootstrap.js in a sandbox and immediatly
 // put in module cache so that it is never loaded in any other way.
 
 /* Workarounds to include dependencies in the manifest
 require('chrome')                  // Otherwise CFX will complain about Components
 require('toolkit/loader')          // Otherwise CFX will stip out loader.js
 require('sdk/addon/runner')        // Otherwise CFX will stip out addon/runner.js
+require('sdk/system/xul-app')      // Otherwise CFX will stip out sdk/system/xul-app
 */
 
 const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu } = Components;
 
-const {
-  incompatibility
-} = Cu.import("resource://gre/modules/sdk/system/XulApp.js", {}).XulApp;
-
 // `loadSandbox` is exposed by bootstrap.js
 const loaderURI = module.uri.replace("sdk/loader/cuddlefish.js",
                                      "toolkit/loader.js");
+const xulappURI = module.uri.replace("loader/cuddlefish.js",
+                                     "system/xul-app.js");
 // We need to keep a reference to the sandbox in order to unload it in
 // bootstrap.js
 
 const loaderSandbox = loadSandbox(loaderURI);
 const loaderModule = loaderSandbox.exports;
 
+const xulappSandbox = loadSandbox(xulappURI);
+const xulappModule = xulappSandbox.exports;
+
 const { override, load } = loaderModule;
 
+/**
+ * Ensure the current application satisfied the requirements specified in the
+ * module given. If not, an exception related to the incompatibility is
+ * returned; `null` otherwise.
+ *
+ * @param {Object} module
+ *  The module to check
+ * @returns {Error}
+ */
+function incompatibility(module) {
+  let { metadata, id } = module;
+
+  // if metadata or engines are not specified we assume compatibility is not
+  // an issue.
+  if (!metadata || !("engines" in metadata))
+    return null;
+
+  let { engines } = metadata;
+
+  if (engines === null || typeof(engines) !== "object")
+    return new Error("Malformed engines' property in metadata");
+
+  let applications = Object.keys(engines);
+
+  let versionRange;
+  applications.forEach(function(name) {
+    if (xulappModule.is(name)) {
+      versionRange = engines[name];
+      // Continue iteration. We want to ensure the module doesn't
+      // contain a typo in the applications' name or some unknown
+      // application - `is` function throws an exception in that case.
+    }
+  });
+
+  if (typeof(versionRange) === "string") {
+    if (xulappModule.satisfiesVersion(versionRange))
+      return null;
+
+    return new Error("Unsupported Application version: The module " + id +
+            " currently supports only version " + versionRange + " of " +
+            xulappModule.name + ".");
+  }
+
+  return new Error("Unsupported Application: The module " + id +
+            " currently supports only " + applications.join(", ") + ".")
+}
+
 function CuddlefishLoader(options) {
   let { manifest } = options;
 
   options = override(options, {
     // Put `api-utils/loader` and `api-utils/cuddlefish` loaded as JSM to module
     // cache to avoid subsequent loads via `require`.
     modules: override({
       'toolkit/loader': loaderModule,
-      'sdk/loader/cuddlefish': exports
+      'sdk/loader/cuddlefish': exports,
+      'sdk/system/xul-app': xulappModule
     }, options.modules),
     resolve: function resolve(id, requirer) {
       let entry = requirer && requirer in manifest && manifest[requirer];
       let uri = null;
 
       // If manifest entry for this requirement is present we follow manifest.
       // Note: Standard library modules like 'panel' will be present in
       // manifest unless they were moved to platform.
--- a/addon-sdk/source/lib/toolkit/loader.js
+++ b/addon-sdk/source/lib/toolkit/loader.js
@@ -37,19 +37,16 @@ const systemPrincipal = CC('@mozilla.org
 const { loadSubScript } = Cc['@mozilla.org/moz/jssubscript-loader;1'].
                      getService(Ci.mozIJSSubScriptLoader);
 const { notifyObservers } = Cc['@mozilla.org/observer-service;1'].
                         getService(Ci.nsIObserverService);
 const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
 const { Reflect } = Cu.import("resource://gre/modules/reflect.jsm", {});
 const { ConsoleAPI } = Cu.import("resource://gre/modules/devtools/Console.jsm");
 const { join: pathJoin, normalize, dirname } = Cu.import("resource://gre/modules/osfile/ospath_unix.jsm");
-const {
-  incompatibility
-} = Cu.import("resource://gre/modules/sdk/system/XulApp.js", {}).XulApp;
 
 // Define some shortcuts.
 const bind = Function.call.bind(Function.bind);
 const getOwnPropertyNames = Object.getOwnPropertyNames;
 const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
 const define = Object.defineProperties;
 const prototypeOf = Object.getPrototypeOf;
 const create = Object.create;
@@ -347,22 +344,16 @@ const load = iced(function load(loader, 
       message: { value: message, writable: true, configurable: true },
       fileName: { value: fileName, writable: true, configurable: true },
       lineNumber: { value: lineNumber, writable: true, configurable: true },
       stack: { value: serializeStack(frames), writable: true, configurable: true },
       toString: { value: function() toString, writable: true, configurable: true },
     });
   }
 
-  let (error = incompatibility(module)) {
-    if (error) {
-      throw error;
-    }
-  }
-
   if (module.exports && typeof(module.exports) === 'object')
     freeze(module.exports);
 
   return module;
 });
 exports.load = load;
 
 // Utility function to normalize module `uri`s so they have `.js` extension.
--- a/addon-sdk/source/modules/system/XulApp.js
+++ b/addon-sdk/source/modules/system/XulApp.js
@@ -178,56 +178,8 @@ function satisfiesVersion(version, versi
     let [, lowMod, lowVer, highMod, highVer] = matches;
 
     return compareVersion(version, lowMod, lowVer) && (highVer !== undefined
       ? compareVersion(version, highMod, highVer)
       : true);
   });
 }
 exports.satisfiesVersion = satisfiesVersion;
-
-/**
- * Ensure the current application satisfied the requirements specified in the
- * module given. If not, an exception related to the incompatibility is
- * returned; `null` otherwise.
- *
- * @param {Object} module
- *  The module to check
- * @returns {Error}
- */
-function incompatibility(module) {
-  let { metadata, id } = module;
-
-  // if metadata or engines are not specified we assume compatibility is not
-  // an issue.
-  if (!metadata || !("engines" in metadata))
-    return null;
-
-  let { engines } = metadata;
-
-  if (engines === null || typeof(engines) !== "object")
-    return new Error("Malformed engines' property in metadata");
-
-  let applications = Object.keys(engines);
-
-  let versionRange;
-  applications.forEach(function(name) {
-    if (is(name)) {
-      versionRange = engines[name];
-      // Continue iteration. We want to ensure the module doesn't
-      // contain a typo in the applications' name or some unknown
-      // application - `is` function throws an exception in that case.
-    }
-  });
-
-  if (typeof(versionRange) === "string") {
-    if (satisfiesVersion(versionRange))
-      return null;
-
-    return new Error("Unsupported Application version: The module " + id +
-            " currently supports only version " + versionRange + " of " +
-            name + ".");
-  }
-
-  return new Error("Unsupported Application: The module " + id +
-            " currently supports only " + applications.join(", ") + ".")
-}
-exports.incompatibility = incompatibility;
--- a/addon-sdk/source/test/test-cuddlefish.js
+++ b/addon-sdk/source/test/test-cuddlefish.js
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 'use strict';
 
 const { Loader, Require, unload, override } = require('sdk/loader/cuddlefish');
-const app = require('sdk/system/xul-app');
 const packaging = require('@loader/options');
 
 exports['test loader'] = function(assert) {
   var prints = [];
   function print(message) {
     prints.push(message);
   }
 
@@ -39,24 +39,9 @@ exports['test loader'] = function(assert
   });
 
   unload(loader, 'test');
 
   assert.equal(unloadsCalled, 'ba',
                'loader.unload() must call listeners in LIFO order.');
 };
 
-exports['test loader on unsupported modules'] = function(assert) {
-  let loader = Loader({});
-  let err = "";
-  assert.throws(() => {
-    if (!app.is('Firefox')) {
-      require('./fixtures/loader/unsupported/firefox');
-    }
-    else {
-      require('./fixtures/loader/unsupported/fennec');
-    }
-  }, /^Unsupported Application/, "throws Unsupported Application");
-
-  unload(loader);
-};
-
-require('sdk/test').run(exports);
+require('test').run(exports);
--- a/addon-sdk/source/test/test-loader.js
+++ b/addon-sdk/source/test/test-loader.js
@@ -1,24 +1,24 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 'use strict';
 
 let {
   Loader, main, unload, parseStack, generateMap, resolve, join
 } = require('toolkit/loader');
 let { readURI } = require('sdk/net/url');
 
 let root = module.uri.substr(0, module.uri.lastIndexOf('/'))
 
+
 // The following adds Debugger constructor to the global namespace.
 const { Cu } = require('chrome');
-const app = require('sdk/system/xul-app');
-
 const { addDebuggerToGlobal } = Cu.import('resource://gre/modules/jsdebugger.jsm', {});
 addDebuggerToGlobal(this);
 
 exports['test resolve'] = function (assert) {
   let cuddlefish_id = 'sdk/loader/cuddlefish';
   assert.equal(resolve('../index.js', './dir/c.js'), './index.js');
   assert.equal(resolve('./index.js', './dir/c.js'), './dir/index.js');
   assert.equal(resolve('./dir/c.js', './index.js'), './dir/c.js');
@@ -326,17 +326,17 @@ exports['test invisibleToDebugger: true'
     assert.ok(true, 'debugger did not add invisible value');
   }
 };
 
 exports['test console global by default'] = function (assert) {
   let uri = root + '/fixtures/loader/globals/';
   let loader = Loader({ paths: { '': uri }});
   let program = main(loader, 'main');
-
+ 
   assert.ok(typeof program.console === 'object', 'global `console` exists');
   assert.ok(typeof program.console.log === 'function', 'global `console.log` exists');
 
   let loader2 = Loader({ paths: { '': uri }, globals: { console: fakeConsole }});
   let program2 = main(loader2, 'main');
 
   assert.equal(program2.console, fakeConsole,
     'global console can be overridden with Loader options');
@@ -361,24 +361,9 @@ exports['test shared globals'] = functio
 
   assert.ok(Cu.getGlobalForObject(m).foo, "main is shared");
   assert.ok(Cu.getGlobalForObject(a).foo, "a is shared");
   assert.ok(!Cu.getGlobalForObject(b).foo, "b isn't shared");
 
   unload(loader);
 }
 
-exports['test loader on unsupported modules'] = function(assert) {
-  let loader = Loader({});
-  let err = "";
-  assert.throws(() => {
-    if (!app.is('Firefox')) {
-      require('./fixtures/loader/unsupported/firefox');
-    }
-    else {
-      require('./fixtures/loader/unsupported/fennec');
-    }
-  }, /^Unsupported Application/, "throws Unsupported Application");
-
-  unload(loader);
-};
-
-require('sdk/test').run(exports);
+require('test').run(exports);