| Index: lib/compat.js | 
| diff --git a/lib/compat.js b/lib/compat.js | 
| index c2b09dd500f241a8dc1ace2c7bbae6259d15b42a..f4037fcbba94206708765c913a0ccc48ef146dba 100644 | 
| --- a/lib/compat.js | 
| +++ b/lib/compat.js | 
| @@ -33,13 +33,6 @@ function require(module) | 
| require.modules = Object.create(null); | 
| require.scopes = Object.create(null); | 
|  | 
| -function importAll(module, globalObj) | 
| -{ | 
| -  let exports = require(module); | 
| -  for (let key in exports) | 
| -    globalObj[key] = exports[key]; | 
| -} | 
| - | 
| let onShutdown = { | 
| done: false, | 
| add() {}, | 
| @@ -53,8 +46,7 @@ let onShutdown = { | 
| function nsIFileURL() {} | 
| function nsIHttpChannel() {} | 
|  | 
| -let Components = | 
| -{ | 
| +let Components = { | 
| interfaces: | 
| { | 
| nsIFile: {DIRECTORY_TYPE: 0}, | 
| @@ -77,8 +69,16 @@ let Components = | 
| }, | 
| results: {}, | 
| utils: { | 
| -    import() | 
| +    import(resource) | 
| { | 
| +      let match = /^resource:\/\/gre\/modules\/(.+)\.jsm$/.exec(resource); | 
| +      let resourceName = match && match[1]; | 
| +      if (resourceName && Cu.import.resources.has(resourceName)) | 
| +        return {[resourceName]: Cu.import.resources.get(resourceName)}; | 
| + | 
| +      throw new Error( | 
| +        "Attempt to import unknown JavaScript module " + resource | 
| +      ); | 
| }, | 
| reportError(e) | 
| { | 
| @@ -94,10 +94,11 @@ const Ci = Components.interfaces; | 
| const Cr = Components.results; | 
| const Cu = Components.utils; | 
|  | 
| -let XPCOMUtils = | 
| -{ | 
| +Cu.import.resources = new Map(); | 
| + | 
| +Cu.import.resources.set("XPCOMUtils", { | 
| generateQI() {} | 
| -}; | 
| +}); | 
|  | 
| // | 
| // Fake nsIFile implementation for our I/O | 
| @@ -136,8 +137,7 @@ FakeFile.prototype = | 
| // Services.jsm module emulation | 
| // | 
|  | 
| -let Services = | 
| -{ | 
| +Cu.import.resources.set("Services", { | 
| obs: { | 
| addObserver() {}, | 
| removeObserver() {} | 
| @@ -210,22 +210,20 @@ let Services = | 
| return 0; | 
| } | 
| } | 
| -} | 
| +}); | 
|  | 
| // | 
| // FileUtils.jsm module emulation | 
| // | 
|  | 
| -let FileUtils = | 
| -{ | 
| +Cu.import.resources.set("FileUtils", { | 
| PERMS_DIRECTORY: 0 | 
| -}; | 
| +}); | 
|  | 
| function FakeTimer() | 
| { | 
| } | 
| -FakeTimer.prototype = | 
| -{ | 
| +FakeTimer.prototype = { | 
| delay: 0, | 
| callback: null, | 
| initWithCallback(callback, delay) | 
| @@ -242,7 +240,7 @@ FakeTimer.prototype = | 
| { | 
| this.callback(); | 
| } | 
| -      catch(e) | 
| +      catch (e) | 
| { | 
| Cu.reportError(e); | 
| } | 
| @@ -255,8 +253,7 @@ FakeTimer.prototype = | 
| // Add a channel property to XMLHttpRequest, Synchronizer needs it | 
| // | 
|  | 
| -XMLHttpRequest.prototype.channel = | 
| -{ | 
| +XMLHttpRequest.prototype.channel = { | 
| status: -1, | 
| notificationCallbacks: {}, | 
| loadFlags: 0, | 
|  |