Bug 1129567: Revert page-mod to a non-e10s compliant version to fix jank when loading amazon.com. r=jsantell, a=sledru
authorDave Townsend <dtownsend@oxymoronical.com>
Thu, 05 Feb 2015 07:56:38 -0800
changeset 243692 18d9d9422db6
parent 243691 5eae334a2b31
child 243693 b1db02330579
push id4439
push userdtownsend@mozilla.com
push date2015-02-05 15:58 +0000
treeherdermozilla-beta@18d9d9422db6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsantell, sledru
bugs1129567
milestone36.0
Bug 1129567: Revert page-mod to a non-e10s compliant version to fix jank when loading amazon.com. r=jsantell, a=sledru
addon-sdk/source/lib/sdk/page-mod.js
--- a/addon-sdk/source/lib/sdk/page-mod.js
+++ b/addon-sdk/source/lib/sdk/page-mod.js
@@ -9,20 +9,21 @@ module.metadata = {
 
 const observers = require('./system/events');
 const { contract: loaderContract } = require('./content/loader');
 const { contract } = require('./util/contract');
 const { getAttachEventType, WorkerHost } = require('./content/utils');
 const { Class } = require('./core/heritage');
 const { Disposable } = require('./core/disposable');
 const { WeakReference } = require('./core/reference');
-const { Worker } = require('./content/worker-parent');
+const { Worker } = require('./content/worker');
 const { EventTarget } = require('./event/target');
 const { on, emit, once, setListeners } = require('./event/core');
 const { on: domOn, removeListener: domOff } = require('./dom/events');
+const { pipe } = require('./event/utils');
 const { isRegExp, isUndefined } = require('./lang/type');
 const { merge } = require('./util/object');
 const { windowIterator } = require('./deprecated/window-utils');
 const { isBrowser, getFrames } = require('./window/utils');
 const { getTabs, getTabContentWindow, getTabForContentWindow,
         getURI: getTabURI } = require('./tabs/utils');
 const { ignoreWindow } = require('./private-browsing/utils');
 const { Style } = require("./stylesheet/style");
@@ -108,16 +109,17 @@ const modContract = contract(merge({}, l
  * PageMod constructor (exported below).
  * @constructor
  */
 const PageMod = Class({
   implements: [
     modContract.properties(modelFor),
     EventTarget,
     Disposable,
+    WeakReference
   ],
   extends: WorkerHost(workerFor),
   setup: function PageMod(options) {
     let mod = this;
     let model = modContract(options);
     models.set(this, model);
 
     // Set listeners on {PageMod} itself, not the underlying worker,
@@ -206,25 +208,21 @@ function createWorker (mod, window) {
     contentScriptFile: mod.contentScriptFile,
     contentScriptOptions: mod.contentScriptOptions,
     // Bug 980468: Syntax errors from scripts can happen before the worker
     // can set up an error handler. They are per-mod rather than per-worker
     // so are best handled at the mod level.
     onError: (e) => emit(mod, 'error', e)
   });
   workers.set(mod, worker);
-  worker.on('*', (event, ...args) => {
-    // worker's "attach" event passes a window as the argument
-    // page-mod's "attach" event needs a worker
-    if (event === 'attach')
-      emit(mod, event, worker)
-    else 
-      emit(mod, event, ...args);
-  })
-  once(worker, 'detach', () => worker.destroy());
+  pipe(worker, mod);
+  emit(mod, 'attach', worker);
+  once(worker, 'detach', function detach() {
+    worker.destroy();
+  });
 }
 
 function onContent (mod, window) {
   // not registered yet
   if (!pagemods.has(mod))
     return;
 
   let isTopDocument = window.top === window;