author | Clint Talbert <ctalbert@mozilla.com> |
Fri, 12 Nov 2010 11:08:45 -0800 | |
changeset 57416 | 83ef401a4f255ff1b35f1afe6feb6dc6094310e0 |
parent 57414 | 3e941917e221c347d9c0fb4be2601afc1f7d135b (current diff) |
parent 57415 | bb05f8488944166fc6e722542ec029241a04f3a3 (diff) |
child 57417 | d3790fe503e562119fa47d77a0f4f8d1a19705a9 |
push id | 16914 |
push user | ctalbert@mozilla.com |
push date | Fri, 12 Nov 2010 19:09:30 +0000 |
treeherder | mozilla-central@83ef401a4f25 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bustage |
milestone | 2.0b8pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
testing/mochitest/specialpowers/Makefile.in | file | annotate | diff | comparison | revisions | |
testing/mochitest/specialpowers/chrome.manifest | file | annotate | diff | comparison | revisions | |
testing/mochitest/specialpowers/components/SpecialPowersObserver.js | file | annotate | diff | comparison | revisions | |
testing/mochitest/specialpowers/content/specialpowers.js | file | annotate | diff | comparison | revisions | |
testing/mochitest/specialpowers/install.rdf | file | annotate | diff | comparison | revisions | |
testing/mochitest/specialpowers/jar.mn | file | annotate | diff | comparison | revisions | |
testing/mochitest/tests/file_SpecialPowersFrame1.html | file | annotate | diff | comparison | revisions | |
testing/mochitest/tests/test_SpecialPowersExtension.html | file | annotate | diff | comparison | revisions | |
testing/mochitest/tests/test_SpecialPowersExtension2.html | file | annotate | diff | comparison | revisions |
--- a/testing/mochitest/Makefile.in +++ b/testing/mochitest/Makefile.in @@ -38,25 +38,23 @@ DEPTH = ../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ relativesrcdir = testing/mochitest include $(DEPTH)/config/autoconf.mk -DIRS = \ - MochiKit \ - static \ - dynamic \ - tests \ - chrome \ - ssltunnel \ - specialpowers \ - $(NULL) +DIRS = MochiKit \ + static \ + dynamic \ + tests \ + chrome \ + ssltunnel \ + $(NULL) NO_JS_MANIFEST = 1 MOZ_CHROME_FILE_FORMAT = jar DIST_FILES = install.rdf # Used in install.rdf USE_EXTENSION_MANIFEST = 1
--- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -458,25 +458,16 @@ class Mochitest(object): self.server.stop() def getLogFilePath(self, logFile): """ return the log file path relative to the device we are testing on, in most cases it will be the full path on the local system """ return self.getFullPath(logFile) - def installSpecialPowersExtension(self, browserEnv, options): - """ install the Special Powers extension for special testing capabilities """ - extensionSource = os.path.normpath(os.path.join(self.SCRIPT_DIRECTORY, "specialpowers")) - self.automation.log.info("INFO | runtests.py | Installing extension at %s to %s." % - (extensionSource, options.profilePath)) - - self.automation.installExtension(extensionSource, options.profilePath, "special-powers@mozilla.org") - self.automation.log.info("INFO | runtests.py | Done installing extension.") - def buildProfile(self, options): """ create the profile and add optional chrome bits and files if requested """ self.automation.initializeProfile(options.profilePath, options.extraPrefs, useServerLocations = True) manifest = self.addChromeToProfile(options) self.copyExtraFilesToProfile(options) return manifest def buildBrowserEnv(self, options): @@ -583,23 +574,16 @@ class Mochitest(object): browserEnv = self.buildBrowserEnv(options) if browserEnv is None: return 1 manifest = self.buildProfile(options) if manifest is None: return 1 - - # We only need special powers in non-chrome harnesses - if (not options.browserChrome and - not options.chrome and - not options.a11y): - self.installSpecialPowersExtension(browserEnv, options) - self.startWebServer(options) self.startWebSocketServer(options) testURL = self.buildTestPath(options) self.buildURLOptions(options) if len(self.urlOpts) > 0: testURL += "?" + "&".join(self.urlOpts)
deleted file mode 100644 --- a/testing/mochitest/specialpowers/Makefile.in +++ /dev/null @@ -1,64 +0,0 @@ -# -# ***** 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 mozilla.org code. -# -# The Initial Developer of the Original Code is -# Mozilla Foundation -# Portions created by the Initial Developer are Copyright (C) 2010 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# -# 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 ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ -relativesrcdir = testing/mochitest/specialpowers - -include $(DEPTH)/config/autoconf.mk - -NO_JS_MANIFEST = 1 -DIST_FILES = \ - install.rdf \ - chrome.manifest \ - $(NULL) - -EXTRA_COMPONENTS = components/SpecialPowersObserver.js - -XPI_NAME=specialpowers - -DEST_DIR=testing/mochitest - -# Used in install.rdf -USE_EXTENSION_MANIFEST=1 - -include $(topsrcdir)/config/rules.mk - -libs:: - (cd $(DIST)/xpi-stage && tar $(TAR_CREATE_FLAGS) - specialpowers) | (cd $(DEPTH)/_tests/$(DEST_DIR) && tar -xf -)
deleted file mode 100644 --- a/testing/mochitest/specialpowers/chrome.manifest +++ /dev/null @@ -1,4 +0,0 @@ -content specialpowers chrome/specialpowers/content/ -component {59a52458-13e0-4d93-9d85-a637344f29a1} components/SpecialPowersObserver.js -contract @mozilla.org/special-powers-observer;1 {59a52458-13e0-4d93-9d85-a637344f29a1} -category profile-after-change @mozilla.org/special-powers-observer;1 @mozilla.org/special-powers-observer;1
deleted file mode 100644 --- a/testing/mochitest/specialpowers/components/SpecialPowersObserver.js +++ /dev/null @@ -1,164 +0,0 @@ -/* ***** 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 Special Powers code - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Jesse Ruderman <jruderman@mozilla.com> - * Robert Sayre <sayrer@gmail.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 *****/ - -// Based on: -// https://bugzilla.mozilla.org/show_bug.cgi?id=549539 -// https://bug549539.bugzilla.mozilla.org/attachment.cgi?id=429661 -// https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_1.9.3 -// http://mxr.mozilla.org/mozilla-central/source/toolkit/components/console/hudservice/HUDService.jsm#3240 -// https://developer.mozilla.org/en/how_to_build_an_xpcom_component_in_javascript - -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://specialpowers/content/specialpowers.js" - -/** - * Special Powers Exception - used to throw exceptions nicely - **/ -function SpecialPowersException(aMsg) { - this.message = aMsg; - this.name = "SpecialPowersException"; -} - -SpecialPowersException.prototype.toString = function() { - return this.name + ': "' + this.message + '"'; -}; - -/* XPCOM gunk */ -function SpecialPowersObserver() {} - -SpecialPowersObserver.prototype = { - classDescription: "Special powers Observer for use in testing.", - classID: Components.ID("{59a52458-13e0-4d93-9d85-a637344f29a1}"), - contractID: "@mozilla.org/special-powers-observer;1", - QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver]), - _xpcom_categories: [{category: "profile-after-change", service: true }], - - observe: function(aSubject, aTopic, aData) - { - if (aTopic == "profile-after-change") { - this.init(); - } else if (aTopic == "content-document-global-created") { - var w = aSubject.wrappedJSObject; - - if (w) { - var messageManager = Cc["@mozilla.org/globalmessagemanager;1"]. - getService(Ci.nsIChromeFrameMessageManager); - // Register for any messages our API needs us to handle - messageManager.addMessageListener("SPPrefService", this); - - // Load the frame script into the window - messageManager.loadFrameScript(CHILD_SCRIPT, true); - //dump("\n\n TESTME!! Loaded SPPrefService as well as frame script now\n\n"); - } else { - dump("TEST-INFO | specialpowers | Can't attach special powers to window " + aSubject + "\n"); - } - } else if (aTopic == "xpcom-shutdown") { - this.uninit(); - } - }, - - init: function() - { - var obs = Services.obs; - obs.addObserver(this, "xpcom-shutdown", false); - obs.addObserver(this, "content-document-global-created", false); - }, - - uninit: function() - { - var obs = Services.obs; - obs.removeObserver(this, "content-document-global-created"); - }, - - /** - * 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 "SPPrefService": - var prefs = Services.prefs; - var prefType = aMessage.json.prefType.toUpperCase(); - var prefName = aMessage.json.prefName; - var prefValue = aMessage.json.prefValue ? aMessage.json.prefValue : null; - - if (aMessage.json.op == "get") { - if (!prefName || !prefType) - throw new SpecialPowersException("Invalid parameters for get in SPPrefService"); - } else if (aMessage.json.op == "set") { - if (!prefName || !prefType || !prefValue) - throw new SpecialPowersException("Invalid parameters for set in SPPrefService"); - } else { - throw new SpecialPowersException("Invalid operation for SPPrefService"); - } - // Now we make the call - switch(prefType) { - case "BOOL": - if (aMessage.json.op == "get") - return(prefs.getBoolPref(prefName)); - else - return(prefs.setBoolPref(prefName, prefValue)); - case "INT": - if (aMessage.json.op == "get") - return(prefs.getIntPref(prefName)); - else - return(prefs.setIntPref(prefName, prefValue)); - case "CHAR": - if (aMessage.json.op == "get") - return(prefs.getCharPref(prefName)); - else - return(prefs.setCharPref(prefName, prefValue)); - case "COMPLEX": - if (aMessage.json.op == "get") - return(prefs.getComplexValue(prefName, prefValue[0])); - else - return(prefs.setComplexValue(prefName, prefValue[0], prefValue[1])); - } - break; - default: - throw new SpecialPowersException("Unrecognized Special Powers API"); - } - } -}; - -const NSGetFactory = XPCOMUtils.generateNSGetFactory([SpecialPowersObserver]);
deleted file mode 100644 --- a/testing/mochitest/specialpowers/content/specialpowers.js +++ /dev/null @@ -1,146 +0,0 @@ -/* ***** 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 Special Powers code - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Clint Talbert cmtalbert@gmail.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 *****/ - -/* This code is loaded in every child process that is started by mochitest in - * order to be used as a replacement for UniversalXPConnect - */ -function SpecialPowers() {} - -var SpecialPowers = { - sanityCheck: function() { return "foo"; }, - - // Mimic the get*Pref API - getBoolPref: function(aPrefName) { - return (this._getPref(aPrefName, 'BOOL')); - }, - getIntPref: function(aPrefName) { - return (this._getPref(aPrefName, 'INT')); - }, - getCharPref: function(aPrefName) { - return (this._getPref(aPrefName, 'CHAR')); - }, - getComplexValue: function(aPrefName, aIid) { - return (this._getPref(aPrefName, 'COMPLEX', aIid)); - }, - - // Mimic the set*Pref API - setBoolPref: function(aPrefName, aValue) { - return (this._setPref(aPrefName, 'BOOL', aValue)); - }, - setIntPref: function(aPrefName, aValue) { - return (this._setPref(aPrefName, 'INT', aValue)); - }, - setCharPref: function(aPrefName, aValue) { - return (this._setPref(aPrefName, 'CHAR', aValue)); - }, - setComplexValue: function(aPrefName, aIid, aValue) { - return (this._setPref(aPrefName, 'COMPLEX', aValue, aIid)); - }, - - // Private pref functions to communicate to chrome - _getPref: function(aPrefName, aPrefType, aIid) { - var msg = {}; - if (aIid) { - // Overloading prefValue to handle complex prefs - msg = {'op':'get', 'prefName': aPrefName, 'prefType':aPrefType, 'prefValue':[aIid]}; - } else { - msg = {'op':'get', 'prefName': aPrefName,'prefType': aPrefType}; - } - return(sendSyncMessage('SPPrefService', msg)[0]); - }, - _setPref: function(aPrefName, aPrefType, aValue, aIid) { - var msg = {}; - if (aIid) { - msg = {'op':'set','prefName':aPrefName, 'prefType': aPrefType, 'prefValue': [aIid,aValue]}; - } else { - msg = {'op':'set', 'prefName': aPrefName, 'prefType': aPrefType, 'prefValue': aValue}; - } - return(sendSyncMessage('SPPrefService', msg)[0]); - } -} - -// Attach our API to the window -function attachToWindow() { - try { - if ((content !== null) && - (content !== undefined) && - (content.wrappedJSObject)) { - content.wrappedJSObject.SpecialPowers = SpecialPowers; - } - } catch(ex) { - dump("TEST-INFO | specialpowers.js | Failed to attach specialpowers to window exception: " + ex + "\n"); - } -} - -// In true IPC, this loads in the child process so we need our own observer here -// to ensure we actually get attached, otherwise we'll miss content-document-global-created -// notifications -// NOTE: The observers are GC'd when the window dies, so while this looks like it should -// leak, it actually doesn't. And if you add in an observer for dom-window-destroyed or -// xpcom-shutdown and upon capturing either of those events you unregister the -// content-document-global-created observer, then in the child process you will never -// be able to capture another content-document-global-created on the next page load. Essentially, -// this is registered inside the child process once by our SpecialPowersObserver, and after that, -// we will no longer trip that chrome code again. -function frameScriptObserver() { - this.register(); -} -frameScriptObserver.prototype = { - observe: function(aSubject, aTopic, aData) { - if (aTopic == "content-document-global-created") { - attachToWindow(); - } - }, - register: function() { - var obsSvc = Components.classes["@mozilla.org/observer-service;1"] - .getService(Components.interfaces.nsIObserverService); - obsSvc.addObserver(this, "content-document-global-created", false); - }, - unregister: function() { - var obsSvc = Components.classes["@mozilla.org/observer-service;1"] - .getService(Components.interfaces.nsIObserverService); - obsSvc.removeObserver(this, "content-document-global-created"); - } -}; - -var xulruntime = Components.classes["@mozilla.org/xre/app-info;1"] - .getService(Components.interfaces.nsIXULRuntime); -if (xulruntime.processType == 2) { - var frameScriptObsv = new frameScriptObserver(); -} else { - attachToWindow(); -}
deleted file mode 100644 --- a/testing/mochitest/specialpowers/install.rdf +++ /dev/null @@ -1,26 +0,0 @@ -<?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>special-powers@mozilla.org</em:id> - <em:version>2010.07.23</em:version> - <em:type>2</em:type> - - <!-- Target Application this extension can install into, - with minimum and maximum supported versions. --> - <em:targetApplication> - <Description> - <em:id>toolkit@mozilla.org</em:id> -#expand <em:minVersion>__MOZILLA_VERSION_U__</em:minVersion> -#expand <em:maxVersion>__MOZILLA_VERSION_U__</em:maxVersion> - </Description> - </em:targetApplication> - - <!-- Front End MetaData --> - <em:name>Special Powers</em:name> - <em:description>Special powers for use in testing.</em:description> - <em:creator>Mozilla</em:creator> - </Description> -</RDF>
deleted file mode 100644 --- a/testing/mochitest/specialpowers/jar.mn +++ /dev/null @@ -1,3 +0,0 @@ -specialpowers.jar: -% content specialpowers %content/ - content/specialpowers.js (content/specialpowers.js)
--- a/testing/mochitest/tests/Makefile.in +++ b/testing/mochitest/tests/Makefile.in @@ -48,18 +48,15 @@ PARALLEL_DIRS = \ MochiKit-1.4.2 \ SimpleTest \ browser \ $(NULL) include $(topsrcdir)/config/rules.mk _TEST_FILES = \ - test_sanity.html \ - test_SpecialPowersExtension.html \ - test_SpecialPowersExtension2.html \ - file_SpecialPowersFrame1.html \ - $(NULL) + test_sanity.html \ + $(NULL) # Copy the sanity tests into a subdirectory, so the top level is all dirs # in the test screen. libs:: $(_TEST_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/$(relativesrcdir)/Harness_sanity
deleted file mode 100644 --- a/testing/mochitest/tests/file_SpecialPowersFrame1.html +++ /dev/null @@ -1,15 +0,0 @@ -<html> - <head> - <script type="text/javascript" src="/MochiKit/packed.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> - </head> - <body> - <div id="content" style="display: none"> - <script type="text/javascript"> - is(content.window.SpecialPowers.sanityCheck(), "foo", "Check Special Powers in iframe"); - </script> - </div> - </body> -</html>
deleted file mode 100644 --- a/testing/mochitest/tests/test_SpecialPowersExtension.html +++ /dev/null @@ -1,40 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test for SpecialPowers extension</title> - <script type="text/javascript" src="/MochiKit/packed.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> - -<div id="content" style="display: none"> - -</div> -<pre id="test"> -<script class="testbody" type="text/javascript"> - -/** Test for SpecialPowers extension **/ -is(content.window.SpecialPowers.sanityCheck(), "foo", "check to see whether the Special Powers extension is installed."); - -// Test a sync call into chrome -content.window.SpecialPowers.setBoolPref('extensions.checkCompatibility', true); -is(content.window.SpecialPowers.getBoolPref('extensions.checkCompatibility'), true, "Check to see if we can set a preference properly"); - -// Test a int pref -content.window.SpecialPowers.setIntPref('extensions.foobar', 42); -is(content.window.SpecialPowers.getIntPref('extensions.foobar'), 42, "Check int pref"); - -// Test a string pref -content.window.SpecialPowers.setCharPref("extensions.foobaz", "hi there"); -is(content.window.SpecialPowers.getCharPref("extensions.foobaz"), "hi there", "Check string pref"); - -// Test Complex Pref - TODO: Without chrome access, I don't know how you'd actually -// set this preference since you have to create an XPCOM object. -// Leaving untested for now. -</script> -</pre> -</body> -</html> -
deleted file mode 100644 --- a/testing/mochitest/tests/test_SpecialPowersExtension2.html +++ /dev/null @@ -1,20 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Test for SpecialPowers extension</title> - <script type="text/javascript" src="/MochiKit/packed.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> - -<div id="content" class="testbody"> - <script type="text/javascript"> - is(content.window.SpecialPowers.sanityCheck(), "foo", "Special Powers top level"); - </script> - <iframe id="frame1" src="file_SpecialPowersFrame1.html"> - </iframe> -</div> -</body> -</html>