Back out changeset 453772872eeb (bug 668710) for bustage
authorGeoff Lankow <geoff@darktrojan.net>
Sun, 20 Nov 2011 01:10:40 +1300
changeset 80476 0c6b1cfb02cd0247dc6f9f401038b45071f44f3e
parent 80475 16073086d49b50d799f3ee1cb78023f2e4d1cedd
child 80477 8a529677e99899b81f91c02e389bea319641557b
push idunknown
push userunknown
push dateunknown
bugs668710
milestone11.0a1
backs out453772872eebf6091253702f8ac344dcaf0dd17b
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
Back out changeset 453772872eeb (bug 668710) for bustage
dom/tests/mochitest/bugs/test_bug61098.html
testing/mochitest/jar.mn
testing/mochitest/tests/SimpleTest/Makefile.in
testing/mochitest/tests/SimpleTest/MockObjects.js
toolkit/content/tests/browser/common/Makefile.in
toolkit/content/tests/browser/common/mockObjects.js
toolkit/content/tests/browser/common/mockTransfer.js
--- a/dom/tests/mochitest/bugs/test_bug61098.html
+++ b/dom/tests/mochitest/bugs/test_bug61098.html
@@ -3,17 +3,17 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=61098
 -->
 <head>
   <title>Test for Bug 61098</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="/mozprefs.js"></script>
   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/MockObjects.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 onload="runtests();">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=61098">Mozilla Bug 61098</a>
 <p id="display">
 </p>
 <div id="content" style="display: none"> 
 </div>
--- a/testing/mochitest/jar.mn
+++ b/testing/mochitest/jar.mn
@@ -18,13 +18,13 @@ mochikit.jar:
   content/tests/SimpleTest/ChromeUtils.js (tests/SimpleTest/ChromeUtils.js)
   content/tests/SimpleTest/MozillaLogger.js (tests/SimpleTest/MozillaLogger.js)
   content/tests/SimpleTest/LogController.js (tests/SimpleTest/LogController.js)
   content/tests/SimpleTest/setup.js (tests/SimpleTest/setup.js)
   content/tests/SimpleTest/SimpleTest.js (tests/SimpleTest/SimpleTest.js)
   content/tests/SimpleTest/test.css (tests/SimpleTest/test.css)
   content/tests/SimpleTest/TestRunner.js (tests/SimpleTest/TestRunner.js)
   content/tests/SimpleTest/WindowSnapshot.js (tests/SimpleTest/WindowSnapshot.js)
