Bug 1082450 - Fix quitter extension. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Wed, 15 Oct 2014 15:05:08 +0200
changeset 210537 1f19fa816c9746f423736068f6ebbabf282eb0e6
parent 210536 1c9d6c298b5aa6328325ba302e0bde931ba1a79a
child 210538 687aa81bd41c42d6e9755242b32874362d577967
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersgabor
bugs1082450
milestone36.0a1
Bug 1082450 - Fix quitter extension. r=gabor
tools/quitter/contentscript.js
--- a/tools/quitter/contentscript.js
+++ b/tools/quitter/contentscript.js
@@ -1,38 +1,37 @@
 /* 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/. */
 
 var Ci = Components.interfaces;
 var Cc = Components.classes;
+var Cu = Components.utils;
 
 function Quitter() {
 }
 
 Quitter.prototype = {
   toString: function() { return "[Quitter]"; },
-  quit: function() {
-    sendSyncMessage('Quitter.Quit', {});
-  },
-  __exposedProps__: {
-    'toString': 'r',
-    'quit': 'r'
-  }
+  quit: function() { sendSyncMessage('Quitter.Quit', {}); }
 };
 
 // This is a frame script, so it may be running in a content process.
 // In any event, it is targeted at a specific "tab", so we listen for
 // the DOMWindowCreated event to be notified about content windows
 // being created in this context.
 
 function QuitterManager() {
   addEventListener("DOMWindowCreated", this, false);
 }
 
 QuitterManager.prototype = {
   handleEvent: function handleEvent(aEvent) {
+    var quitter = new Quitter(window);
     var window = aEvent.target.defaultView;
-    window.wrappedJSObject.Quitter = new Quitter(window);
+    window.wrappedJSObject.Quitter = Cu.cloneInto({
+      toString: quitter.toString.bind(quitter),
+      quit: quitter.quit.bind(quitter)
+    }, window, {cloneFunctions: true});
   }
 };
 
 var quittermanager = new QuitterManager();