diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /tools/quitter/contentscript.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'tools/quitter/contentscript.js')
-rw-r--r-- | tools/quitter/contentscript.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/quitter/contentscript.js b/tools/quitter/contentscript.js new file mode 100644 index 000000000..e25f5dbc8 --- /dev/null +++ b/tools/quitter/contentscript.js @@ -0,0 +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', {}); } +}; + +// 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 = Cu.cloneInto({ + toString: quitter.toString.bind(quitter), + quit: quitter.quit.bind(quitter) + }, window, {cloneFunctions: true}); + } +}; + +var quittermanager = new QuitterManager(); |