Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use quit.js instead of re-inventing the wheel

  • Loading branch information...
commit dd3d09a0b73ca87c93a80546d0a87bf5e8d4efe7 1 parent 9d9643a
@ahal authored
View
19 peptest/extension/chrome/content/pepinit.js
@@ -45,13 +45,10 @@ const gIOS = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService)
const subscriptLoader = Cc['@mozilla.org/moz/jssubscript-loader;1']
.getService(Components.interfaces.mozIJSSubScriptLoader);
-var noisy = false;
var appContent;
function pepInit(args) {
try {
- if (args.noisy) noisy = true;
-
let manifest = args.manifest;
let obj = loadManifest(manifest);
let firstRun = true;
@@ -70,13 +67,13 @@ function pepInit(args) {
function runTests(tests) {
for (let i = 0; i < tests.length; ++i) {
runFile(tests[i]);
- // Sleep for half a second because tests will interfere with each other if loaded too quickly
- utils.sleep(500);
+ // Sleep for a second because tests will interfere with each other if loaded too quickly
+ // TODO Figure out why they interfere with each other
+ utils.sleep(1000);
}
// quit the application
- let app = Components.classes['@mozilla.org/toolkit/app-startup;1']
- .getService(Components.interfaces.nsIAppStartup);
- app.quit(Components.interfaces.nsIAppStartup.eForceQuit);
+ subscriptLoader.loadSubScript('resource://pep/quit.js')
+ goQuitApplication();
}
/**
@@ -113,9 +110,3 @@ MozmillMsgListener.prototype.update = function(msgType, obj) {
utils.dumpLine('MOZMILL ' + msgType + ' ' + JSON.stringify(obj) + '\n');
}
msg.broker.addListener(new MozmillMsgListener());
-
-function debugLine(str) {
- if (noisy) {
- utils.dumpLine(str);
- }
-};
View
93 peptest/extension/resource/pep/quit.js
@@ -0,0 +1,93 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is The Original Code is Mozilla Automated Testing Code
+*
+* The Initial Developer of the Original Code is
+* Mozilla Corporation.
+* Portions created by the Initial Developer are Copyright (C) 2005
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s): Bob Clary <bob@bclary.com>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+/*
+From mozilla/toolkit/content
+These files did not have a license
+*/
+
+function canQuitApplication() {
+ var os = Components.classes["@mozilla.org/observer-service;1"]
+ .getService(Components.interfaces.nsIObserverService);
+ if (!os) {
+ return true;
+ }
+
+ try {
+ var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
+ .createInstance(Components.interfaces.nsISupportsPRBool);
+ os.notifyObservers(cancelQuit, "quit-application-requested", null);
+
+ // Something aborted the quit process.
+ if (cancelQuit.data) {
+ return false;
+ }
+ }
+ catch (ex) {
+ }
+ return true;
+}
+
+function goQuitApplication() {
+ if (!canQuitApplication()) {
+ return false;
+ }
+
+ const kAppStartup = '@mozilla.org/toolkit/app-startup;1';
+ const kAppShell = '@mozilla.org/appshell/appShellService;1';
+ var appService;
+ var forceQuit;
+
+ if (kAppStartup in Components.classes) {
+ appService = Components.classes[kAppStartup].
+ getService(Components.interfaces.nsIAppStartup);
+ forceQuit = Components.interfaces.nsIAppStartup.eForceQuit;
+ } else if (kAppShell in Components.classes) {
+ appService = Components.classes[kAppShell].
+ getService(Components.interfaces.nsIAppShellService);
+ forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
+ } else {
+ throw 'goQuitApplication: no AppStartup/appShell';
+ }
+
+ try {
+ appService.quit(forceQuit);
+ }
+ catch(ex) {
+ throw('goQuitApplication: ' + ex);
+ }
+ return true;
+}
View
1  peptest/runpeptests.py
@@ -111,7 +111,6 @@ def __init__(self, options, **kwargs):
# TODO Make browserArgs a list
cmdargs.extend(self.options.browserArgs)
cmdargs.extend(['-pep-start', os.path.realpath(jsonManifest.name)])
- cmdargs.append('-pep-noisy')
# run with managed process handler
self.runner = self.runner_class(profile=self.profile,
Please sign in to comment.
Something went wrong with that request. Please try again.