Backed out changeset 32f70e593bf6 due to intermittent orange on mochi-1 a=bustage

This commit is contained in:
Clint Talbert 2010-11-12 11:03:44 -08:00
parent ccf09edf01
commit 4ef8182731
12 changed files with 9 additions and 512 deletions

View File

@ -43,15 +43,13 @@ 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

View File

@ -463,15 +463,6 @@ class Mochitest(object):
"""
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)
@ -588,13 +579,6 @@ class Mochitest(object):
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)

View File

@ -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 -)

View File

@ -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

View File

@ -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]);

View File

@ -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();
}

View File

@ -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>

View File

@ -1,3 +0,0 @@
specialpowers.jar:
% content specialpowers %content/
content/specialpowers.js (content/specialpowers.js)

View File

@ -53,11 +53,8 @@ PARALLEL_DIRS = \
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.

View File

@ -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>

View File

@ -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>

View File

@ -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>