Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 var Ci = Components.interfaces;
6 var Cc = Components.classes;
8 function Quitter() {
9 }
11 Quitter.prototype = {
12 toString: function() { return "[Quitter]"; },
13 quit: function() {
14 sendSyncMessage('Quitter.Quit', {});
15 },
16 __exposedProps__: {
17 'toString': 'r',
18 'quit': 'r'
19 }
20 };
22 // This is a frame script, so it may be running in a content process.
23 // In any event, it is targeted at a specific "tab", so we listen for
24 // the DOMWindowCreated event to be notified about content windows
25 // being created in this context.
27 function QuitterManager() {
28 addEventListener("DOMWindowCreated", this, false);
29 }
31 QuitterManager.prototype = {
32 handleEvent: function handleEvent(aEvent) {
33 var window = aEvent.target.defaultView;
34 window.wrappedJSObject.Quitter = new Quitter(window);
35 }
36 };
38 var quittermanager = new QuitterManager();