2011-05-26 17:07:35 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2017-05-01 13:38:39 +03:00
|
|
|
/* eslint-env mozilla/frame-script */
|
|
|
|
|
2011-05-26 17:07:35 +04:00
|
|
|
function Quitter() {
|
|
|
|
}
|
|
|
|
|
|
|
|
Quitter.prototype = {
|
2017-05-01 13:38:39 +03:00
|
|
|
toString() { return "[Quitter]"; },
|
|
|
|
quit() { sendSyncMessage("Quitter.Quit", {}); }
|
2011-05-26 17:07:35 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// 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) {
|
2014-10-15 17:05:08 +04:00
|
|
|
var quitter = new Quitter(window);
|
2011-05-26 17:07:35 +04:00
|
|
|
var window = aEvent.target.defaultView;
|
2014-10-15 17:05:08 +04:00
|
|
|
window.wrappedJSObject.Quitter = Cu.cloneInto({
|
|
|
|
toString: quitter.toString.bind(quitter),
|
|
|
|
quit: quitter.quit.bind(quitter)
|
|
|
|
}, window, {cloneFunctions: true});
|
2011-05-26 17:07:35 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var quittermanager = new QuitterManager();
|