diff --git a/js/xpconnect/src/XPCWrappedJS.cpp b/js/xpconnect/src/XPCWrappedJS.cpp index 866e0a9920ac..637cfb6fe4d4 100644 --- a/js/xpconnect/src/XPCWrappedJS.cpp +++ b/js/xpconnect/src/XPCWrappedJS.cpp @@ -11,7 +11,6 @@ #include "nsProxyRelease.h" #include "nsThreadUtils.h" #include "nsTextFormatter.h" -#include "nsCycleCollectorUtils.h" // NOTE: much of the fancy footwork is done in xpcstubs.cpp @@ -151,8 +150,6 @@ nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr) nsrefcnt nsXPCWrappedJS::AddRef(void) { - if (!MOZ_LIKELY(NS_IsMainThread() || NS_IsCycleCollectorThread())) - MOZ_CRASH(); nsrefcnt cnt = NS_AtomicIncrementRefcnt(mRefCnt); NS_LOG_ADDREF(this, cnt, "nsXPCWrappedJS", sizeof(*this)); @@ -167,8 +164,6 @@ nsXPCWrappedJS::AddRef(void) nsrefcnt nsXPCWrappedJS::Release(void) { - if (!MOZ_LIKELY(NS_IsMainThread() || NS_IsCycleCollectorThread())) - MOZ_CRASH(); NS_PRECONDITION(0 != mRefCnt, "dup release"); if (mMainThreadOnly && !NS_IsMainThread()) { @@ -282,10 +277,6 @@ nsXPCWrappedJS::GetNewOrUsed(JSContext* cx, nsISupports* aOuter, nsXPCWrappedJS** wrapperResult) { - // Do a release-mode assert against accessing nsXPCWrappedJS off-main-thread. - if (!MOZ_LIKELY(NS_IsMainThread() || NS_IsCycleCollectorThread())) - MOZ_CRASH(); - JS::RootedObject jsObj(cx, aJSObj); JSObject2WrappedJSMap* map; nsXPCWrappedJS* root = nullptr; @@ -568,10 +559,6 @@ nsXPCWrappedJS::CallMethod(uint16_t methodIndex, const XPTMethodDescriptor* info, nsXPTCMiniVariant* params) { - // Do a release-mode assert against accessing nsXPCWrappedJS off-main-thread. - if (!MOZ_LIKELY(NS_IsMainThread() || NS_IsCycleCollectorThread())) - MOZ_CRASH(); - if (!IsValid()) return NS_ERROR_UNEXPECTED; if (NS_IsMainThread() != mMainThread) { diff --git a/js/xpconnect/tests/unit/test_bug608142.js b/js/xpconnect/tests/unit/test_bug608142.js new file mode 100644 index 000000000000..6eb938760fd3 --- /dev/null +++ b/js/xpconnect/tests/unit/test_bug608142.js @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: sw=4 ts=4 sts=4 et + * 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/. */ + +function run_test() { + var tm = Components.classes["@mozilla.org/thread-manager;1"].getService(); + var thr = tm.newThread(0); + + var foundThreadError = false; + + var listener = { + observe: function(message) { + if (/JS function on a different thread/.test(message.message)) + foundThreadError = true; + } + }; + + var cs = Components.classes["@mozilla.org/consoleservice;1"]. + getService(Components.interfaces.nsIConsoleService); + cs.registerListener(listener); + + thr.dispatch({ + run: function() { + do_check_true(false); + } + }, Components.interfaces.nsIThread.DISPATCH_NORMAL); + + thr.shutdown(); + + cs.unregisterListener(listener); + do_check_true(foundThreadError); +} + diff --git a/js/xpconnect/tests/unit/xpcshell.ini b/js/xpconnect/tests/unit/xpcshell.ini index 1889a5b55046..3db8ba3d330b 100644 --- a/js/xpconnect/tests/unit/xpcshell.ini +++ b/js/xpconnect/tests/unit/xpcshell.ini @@ -7,6 +7,7 @@ tail = [test_bug451678.js] [test_bug596580.js] [test_bug604362.js] +[test_bug608142.js] [test_bug641378.js] [test_bug677864.js] [test_bug711404.js]