Bug 591325 Fix regression due to relativesrcdir landing in xpchsell test, continued cleanup in chrome tets r=ctalbert a=NPOTB
authorJoel Maher <jmaher@mozilla.com>
Fri, 10 Sep 2010 10:20:38 -0700
changeset 52394 47c6a53ffd8cbc5f9c610a39008e2d2893148339
parent 52393 f9fcf102493f6bc2a4c9dac8fc004ffdb92a4b63
child 52395 d8203cb80c95ff7947f8640c61dfecc93360ec85
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersctalbert, NPOTB
bugs591325
milestone2.0b6pre
Bug 591325 Fix regression due to relativesrcdir landing in xpchsell test, continued cleanup in chrome tets r=ctalbert a=NPOTB
accessible/tests/mochitest/hyperlink/test_general.html
accessible/tests/mochitest/hyperlink/test_general.xul
accessible/tests/mochitest/selectable/test_listbox.xul
accessible/tests/mochitest/selectable/test_menu.xul
accessible/tests/mochitest/selectable/test_menulist.xul
config/rules.mk
content/html/content/test/test_bug500885.html
js/src/config/rules.mk
layout/forms/test/bug536567_subframe.html
layout/forms/test/test_bug36619.html
services/sync/tests/Makefile.in
testing/mochitest/tests/SimpleTest/Makefile.in
toolkit/components/places/tests/chrome/test_329534.xul
toolkit/content/tests/browser/common/mockObjects.js
toolkit/content/tests/chrome/RegisterUnregisterChrome.js
toolkit/content/tests/chrome/test_bug437844.xul
toolkit/content/tests/chrome/test_righttoleft.xul
toolkit/crashreporter/client/Makefile.in
toolkit/crashreporter/test/browser/browser_aboutCrashes.js
toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js
toolkit/crashreporter/test/browser/browser_bug471404.js
toolkit/mozapps/update/test/chrome/test_0113_showNeverForVersionRemovedWithPref.xul
toolkit/mozapps/update/test/chrome/test_0121_check_requireBuiltinCert.xul
toolkit/mozapps/update/test/chrome/test_0122_check_allowNonBuiltinCert_validCertAttrs.xul
toolkit/mozapps/update/test/chrome/test_0123_check_allowNonBuiltinCert_noCertAttrsCheck.xul
toolkit/mozapps/update/test/chrome/test_0131_check_invalidCertAttrs_noUpdate.xul
toolkit/mozapps/update/test/chrome/test_0132_check_invalidCertAttrs_hasUpdate.xul
toolkit/mozapps/update/test/chrome/test_0141_notify_invalidCertAttrs_noUpdate.xul
toolkit/mozapps/update/test/chrome/test_0142_notify_invalidCertAttrs_hasUpdate.xul
toolkit/profile/test/test_create_profile.xul
toolkit/spatial-navigation/tests/chrome/test_snav_prefDisabled.xul
toolkit/spatial-navigation/tests/chrome/test_snav_prefKeyCode.xul
widget/tests/test_bug462106.xul
--- a/accessible/tests/mochitest/hyperlink/test_general.html
+++ b/accessible/tests/mochitest/hyperlink/test_general.html
@@ -8,21 +8,21 @@ https://bugzilla.mozilla.org/show_bug.cg
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
 
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           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,
                       aEndIndex)
     {
       testRole(aAcc, aRole);
       is(aAcc.anchorCount, aAnchors, "Wrong number of anchors for ID "
                                       + aID + "!");
--- a/accessible/tests/mochitest/hyperlink/test_general.xul
+++ b/accessible/tests/mochitest/hyperlink/test_general.xul
@@ -7,21 +7,21 @@
         title="test for nsIAccessibleHyperLink interface on XUL:label elements">
 
   <script type="application/javascript" 
           src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
           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[
     function testThis(aID, aAcc, aRole, aAnchorCount, aAnchorName, aURI,
                       aStartIndex, aEndIndex, aValid, aSelectedBefore,
                       aSelectedAfter)
     {
       testRole(aID, aRole);
--- a/accessible/tests/mochitest/selectable/test_listbox.xul
+++ b/accessible/tests/mochitest/selectable/test_listbox.xul
@@ -1,14 +1,13 @@
 <?xml version="1.0"?>
 <?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">
 
   <script type="application/javascript" 
           src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
--- a/accessible/tests/mochitest/selectable/test_menu.xul
+++ b/accessible/tests/mochitest/selectable/test_menu.xul
@@ -1,14 +1,13 @@
 <?xml version="1.0"?>
 <?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">
 
   <script type="application/javascript" 
           src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
--- a/accessible/tests/mochitest/selectable/test_menulist.xul
+++ b/accessible/tests/mochitest/selectable/test_menulist.xul
@@ -1,14 +1,13 @@
 <?xml version="1.0"?>
 <?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">
 
   <script type="application/javascript" 
           src="chrome://mochikit/content/MochiKit/packed.js" />
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -142,19 +142,19 @@ endif
 
 ################################################################################
 # Testing frameworks support
 ################################################################################
 
 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
 
 # Test file installation
 ifneq (,$(filter WINNT os2-emx,$(HOST_OS_ARCH)))
 # Windows and OS/2 nsinstall can't recursively copy directories, so use nsinstall.py
 TEST_INSTALLER = $(PYTHON) $(topsrcdir)/config/nsinstall.py
 else
--- a/content/html/content/test/test_bug500885.html
+++ b/content/html/content/test/test_bug500885.html
@@ -3,36 +3,28 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=500885
 -->
 <head>
   <title>Test for Bug 500885</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>
+  <script type="text/javascript" src="/tests/SimpleTest/mockObjects.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=500885">Mozilla Bug 500885</a>
 <div>
   <input id="file" type="file" />
 </div>
 <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() { };
 MockFilePicker.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIFilePicker]),
   init: function(aParent, aTitle, aMode) { },
   appendFilters: function(aFilterMask) { },
   appendFilter: function(aTitle, aFilter) { },
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -142,19 +142,19 @@ endif
 
 ################################################################################
 # Testing frameworks support
 ################################################################################
 
 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
 
 # Test file installation
 ifneq (,$(filter WINNT os2-emx,$(HOST_OS_ARCH)))
 # Windows and OS/2 nsinstall can't recursively copy directories, so use nsinstall.py
 TEST_INSTALLER = $(PYTHON) $(topsrcdir)/config/nsinstall.py
 else
--- a/layout/forms/test/bug536567_subframe.html
+++ b/layout/forms/test/bug536567_subframe.html
@@ -1,27 +1,19 @@
 <!DOCTYPE html>
 <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() { };
 MockFilePicker.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIFilePicker]),
   init: function(aParent, aTitle, aMode) { },
   appendFilters: function(aFilterMask) { },
   appendFilter: function(aTitle, aFilter) { },
