Backed out changeset c78f97c0b771 (bug 1314955)
authorIris Hsiao <ihsiao@mozilla.com>
Wed, 16 Nov 2016 15:19:46 +0800
changeset 439854 8e8aa918d2f59b7ccd58e3f568dab2cea55148d1
parent 439853 ee36b7c4f4be4426178b712ef5f0a69df65da5cf
child 439855 4ab3e15efcfeecd9a9a53bc6669546d4ea2c7f4b
push id36113
push userbmo:afarre@mozilla.com
push dateWed, 16 Nov 2016 18:15:04 +0000
bugs1314955
milestone53.0a1
backs outc78f97c0b77126fa37c857728192f2e2d0c2d99c
Backed out changeset c78f97c0b771 (bug 1314955)
js/xpconnect/src/XPCShellImpl.cpp
js/xpconnect/tests/components/native/moz.build
js/xpconnect/tests/components/native/xpctest_module.cpp
js/xpconnect/tests/components/native/xpctest_private.h
js/xpconnect/tests/unit/test_attributes.js
js/xpconnect/tests/unit/test_params.js
js/xpconnect/tests/unit/test_returncode.js
--- a/js/xpconnect/src/XPCShellImpl.cpp
+++ b/js/xpconnect/src/XPCShellImpl.cpp
@@ -23,17 +23,16 @@
 #include "nscore.h"
 #include "nsArrayEnumerator.h"
 #include "nsCOMArray.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsCOMPtr.h"
 #include "nsJSPrincipals.h"
 #include "xpcpublic.h"
 #include "xpcprivate.h"
-#include "xpctest_private.h"
 #include "BackstagePass.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIPrincipal.h"
 #include "nsJSUtils.h"
 #include "gfxPrefs.h"
 #include "nsIXULRuntime.h"
 
 #include "base/histogram.h"
@@ -639,32 +638,16 @@ RegisterAppManifest(JSContext* cx, unsig
     rv = XRE_AddManifestLocation(NS_APP_LOCATION, file);
     if (NS_FAILED(rv)) {
         XPCThrower::Throw(rv, cx);
         return false;
     }
     return true;
 }
 
