Bug 591325 Fix regression due to relativesrcdir landing in xpchsell test, continued cleanup in chrome tets r=ctalbert a=NPOTB

This commit is contained in:
Joel Maher 2010-09-10 10:20:38 -07:00
parent 3b1fb9d8ce
commit 161d8ae5ae
33 changed files with 169 additions and 66 deletions

View File

@ -13,11 +13,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418368
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
src="../common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js"></script>
src="../role.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js"></script>
src="../states.js"></script>
<script type="application/javascript">
function testThis(aID, aAcc, aRole, aAnchors, aName, aValid, aStartIndex,

View File

@ -12,11 +12,11 @@
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js" />
src="../common.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/role.js" />
src="../role.js" />
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js" />
src="../states.js" />
<script type="application/javascript">
<![CDATA[

View File

@ -2,8 +2,7 @@
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/a11y/accessible/treeview.css"
type="text/css"?>
<?xml-stylesheet href="../treeview.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="XUL tree selectable tests">

View File

@ -2,8 +2,7 @@
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/a11y/accessible/treeview.css"
type="text/css"?>
<?xml-stylesheet href="../treeview.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="XUL tree selectable tests">

View File

@ -2,8 +2,7 @@
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/a11y/accessible/treeview.css"
type="text/css"?>
<?xml-stylesheet href="../treeview.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="XUL tree selectable tests">

View File

@ -147,9 +147,9 @@ endif
ifdef ENABLE_TESTS
ifdef XPCSHELL_TESTS
#ifndef MODULE
#$(error Must define MODULE when defining XPCSHELL_TESTS.)
#endif
ifndef relativesrcdir
$(error Must define relativesrcdir when defining XPCSHELL_TESTS.)
endif
testxpcobjdir = $(DEPTH)/_tests/xpcshell

View File

@ -8,6 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500885
<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>
<script type="text/javascript" src="/tests/SimpleTest/mockObjects.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
@ -19,15 +20,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500885
<script type="text/javascript">
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cm = Components.manager;
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://mochikit/content/browser/toolkit/content/tests/browser/common/mockObjects.js", this);
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function MockFilePicker() { };

View File

@ -147,9 +147,9 @@ endif
ifdef ENABLE_TESTS
ifdef XPCSHELL_TESTS
#ifndef MODULE
#$(error Must define MODULE when defining XPCSHELL_TESTS.)
#endif
ifndef relativesrcdir
$(error Must define relativesrcdir when defining XPCSHELL_TESTS.)
endif
testxpcobjdir = $(DEPTH)/_tests/xpcshell

View File

@ -2,21 +2,13 @@
<html>
<head>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/mockObjects.js"></script>
</head>
<body>
<input id="target" type="file" />
<script type="text/javascript">
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cm = Components.manager;
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://mochikit/content/browser/toolkit/content/tests/browser/common/mockObjects.js", this);
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function MockFilePicker() { };

View File

@ -8,6 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=36619
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/mockObjects.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
@ -25,16 +26,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=36619
SimpleTest.waitForExplicitFinish();
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cm = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
const Cu = Components.utils;
Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://mochikit/content/browser/toolkit/content/tests/browser/common/mockObjects.js", this);
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function MockFilePicker()

View File

@ -39,6 +39,7 @@ DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = services/sync/tests
include $(DEPTH)/config/autoconf.mk

View File

@ -54,6 +54,7 @@ _SIMPLETEST_FILES = MozillaFileLogger.js \
EventUtils.js \
WindowSnapshot.js \
PluginUtils.js \
$(DEPTH)/toolkit/content/tests/browser/common/mockObjects.js \
$(NULL)
libs:: $(_SIMPLETEST_FILES)

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet
href="file:///c:/mozbuild/fx3.1/mozilla-central/testing/mochitest/tests/SimpleTest/test.css" type="text/css"?>
href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window title="Distribute to loading Livemark"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

View File

@ -50,6 +50,29 @@
* the specified ContractID (for example
* Components.interfaces.nsIFilePicker).
*/
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (Cc === undefined) {
var Cc = Components.classes;
}
if (Ci === undefined) {
var Ci = Components.interfaces;
}
if (Cu === undefined) {
var Cu = Components.utils;
}
if (Cr === undefined) {
var Cr = Components.results;
}
if (Cm === undefined) {
var Cm = Components.manager;
}
function MockObjectRegisterer(aContractID, aReplacementCtor)
{
this._contractID = aContractID;
@ -65,6 +88,7 @@ MockObjectRegisterer.prototype = {
* to ensure that unregister() is called.
*/
register: function MOR_register() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (this._originalCID)
throw new Exception("Invalid object state when calling register()");
@ -96,6 +120,7 @@ MockObjectRegisterer.prototype = {
* Restores the original factory.
*/
unregister: function MOR_unregister() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (!this._originalCID)
throw new Exception("Invalid object state when calling unregister()");

View File

@ -23,11 +23,60 @@ function copyToTemporaryFile(f)
tmpf.append("temp.manifest");
tmpf.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
tmpf.remove(false);
f.copyTo(tmpd, tmpf.leafName);
return tmpf;
}
function dirIter(directory)
{
var ioSvc = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var testsDir = ioSvc.newURI(directory, null, null)
.QueryInterface(Ci.nsIFileURL).file;
let en = testsDir.directoryEntries;
while (en.hasMoreElements()) {
let file = en.getNext();
yield file.QueryInterface(Ci.nsIFile);
}
}
function getParent(path) {
let lastSlash = path.lastIndexOf("/");
if (lastSlash == -1) {
lastSlash = path.lastIndexOf("\\");
if (lastSlash == -1) {
return "";
}
return '/' + path.substring(0, lastSlash).replace(/\\/g, '/');
}
return path.substring(0, lastSlash);
}
function copyDirToTempProfile(path, subdirname) {
if (subdirname === undefined) {
subdirname = "mochikit-tmp";
}
let tmpdir = gDirSvc.get("ProfD", Ci.nsIFile);
tmpdir.append(subdirname);
tmpdir.createUnique(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
let rootDir = getParent(path);
if (rootDir == "") {
return tmpdir;
}
// The SimpleTest directory is hidden
var files = [file for (file in dirIter('file://' +rootDir))];
for (f in files) {
files[f].copyTo(tmpdir, "");
}
return tmpdir;
}
function convertChromeURI(chromeURI)
{
let uri = Cc["@mozilla.org/network/io-service;1"].
@ -51,6 +100,35 @@ function chromeURIToFile(chromeURI)
QueryInterface(Ci.nsIFileURL).file;
}
// Register a chrome manifest temporarily and return a function which un-does
// the registrarion when no longer needed.
function createManifestTemporarily(tempDir, manifestText)
{
gPrefs.setBoolPref(XUL_CACHE_PREF, true);
tempDir.append("temp.manifest");
let foStream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
foStream.init(tempDir,
0x02 | 0x08 | 0x20, 0664, 0); // write, create, truncate
foStream.write(manifestText, manifestText.length);
foStream.close();
let tempfile = copyToTemporaryFile(tempDir);
Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
autoRegister(tempfile);
gChromeReg.refreshSkins();
return function() {
tempfile.fileSize = 0; // truncate the manifest
gChromeReg.checkForNewChrome();
gChromeReg.refreshSkins();
gPrefs.clearUserPref(XUL_CACHE_PREF);
}
}
// Register a chrome manifest temporarily and return a function which un-does
// the registrarion when no longer needed.
function registerManifestTemporarily(manifestURI)
@ -58,6 +136,7 @@ function registerManifestTemporarily(manifestURI)
gPrefs.setBoolPref(XUL_CACHE_PREF, true);
let file = chromeURIToFile(manifestURI);
let tempfile = copyToTemporaryFile(file);
Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
autoRegister(tempfile);
@ -74,6 +153,9 @@ function registerManifestTemporarily(manifestURI)
function registerManifestPermanently(manifestURI)
{
var chromepath = chromeURIToFile(manifestURI);
Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
autoRegister(chromeURIToFile(manifestURI));
autoRegister(chromepath);
return chromepath;
}

View File

@ -44,7 +44,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=348233
/** Test for Bug 437844 and Bug 348233 **/
SimpleTest.waitForExplicitFinish();
let cleanupFunc = registerManifestTemporarily("chrome://mochikit/content/chrome/toolkit/content/tests/chrome/rtlchrome/rtl.manifest");
let rootDir = getRootDirectory(window.location.href);
let manifest = rootDir + "rtlchrome/rtl.manifest";
//copy rtlchrome to profile/rtlchrome and generate .manifest
let filePath = chromeURIToFile(manifest);
let tempProfileDir = copyDirToTempProfile(filePath.path, 'rtlchrome');
if (tempProfileDir.path.lastIndexOf('\\') >= 0) {
manifest = "content rtlchrome /" + tempProfileDir.path.replace(/\\/g, '/') + "\n";
} else {
manifest = "content rtlchrome " + tempProfileDir.path + "\n";
}
manifest += "override chrome://global/locale/intl.css chrome://rtlchrome/content/rtlchrome/rtl.css\n";
manifest += "override chrome://global/locale/global.dtd chrome://rtlchrome/content/rtlchrome/rtl.dtd\n";
let cleanupFunc = createManifestTemporarily(tempProfileDir, manifest);
// Load about:plugins in an iframe
let frame = document.createElement("iframe");

View File

@ -37,7 +37,8 @@
const UI_DIRECTION_PREF = "intl.uidirection.ar";
prefs.setCharPref(UI_DIRECTION_PREF, "rtl");
registerManifestPermanently("chrome://mochikit/content/chrome/toolkit/content/tests/chrome/rtltest/righttoleft.manifest");
let rootDir = getRootDirectory(window.location.href);
registerManifestPermanently(rootDir + "rtltest/righttoleft.manifest");
function runTest()
{

View File

@ -41,6 +41,7 @@ DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = toolkit/crashreporter/client
include $(DEPTH)/config/autoconf.mk

View File

@ -1,7 +1,9 @@
// load our utility script
var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
scriptLoader.loadSubScript("chrome://mochikit/content/browser/toolkit/crashreporter/test/browser/aboutcrashes_utils.js", this);
var rootDir = getRootDirectory(gTestPath);
scriptLoader.loadSubScript(rootDir + "/aboutcrashes_utils.js", this);
function check_crash_list(tab, crashes) {
let doc = gBrowser.getBrowserForTab(tab).contentDocument;

View File

@ -1,7 +1,9 @@
// load our utility script
var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
scriptLoader.loadSubScript("chrome://mochikit/content/browser/toolkit/crashreporter/test/browser/aboutcrashes_utils.js", this);
var rootDir = getRootDirectory(gTestPath);
scriptLoader.loadSubScript(rootDir + "/aboutcrashes_utils.js", this);
function cleanup_and_finish() {
try {

View File

@ -1,7 +1,9 @@
// load our utility script
var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
scriptLoader.loadSubScript("chrome://mochikit/content/browser/toolkit/crashreporter/test/browser/aboutcrashes_utils.js", this);
var rootDir = getRootDirectory(gTestPath);
scriptLoader.loadSubScript(rootDir + "/aboutcrashes_utils.js", this);
function check_clear_visible(tab, aVisible) {
let doc = gBrowser.getBrowserForTab(tab).contentDocument;

View File

@ -16,7 +16,7 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
src="utils.js"/>
<script type="application/javascript">
<![CDATA[

View File

@ -16,7 +16,7 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
src="utils.js"/>
<script type="application/javascript">
<![CDATA[

View File

@ -16,7 +16,7 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
src="utils.js"/>
<script type="application/javascript">
<![CDATA[

View File

@ -16,7 +16,7 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
src="utils.js"/>
<script type="application/javascript">
<![CDATA[

View File

@ -16,7 +16,7 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
src="utils.js"/>
<script type="application/javascript">
<![CDATA[

View File

@ -16,7 +16,7 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
src="utils.js"/>
<script type="application/javascript">
<![CDATA[

View File

@ -16,7 +16,7 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
src="utils.js"/>
<script type="application/javascript">
<![CDATA[

View File

@ -16,7 +16,7 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/chrome/toolkit/mozapps/update/test/chrome/utils.js"/>
src="utils.js"/>
<script type="application/javascript">
<![CDATA[

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=543854
-->

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<window title="Mozilla Bug 444801"
xmlns:html="http://www.w3.org/1999/xhtml"

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<window title="Mozilla Bug 444801"
xmlns:html="http://www.w3.org/1999/xhtml"

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=462106
-->