summaryrefslogtreecommitdiffstats
path: root/tools/quitter
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /tools/quitter
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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')
-rw-r--r--tools/quitter/Makefile.in6
-rw-r--r--tools/quitter/QuitterObserver.js70
-rw-r--r--tools/quitter/chrome.manifest4
-rw-r--r--tools/quitter/contentscript.js37
-rw-r--r--tools/quitter/install.rdf35
-rw-r--r--tools/quitter/jar.mn3
-rw-r--r--tools/quitter/moz.build21
-rw-r--r--tools/quitter/quitter@mozilla.org.xpibin0 -> 6864 bytes
8 files changed, 176 insertions, 0 deletions
diff --git a/tools/quitter/Makefile.in b/tools/quitter/Makefile.in
new file mode 100644
index 000000000..bc0c0852c
--- /dev/null
+++ b/tools/quitter/Makefile.in
@@ -0,0 +1,6 @@
+#
+# 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/.
+
+XPI_PKGNAME = quitter@mozilla.org
diff --git a/tools/quitter/QuitterObserver.js b/tools/quitter/QuitterObserver.js
new file mode 100644
index 000000000..fe2a810c9
--- /dev/null
+++ b/tools/quitter/QuitterObserver.js
@@ -0,0 +1,70 @@
+/* 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/. */
+
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+const CHILD_SCRIPT = "chrome://quitter/content/contentscript.js";
+
+/* XPCOM gunk */
+function QuitterObserver() {}
+
+QuitterObserver.prototype = {
+ classDescription: "Quitter Observer for use in testing.",
+ classID: Components.ID("{c235a986-5ac1-4f28-ad73-825dae9bad90}"),
+ contractID: "@mozilla.org/quitter-observer;1",
+ QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver]),
+ _xpcom_categories: [{category: "profile-after-change", service: true }],
+ isFrameScriptLoaded: false,
+
+ observe: function(aSubject, aTopic, aData)
+ {
+ if (aTopic == "profile-after-change") {
+ this.init();
+ } else if (!this.isFrameScriptLoaded &&
+ aTopic == "chrome-document-global-created") {
+
+ var messageManager = Cc["@mozilla.org/globalmessagemanager;1"].
+ getService(Ci.nsIMessageBroadcaster);
+ // Register for any messages our API needs us to handle
+ messageManager.addMessageListener("Quitter.Quit", this);
+
+ messageManager.loadFrameScript(CHILD_SCRIPT, true);
+ this.isFrameScriptLoaded = true;
+ } else if (aTopic == "xpcom-shutdown") {
+ this.uninit();
+ }
+ },
+
+ init: function()
+ {
+ var obs = Services.obs;
+ obs.addObserver(this, "xpcom-shutdown", false);
+ obs.addObserver(this, "chrome-document-global-created", false);
+ },
+
+ uninit: function()
+ {
+ var obs = Services.obs;
+ obs.removeObserver(this, "chrome-document-global-created", false);
+ },
+
+ /**
+ * messageManager callback function
+ * This will get requests from our API in the window and process them in chrome for it
+ **/
+ receiveMessage: function(aMessage) {
+ switch(aMessage.name) {
+ case "Quitter.Quit":
+ let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
+ appStartup.quit(Ci.nsIAppStartup.eForceQuit);
+ break;
+ }
+ }
+};
+
+const NSGetFactory = XPCOMUtils.generateNSGetFactory([QuitterObserver]);
diff --git a/tools/quitter/chrome.manifest b/tools/quitter/chrome.manifest
new file mode 100644
index 000000000..b01f04655
--- /dev/null
+++ b/tools/quitter/chrome.manifest
@@ -0,0 +1,4 @@
+category profile-after-change @mozilla.org/quitter-observer;1 @mozilla.org/quitter-observer;1
+component {c235a986-5ac1-4f28-ad73-825dae9bad90} components/QuitterObserver.js
+content quitter chrome/quitter/content/
+contract @mozilla.org/quitter-observer;1 {c235a986-5ac1-4f28-ad73-825dae9bad90}
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();
diff --git a/tools/quitter/install.rdf b/tools/quitter/install.rdf
new file mode 100644
index 000000000..184edfd2c
--- /dev/null
+++ b/tools/quitter/install.rdf
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>quitter@mozilla.org</em:id>
+ <em:version>2016.03.10</em:version>
+ <em:type>2</em:type>
+
+ <!-- Target Application this extension can install into,
+ with minimum and maximum supported versions. -->
+ <em:targetApplication>
+ <Description>
+ <!-- Firefox -->
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>45.0</em:minVersion>
+ <em:maxVersion>*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+ <em:targetApplication>
+ <Description>
+ <!-- Fennec -->
+ <em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
+ <em:minVersion>45.0</em:minVersion>
+ <em:maxVersion>*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+
+ <!-- Front End MetaData -->
+ <em:name>Quitter</em:name>
+ <em:description>Adds a quit method that content pages can use to quit the application.</em:description>
+ <em:creator>Mozilla</em:creator>
+ </Description>
+</RDF>
diff --git a/tools/quitter/jar.mn b/tools/quitter/jar.mn
new file mode 100644
index 000000000..4467f923b
--- /dev/null
+++ b/tools/quitter/jar.mn
@@ -0,0 +1,3 @@
+quitter.jar:
+% content quitter %content/
+ content/contentscript.js (contentscript.js)
diff --git a/tools/quitter/moz.build b/tools/quitter/moz.build
new file mode 100644
index 000000000..d58c0d7b4
--- /dev/null
+++ b/tools/quitter/moz.build
@@ -0,0 +1,21 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+EXTRA_COMPONENTS += [
+ 'QuitterObserver.js',
+]
+
+XPI_NAME = 'quitter'
+
+JAR_MANIFESTS += ['jar.mn']
+
+USE_EXTENSION_MANIFEST = True
+NO_JS_MANIFEST = True
+
+FINAL_TARGET_FILES += [
+ 'chrome.manifest',
+ 'install.rdf',
+]
diff --git a/tools/quitter/quitter@mozilla.org.xpi b/tools/quitter/quitter@mozilla.org.xpi
new file mode 100644
index 000000000..a8a6b8ad0
--- /dev/null
+++ b/tools/quitter/quitter@mozilla.org.xpi
Binary files differ