-static bool
-RegisterXPCTestComponents(JSContext* cx, unsigned argc, Value* vp)
-{
-    JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
-    if (args.length() != 0) {
-        JS_ReportErrorASCII(cx, "Wrong number of arguments");
-        return false;
-    }
-    nsresult rv = XRE_AddStaticComponent(&kXPCTestModule);
-    if (NS_FAILED(rv)) {
-        XPCThrower::Throw(rv, cx);
-        return false;
-    }
-    return true;
-}
-
 static const JSFunctionSpec glob_functions[] = {
     JS_FS("print",           Print,          0,0),
     JS_FS("readline",        ReadLine,       1,0),
     JS_FS("load",            Load,           1,0),
     JS_FS("quit",            Quit,           0,0),
     JS_FS("version",         Version,        1,0),
     JS_FS("dumpXPC",         DumpXPC,        1,0),
     JS_FS("dump",            Dump,           1,0),
@@ -674,17 +657,16 @@ static const JSFunctionSpec glob_functio
 #endif
     JS_FS("options",         Options,        0,0),
     JS_FS("sendCommand",     SendCommand,    1,0),
     JS_FS("atob",            xpc::Atob,      1,0),
     JS_FS("btoa",            xpc::Btoa,      1,0),
     JS_FS("setInterruptCallback", SetInterruptCallback, 1,0),
     JS_FS("simulateActivityCallback", SimulateActivityCallback, 1,0),
     JS_FS("registerAppManifest", RegisterAppManifest, 1, 0),
-    JS_FS("registerXPCTestComponents", RegisterXPCTestComponents, 0, 0),
     JS_FS_END
 };
 
 static bool
 env_setProperty(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue vp,
                 ObjectOpResult& result)
 {
 /* XXX porting may be easy, but these don't seem to supply setenv by default */
--- a/js/xpconnect/tests/components/native/moz.build
+++ b/js/xpconnect/tests/components/native/moz.build
@@ -1,22 +1,19 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-EXPORTS += [
-    'xpctest_private.h',
-]
-
+FINAL_TARGET = '_tests/xpcshell/js/xpconnect/tests/components/native/'
 EXTRA_COMPONENTS += [
     'xpctest.manifest',
 ]
 
 UNIFIED_SOURCES += [
     'xpctest_attributes.cpp',
     'xpctest_module.cpp',
     'xpctest_params.cpp',
     'xpctest_returncode.cpp',
 ]
 
-FINAL_LIBRARY = 'xul'
+XPCOMBinaryComponent('xpctest')
--- a/js/xpconnect/tests/components/native/xpctest_module.cpp
+++ b/js/xpconnect/tests/components/native/xpctest_module.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* module registration and factory code. */
 
+#include "mozilla/ModuleUtils.h"
 #include "xpctest_private.h"
 
 #define NS_XPCTESTOBJECTREADONLY_CID                                          \
 { 0x492609a7, 0x2582, 0x436b,                                                 \
    { 0xb0, 0xef, 0x92, 0xe2, 0x9b, 0xb9, 0xe1, 0x43 } }
 
 #define NS_XPCTESTOBJECTREADWRITE_CID                                         \
 { 0x8f37f760, 0x3686, 0x4dbb,                                                 \
@@ -44,13 +45,15 @@ static const mozilla::Module::CIDEntry k
 static const mozilla::Module::ContractIDEntry kXPCTestContracts[] = {
     { "@mozilla.org/js/xpc/test/native/ObjectReadOnly;1", &kNS_XPCTESTOBJECTREADONLY_CID },
     { "@mozilla.org/js/xpc/test/native/ObjectReadWrite;1", &kNS_XPCTESTOBJECTREADWRITE_CID },
     { "@mozilla.org/js/xpc/test/native/Params;1", &kNS_XPCTESTPARAMS_CID },
     { "@mozilla.org/js/xpc/test/native/ReturnCodeParent;1", &kNS_XPCTESTRETURNCODEPARENT_CID },
     { nullptr }
 };
 
-const mozilla::Module kXPCTestModule = {
+static const mozilla::Module kXPCTestModule = {
     mozilla::Module::kVersion,
     kXPCTestCIDs,
     kXPCTestContracts
 };
+
+NSMODULE_DEFN(xpconnect_test) = &kXPCTestModule;
--- a/js/xpconnect/tests/components/native/xpctest_private.h
+++ b/js/xpconnect/tests/components/native/xpctest_private.h
@@ -11,19 +11,16 @@
 
 #include "nsISupports.h"
 #include "nsMemory.h"
 #include "nsStringGlue.h"
 #include "xpctest_attributes.h"
 #include "xpctest_params.h"
 #include "xpctest_returncode.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/ModuleUtils.h"
-
-extern const mozilla::Module kXPCTestModule;
 
 class xpcTestObjectReadOnly final : public nsIXPCTestObjectReadOnly {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIXPCTESTOBJECTREADONLY
   xpcTestObjectReadOnly();
 
  private:
--- a/js/xpconnect/tests/unit/test_attributes.js
+++ b/js/xpconnect/tests/unit/test_attributes.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 function run_test() {
 
   // Load the component manifests.
-  registerXPCTestComponents();
+  registerAppManifest(do_get_file('../components/native/chrome.manifest'));
   registerAppManifest(do_get_file('../components/js/xpctest.manifest'));
 
   // Test for each component.
   test_component_readwrite("@mozilla.org/js/xpc/test/native/ObjectReadWrite;1");
   test_component_readwrite("@mozilla.org/js/xpc/test/js/ObjectReadWrite;1");
   test_component_readonly("@mozilla.org/js/xpc/test/native/ObjectReadOnly;1");
   test_component_readonly("@mozilla.org/js/xpc/test/js/ObjectReadOnly;1");
 }
--- a/js/xpconnect/tests/unit/test_params.js
+++ b/js/xpconnect/tests/unit/test_params.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 function run_test() {
 
   // Load the component manifests.
-  registerXPCTestComponents();
+  registerAppManifest(do_get_file('../components/native/chrome.manifest'));
   registerAppManifest(do_get_file('../components/js/xpctest.manifest'));
 
   // Test for each component.
   test_component("@mozilla.org/js/xpc/test/native/Params;1");
   test_component("@mozilla.org/js/xpc/test/js/Params;1");
 }
 
 function test_component(contractid) {
--- a/js/xpconnect/tests/unit/test_returncode.js
+++ b/js/xpconnect/tests/unit/test_returncode.js
@@ -11,17 +11,17 @@ function getConsoleMessages() {
   let messages = consoleService.getMessageArray().map((m) => m.toString());
   // reset ready for the next call.
   consoleService.reset();
   return messages;
 }
 
 function run_test() {
   // Load the component manifests.
-  registerXPCTestComponents();
+  registerAppManifest(do_get_file('../components/native/chrome.manifest'));
   registerAppManifest(do_get_file('../components/js/xpctest.manifest'));
 
   // and the tests.
   test_simple();
   test_nested();
 }
 
 function test_simple() {