--- a/layout/forms/test/test_bug36619.html
+++ b/layout/forms/test/test_bug36619.html
@@ -3,16 +3,17 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=36619
 -->
 <head>
   <title>Test for Bug 36619</title>
   <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>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=36619">Mozilla Bug 36619</a>
 <p id="display"></p>
 <div id="content" style="display:none;">
   <input id='a' type='file'>
 </div>
@@ -20,26 +21,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 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()
 {
 }
 
 MockFilePicker.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIFilePicker]),
--- a/services/sync/tests/Makefile.in
+++ b/services/sync/tests/Makefile.in
@@ -34,15 +34,16 @@
 # 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 = services/sync/tests
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = test_services_sync
 XPCSHELL_TESTS = unit
 
 include $(topsrcdir)/config/rules.mk
--- a/testing/mochitest/tests/SimpleTest/Makefile.in
+++ b/testing/mochitest/tests/SimpleTest/Makefile.in
@@ -49,13 +49,14 @@ include $(topsrcdir)/config/rules.mk
 			quit.js \
 			SimpleTest.js \
 			test.css \
 			TestRunner.js \
 			setup.js \
 			EventUtils.js \
 			WindowSnapshot.js \
 			PluginUtils.js \
+			$(DEPTH)/toolkit/content/tests/browser/common/mockObjects.js \
 			$(NULL)
 
 libs:: $(_SIMPLETEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/$(relativesrcdir)
 
--- a/toolkit/components/places/tests/chrome/test_329534.xul
+++ b/toolkit/components/places/tests/chrome/test_329534.xul
@@ -1,12 +1,12 @@
 <?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">
   <script type="application/javascript"
    src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
    src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
--- a/toolkit/content/tests/browser/common/mockObjects.js
+++ b/toolkit/content/tests/browser/common/mockObjects.js
@@ -45,31 +45,55 @@
  *
  * @param aReplacementCtor
  *        The constructor function for the JavaScript object that will be
  *        created every time createInstance is called. This object must
  *        implement QueryInterface and provide the XPCOM interfaces required by
  *        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;
   this._replacementCtor = aReplacementCtor;
 }
 
 MockObjectRegisterer.prototype = {
   /**
    * Replaces the current factory with one that returns a new mock object.
    *
    * After register() has been called, it is mandatory to call unregister() to
    * restore the original component. Usually, you should use a try-catch block
    * 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()");
 
     // Define a factory that creates a new object using the given constructor.
     var providedConstructor = this._replacementCtor;
     this._mockFactory = {
       createInstance: function MF_createInstance(aOuter, aIid) {
         if (aOuter != null)
@@ -91,16 +115,17 @@ MockObjectRegisterer.prototype = {
                                        this._contractID,
                                        this._mockFactory);
   },
 
   /**
    * 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()");
 
     // Free references to the mock factory.
     var componentRegistrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
     componentRegistrar.unregisterFactory(this._cid,
                                          this._mockFactory);
 
--- a/toolkit/content/tests/chrome/RegisterUnregisterChrome.js
+++ b/toolkit/content/tests/chrome/RegisterUnregisterChrome.js
@@ -18,21 +18,70 @@ let gPrefs     = Cc["@mozilla.org/prefer
 // we know the mochitest harness kills off the profile when it's done.
 function copyToTemporaryFile(f)
 {
   let tmpd = gDirSvc.get("ProfD", Ci.nsIFile);
   tmpf = tmpd.clone();
   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"].
     getService(Ci.nsIIOService).newURI(chromeURI, null, null);
   return gChromeReg.convertChromeURL(uri);
 }
 
 function chromeURIToFile(chromeURI)
@@ -48,32 +97,65 @@ function chromeURIToFile(chromeURI)
   }
 
   return convertChromeURI(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)
 {
   gPrefs.setBoolPref(XUL_CACHE_PREF, true);
 
   let file = chromeURIToFile(manifestURI);
+
   let tempfile = copyToTemporaryFile(file);
   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);
   }
 }
 
 function registerManifestPermanently(manifestURI)
 {
+  var chromepath = chromeURIToFile(manifestURI);
+  
   Components.manager.QueryInterface(Ci.nsIComponentRegistrar).
-    autoRegister(chromeURIToFile(manifestURI));
+    autoRegister(chromepath);
+  return chromepath;
 }
--- a/toolkit/content/tests/chrome/test_bug437844.xul
+++ b/toolkit/content/tests/chrome/test_bug437844.xul
@@ -39,17 +39,31 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
 
   <script class="testbody" type="application/javascript">
     <![CDATA[
 
       /** 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");
       frame.setAttribute("src", "about:plugins");
       frame.addEventListener("load", function () {
           frame.removeEventListener("load", arguments.callee, false);
           is(frame.contentDocument.dir, "rtl", "about:plugins should be RTL in RTL locales");
 
--- a/toolkit/content/tests/chrome/test_righttoleft.xul
+++ b/toolkit/content/tests/chrome/test_righttoleft.xul
@@ -32,17 +32,18 @@
 
       SimpleTest.waitForExplicitFinish();
 
       let prefs = Cc["@mozilla.org/preferences-service;1"].
                   getService(Ci.nsIPrefBranch);
       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()
       {
         var subframe = document.getElementById("subframe");
         subframe.setAttribute("src", "chrome://ltrtest/content/dirtest.xul");
       }
 
       function frameLoaded()
--- a/toolkit/crashreporter/client/Makefile.in
+++ b/toolkit/crashreporter/client/Makefile.in
@@ -36,16 +36,17 @@
 #
 # ***** END LICENSE BLOCK *****
 
 
 DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
+relativesrcdir = toolkit/crashreporter/client
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = crashreporter
 
 # Don't use the STL wrappers in the crashreporter clients; they don't
 # link with -lmozalloc, and it really doesn't matter here anyway.
 STL_FLAGS =
--- a/toolkit/crashreporter/test/browser/browser_aboutCrashes.js
+++ b/toolkit/crashreporter/test/browser/browser_aboutCrashes.js
@@ -1,12 +1,14 @@
 // 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;
   let crashlinks = doc.getElementById("tbody").getElementsByTagName("a");
   is(crashlinks.length, crashes.length, "about:crashes lists correct number of crash reports");
   for(let i = 0; i < crashes.length; i++) {
     is(crashlinks[i].firstChild.textContent, crashes[i].id, i + ": crash ID is correct");
   }
--- a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js
+++ b/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js
@@ -1,12 +1,14 @@
 // 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 {
     cleanup_fake_appdir();
   } catch(ex) {}
   Services.prefs.clearUserPref("breakpad.reportURL");
   gBrowser.removeTab(gBrowser.selectedTab);
   finish();
--- a/toolkit/crashreporter/test/browser/browser_bug471404.js
+++ b/toolkit/crashreporter/test/browser/browser_bug471404.js
@@ -1,12 +1,14 @@
 // 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;
   let visible = false;
   let button = doc.getElementById("clear-reports");
   if (button) {
     let style = doc.defaultView.getComputedStyle(button, "");
     if (style.display != "none" &&
--- a/toolkit/mozapps/update/test/chrome/test_0113_showNeverForVersionRemovedWithPref.xul
+++ b/toolkit/mozapps/update/test/chrome/test_0113_showNeverForVersionRemovedWithPref.xul
@@ -11,17 +11,17 @@
 <window title="Update Wizard pages: update available with never pref and without showNeverForVersion"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="runTestDefault();">
 <script type="application/javascript" 
         src="chrome://mochikit/content/MochiKit/packed.js"/>
 <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[
 
 gPrefToCheck = PREF_APP_UPDATE_NEVER_BRANCH + Services.appinfo.version;
 
 const TESTS = [ {
   pageid: PAGEID_FOUND_BASIC,
--- a/toolkit/mozapps/update/test/chrome/test_0121_check_requireBuiltinCert.xul
+++ b/toolkit/mozapps/update/test/chrome/test_0121_check_requireBuiltinCert.xul
@@ -11,17 +11,17 @@
 <window title="Test update check with certificate that is not built-in and valid certificate attribute names and values"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="runTestDefault();">
 <script type="application/javascript" 
         src="chrome://mochikit/content/MochiKit/packed.js"/>
 <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[
 
 const TESTS = [ {
   pageid: PAGEID_CHECKING
 }, {
   pageid: PAGEID_ERRORS,
--- a/toolkit/mozapps/update/test/chrome/test_0122_check_allowNonBuiltinCert_validCertAttrs.xul
+++ b/toolkit/mozapps/update/test/chrome/test_0122_check_allowNonBuiltinCert_validCertAttrs.xul
@@ -11,17 +11,17 @@
 <window title="Test update check without requiring a certificate that is built-in and valid certificate attribute names and values"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="runTestDefault();">
 <script type="application/javascript" 
         src="chrome://mochikit/content/MochiKit/packed.js"/>
 <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[
 
 const TESTS = [ {
   pageid: PAGEID_CHECKING
 }, {
   pageid: PAGEID_FOUND_BASIC,
--- a/toolkit/mozapps/update/test/chrome/test_0123_check_allowNonBuiltinCert_noCertAttrsCheck.xul
+++ b/toolkit/mozapps/update/test/chrome/test_0123_check_allowNonBuiltinCert_noCertAttrsCheck.xul
@@ -11,17 +11,17 @@
 <window title="Test update check without requiring a certificate that is built-in and without the certificate attribute check"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="runTestDefault();">
 <script type="application/javascript" 
         src="chrome://mochikit/content/MochiKit/packed.js"/>
 <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[
 
 const TESTS = [ {
   pageid: PAGEID_CHECKING
 }, {
   pageid: PAGEID_FOUND_BASIC,
--- a/toolkit/mozapps/update/test/chrome/test_0131_check_invalidCertAttrs_noUpdate.xul
+++ b/toolkit/mozapps/update/test/chrome/test_0131_check_invalidCertAttrs_noUpdate.xul
@@ -11,17 +11,17 @@
 <window title="Test update check with invalid certificate attribute name with no update"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="runTestDefault();">
 <script type="application/javascript" 
         src="chrome://mochikit/content/MochiKit/packed.js"/>
 <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[
 
 const TESTS = [ {
   pageid: PAGEID_CHECKING
 }, {
   pageid: PAGEID_ERROR_CERT_CHECK,
--- a/toolkit/mozapps/update/test/chrome/test_0132_check_invalidCertAttrs_hasUpdate.xul
+++ b/toolkit/mozapps/update/test/chrome/test_0132_check_invalidCertAttrs_hasUpdate.xul
@@ -11,17 +11,17 @@
 <window title="Test update check with invalid certificate attribute name with an update"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="runTestDefault();">
 <script type="application/javascript" 
         src="chrome://mochikit/content/MochiKit/packed.js"/>
 <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[
 
 const TESTS = [ {
   pageid: PAGEID_CHECKING
 }, {
   pageid: PAGEID_ERROR_CERT_CHECK,
--- a/toolkit/mozapps/update/test/chrome/test_0141_notify_invalidCertAttrs_noUpdate.xul
+++ b/toolkit/mozapps/update/test/chrome/test_0141_notify_invalidCertAttrs_noUpdate.xul
@@ -11,17 +11,17 @@
 <window title="Test notification with invalid certificate attribute name with no update"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="runTestDefault();">
 <script type="application/javascript" 
         src="chrome://mochikit/content/MochiKit/packed.js"/>
 <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[
 
 const TESTS = [ {
   pageid: PAGEID_ERROR_CERT_CHECK,
   extraDelayedCheckFunction: checkCertErrorPage,
   shouldBeHidden: false,
--- a/toolkit/mozapps/update/test/chrome/test_0142_notify_invalidCertAttrs_hasUpdate.xul
+++ b/toolkit/mozapps/update/test/chrome/test_0142_notify_invalidCertAttrs_hasUpdate.xul
@@ -11,17 +11,17 @@
 <window title="Test notification with invalid certificate attribute name with no update"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="runTestDefault();">
 <script type="application/javascript" 
         src="chrome://mochikit/content/MochiKit/packed.js"/>
 <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[
 
 const TESTS = [ {
   pageid: PAGEID_ERROR_CERT_CHECK,
   extraDelayedCheckFunction: checkCertErrorPage,
   shouldBeHidden: true,
--- a/toolkit/profile/test/test_create_profile.xul
+++ b/toolkit/profile/test/test_create_profile.xul
@@ -1,11 +1,11 @@
 <?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
 -->
 <window title="Mozilla Bug 543854"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <script type="application/javascript"
    src="chrome://mochikit/content/MochiKit/packed.js"></script>
   <script type="application/javascript"
--- a/toolkit/spatial-navigation/tests/chrome/test_snav_prefDisabled.xul
+++ b/toolkit/spatial-navigation/tests/chrome/test_snav_prefDisabled.xul
@@ -1,11 +1,11 @@
 <?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"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
     <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
     <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
     <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
--- a/toolkit/spatial-navigation/tests/chrome/test_snav_prefKeyCode.xul
+++ b/toolkit/spatial-navigation/tests/chrome/test_snav_prefKeyCode.xul
@@ -1,11 +1,11 @@
 <?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"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
     <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
     <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
     <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
--- a/widget/tests/test_bug462106.xul
+++ b/widget/tests/test_bug462106.xul
@@ -1,11 +1,11 @@
 <?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
 -->
 <window title="Mozilla Bug 462106"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         onload="initAndRunTests()">
   <script type="application/javascript"
           src="chrome://mochikit/content/MochiKit/packed.js"/>