-  content/tests/SimpleTest/MockObjects.js (tests/SimpleTest/MockObjects.js)
-  content/tests/SimpleTest/docshell_helpers.js (../../docshell/test/chrome/docshell_helpers.js)
+  content/tests/SimpleTest/mockObjects.js (../../toolkit/content/tests/browser/common/mockObjects.js)
+  content/tests/SimpleTest/docshell_helpers.js (../..//docshell/test/chrome/docshell_helpers.js)
 
 % resource mochikit %modules/
   modules/MockFilePicker.jsm (MockFilePicker.jsm)
--- a/testing/mochitest/tests/SimpleTest/Makefile.in
+++ b/testing/mochitest/tests/SimpleTest/Makefile.in
@@ -48,15 +48,15 @@ include $(topsrcdir)/config/rules.mk
 			test.css \
 			TestRunner.js \
 			setup.js \
 			EventUtils.js \
 			ChromeUtils.js \
 			WindowSnapshot.js \
 			specialpowersAPI.js \
 			SpecialPowersObserverAPI.js \
-			MockObjects.js \
-			$(DEPTH)/docshell/test/chrome/docshell_helpers.js \
+			$(DEPTH)/toolkit/content/tests/browser/common/mockObjects.js \
+                        $(DEPTH)/docshell/test/chrome/docshell_helpers.js \
 			$(NULL)
 
 libs:: $(_SIMPLETEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/$(relativesrcdir)
 
deleted file mode 100644
--- a/testing/mochitest/tests/SimpleTest/MockObjects.js
+++ /dev/null
@@ -1,122 +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 XUL Toolkit Testing Code.
- *
- * The Initial Developer of the Original Code is
- * Paolo Amadini <http://www.amadzone.org/>.
- * Portions created by the Initial Developer are Copyright (C) 2009
- * 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 ***** */
-
-/**
- * Allows registering a mock XPCOM component, that temporarily replaces the
- *  original one when an object implementing a given ContractID is requested
- *  using createInstance.
- *
- * @param aContractID
- *        The ContractID of the component to replace, for example
- *        "@mozilla.org/filepicker;1".
- *
- * @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).
- */
-
-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() {
-    if (this._originalFactory)
-      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)
-          throw Components.results.NS_ERROR_NO_AGGREGATION;
-        return new providedConstructor().QueryInterface(aIid);
-      }
-    };
-
-    var retVal = SpecialPowers.swapFactoryRegistration(this._cid, this._contractID, this._mockFactory, this._originalFactory);
-    if ('error' in retVal) {
-      throw new Exception("ERROR: " + retVal.error);
-    } else {
-      this._cid = retVal.cid;
-      this._originalFactory = retVal.originalFactory;
-    }
-  },
-
-  /**
-   * Restores the original factory.
-   */
-  unregister: function MOR_unregister() {
-    if (!this._originalFactory)
-      throw new Exception("Invalid object state when calling unregister()");
-
-    // Free references to the mock factory.
-    SpecialPowers.swapFactoryRegistration(this._cid, this._contractID, this._mockFactory, this._originalFactory);
-
-    // Allow registering a mock factory again later.
-    this._cid = null;
-    this._originalFactory = null;
-    this._mockFactory = null;
-  },
-
-  // --- Private methods and properties ---
-
-  /**
-   * The factory of the component being replaced.
-   */
-  _originalFactory: null,
-
-  /**
-   * The CID under which the mock contractID was registered.
-   */
-  _cid: null,
-
-  /**
-   * The nsIFactory that was automatically generated by this object.
-   */
-  _mockFactory: null
-}
--- a/toolkit/content/tests/browser/common/Makefile.in
+++ b/toolkit/content/tests/browser/common/Makefile.in
@@ -40,13 +40,14 @@ topsrcdir      = @top_srcdir@
 srcdir         = @srcdir@
 VPATH          = @srcdir@
 relativesrcdir = toolkit/content/tests/browser/common
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _COMMON_FILES = \
+  mockObjects.js \
   mockTransfer.js \
   $(NULL)
 
 libs:: $(_COMMON_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/browser/common/mockObjects.js
@@ -0,0 +1,122 @@
+/* ***** 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 XUL Toolkit Testing Code.
+ *
+ * The Initial Developer of the Original Code is
+ * Paolo Amadini <http://www.amadzone.org/>.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * 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 ***** */
+
+/**
+ * Allows registering a mock XPCOM component, that temporarily replaces the
+ *  original one when an object implementing a given ContractID is requested
+ *  using createInstance.
+ *
+ * @param aContractID
+ *        The ContractID of the component to replace, for example
+ *        "@mozilla.org/filepicker;1".
+ *
+ * @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).
+ */
+
+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() {
+    if (this._originalFactory)
+      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)
+          throw Components.results.NS_ERROR_NO_AGGREGATION;
+        return new providedConstructor().QueryInterface(aIid);
+      }
+    };
+
+    var retVal = SpecialPowers.swapFactoryRegistration(this._cid, this._contractID, this._mockFactory, this._originalFactory);
+    if ('error' in retVal) {
+      throw new Exception("ERROR: " + retVal.error);
+    } else {
+      this._cid = retVal.cid;
+      this._originalFactory = retVal.originalFactory;
+    }
+  },
+
+  /**
+   * Restores the original factory.
+   */
+  unregister: function MOR_unregister() {
+    if (!this._originalFactory)
+      throw new Exception("Invalid object state when calling unregister()");
+
+    // Free references to the mock factory.
+    SpecialPowers.swapFactoryRegistration(this._cid, this._contractID, this._mockFactory, this._originalFactory);
+
+    // Allow registering a mock factory again later.
+    this._cid = null;
+    this._originalFactory = null;
+    this._mockFactory = null;
+  },
+
+  // --- Private methods and properties ---
+
+  /**
+   * The factory of the component being replaced.
+   */
+  _originalFactory: null,
+
+  /**
+   * The CID under which the mock contractID was registered.
+   */
+  _cid: null,
+
+  /**
+   * The nsIFactory that was automatically generated by this object.
+   */
+  _mockFactory: null
+}
--- a/toolkit/content/tests/browser/common/mockTransfer.js
+++ b/toolkit/content/tests/browser/common/mockTransfer.js
@@ -31,17 +31,18 @@
  * 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 ***** */
 
 Cc["@mozilla.org/moz/jssubscript-loader;1"]
   .getService(Ci.mozIJSSubScriptLoader)
-  .loadSubScript("chrome://mochikit/content/tests/SimpleTest/MockObjects.js", this);
+  .loadSubScript("chrome://mochitests/content/browser/toolkit/content/tests/browser/common/mockObjects.js",
+                 this);
 
 var mockTransferCallback;
 
 /**
  * This "transfer" object implementation continues the currently running test
  * when the download is completed, reporting true for success or false for
  * failure as the first argument of the testRunner.continueTest function.
  */