Backed out changeset d4ae1994c20c (bug 1489147) for bustages in JSDebugger.cpp on a CLOSED TREE

This commit is contained in:
shindli 2018-09-06 22:12:44 +03:00
Родитель bb7fcd9d69
Коммит 2a86142e74
20 изменённых файлов: 93 добавлений и 70 удалений

Просмотреть файл

@ -115,7 +115,7 @@ nsStructuredCloneContainer::DeserializeToVariant(JSContext* aCx,
// Now wrap the JS::Value as an nsIVariant.
nsCOMPtr<nsIVariant> varStateObj;
nsCOMPtr<nsIXPConnect> xpconnect = nsIXPConnect::XPConnect();
nsCOMPtr<nsIXPConnect> xpconnect = do_GetService(nsIXPConnect::GetCID());
NS_ENSURE_STATE(xpconnect);
xpconnect->JSValToVariant(aCx, jsStateObj, getter_AddRefs(varStateObj));
NS_ENSURE_STATE(varStateObj);

Просмотреть файл

@ -734,7 +734,7 @@ _getpluginelement(NPP npp)
}
JSContext* cx = jsapi.cx();
nsCOMPtr<nsIXPConnect> xpc(nsIXPConnect::XPConnect());
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID()));
NS_ENSURE_TRUE(xpc, nullptr);
JS::RootedValue val(cx);

Просмотреть файл

@ -36,6 +36,8 @@ static bool sandboxEnabled;
nsresult CentralizedAdminPrefManagerInit(bool aSandboxEnabled)
{
nsresult rv;
// If the sandbox is already created, no need to create it again.
if (autoconfigSb.initialized())
return NS_OK;
@ -43,7 +45,10 @@ nsresult CentralizedAdminPrefManagerInit(bool aSandboxEnabled)
sandboxEnabled = aSandboxEnabled;
// Grab XPConnect.
nsCOMPtr<nsIXPConnect> xpc = nsIXPConnect::XPConnect();
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID(), &rv);
if (NS_FAILED(rv)) {
return rv;
}
// Grab the system principal.
nsCOMPtr<nsIPrincipal> principal;
@ -53,7 +58,7 @@ nsresult CentralizedAdminPrefManagerInit(bool aSandboxEnabled)
// Create a sandbox.
AutoSafeJSContext cx;
JS::Rooted<JSObject*> sandbox(cx);
nsresult rv = xpc->CreateSandbox(cx, principal, sandbox.address());
rv = xpc->CreateSandbox(cx, principal, sandbox.address());
NS_ENSURE_SUCCESS(rv, rv);
// Unwrap, store and root the sandbox.
@ -112,6 +117,8 @@ nsresult EvaluateAdminConfigScript(JS::HandleObject sandbox,
const char *filename, bool globalContext,
bool callbacks, bool skipFirstLine)
{
nsresult rv = NS_OK;
if (skipFirstLine) {
/* In order to protect the privacy of the JavaScript preferences file
* from loading by the browser, we make the first line unparseable
@ -135,7 +142,10 @@ nsresult EvaluateAdminConfigScript(JS::HandleObject sandbox,
}
// Grab XPConnect.
nsCOMPtr<nsIXPConnect> xpc = nsIXPConnect::XPConnect();
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID(), &rv);
if (NS_FAILED(rv)) {
return rv;
}
AutoJSAPI jsapi;
if (!jsapi.Init(sandbox)) {
@ -166,7 +176,7 @@ nsresult EvaluateAdminConfigScript(JS::HandleObject sandbox,
return NS_ERROR_UNEXPECTED;
}
}
nsresult rv = xpc->EvalInSandboxObject(convertedScript, filename, cx,
rv = xpc->EvalInSandboxObject(convertedScript, filename, cx,
sandbox, &v);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -200,7 +200,7 @@ DumpXPC(JSContext *cx,
return false;
}
nsCOMPtr<nsIXPConnect> xpc = nsIXPConnect::XPConnect();
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
if (xpc)
xpc->DebugDump(int16_t(depth));
args.rval().setUndefined();

Просмотреть файл

@ -37,7 +37,8 @@ JSDebugger::~JSDebugger()
NS_IMETHODIMP
JSDebugger::AddClass(JS::Handle<JS::Value> global, JSContext* cx)
{
nsCOMPtr<nsIXPConnect> xpc = nsIXPConnect::XPConnect();
nsresult rv;
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID(), &rv);
if (!global.isObject()) {
return NS_ERROR_INVALID_ARG;

Просмотреть файл

@ -191,12 +191,19 @@ interface nsIXPCWrappedJSObjectGetter : nsISupports
/***************************************************************************/
[noscript, builtinclass, uuid(768507b5-b981-40c7-8276-f6a1da502a24)]
%{ C++
// For use with the service manager
// {CB6593E0-F9B2-11d2-BDD6-000064657374}
#define NS_XPCONNECT_CID \
{ 0xcb6593e0, 0xf9b2, 0x11d2, \
{ 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
%}
[noscript, uuid(768507b5-b981-40c7-8276-f6a1da502a24)]
interface nsIXPConnect : nsISupports
{
%{ C++
// These get non-addref'd pointers
static nsIXPConnect* XPConnect();
NS_DEFINE_STATIC_CID_ACCESSOR(NS_XPCONNECT_CID)
%}
/**
@ -369,6 +376,4 @@ interface nsIXPConnect : nsISupports
[noscript] JSObjectPtr readFunction(in nsIObjectInputStream aStream,
in JSContextPtr aJSContext);
[infallible] readonly attribute boolean isShuttingDown;
};

Просмотреть файл

@ -69,7 +69,7 @@ JSValIsInterfaceOfType(JSContext* cx, HandleValue v, REFNSIID iid)
if (v.isPrimitive())
return false;
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
RootedObject obj(cx, &v.toObject());
return NS_SUCCEEDED(xpc->GetWrappedNativeOfJSObject(cx, obj, getter_AddRefs(wn))) && wn &&
NS_SUCCEEDED(wn->Native()->QueryInterface(iid, getter_AddRefs(iface))) && iface;
@ -258,7 +258,7 @@ nsXPCComponents_Interfaces::Resolve(nsIXPConnectWrappedNative* wrapper,
nsCOMPtr<nsIJSIID> nsid = nsJSIID::NewID(info);
if (nsid) {
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
RootedObject idobj(cx);
if (NS_SUCCEEDED(xpc->WrapNative(cx, obj,
static_cast<nsIJSIID*>(nsid),
@ -446,7 +446,7 @@ nsXPCComponents_InterfacesByID::Resolve(nsIXPConnectWrappedNative* wrapper,
if (!nsid)
return NS_ERROR_OUT_OF_MEMORY;
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
RootedObject idobj(cx);
if (NS_SUCCEEDED(xpc->WrapNative(cx, obj,
static_cast<nsIJSIID*>(nsid),
@ -631,7 +631,7 @@ nsXPCComponents_Classes::Resolve(nsIXPConnectWrappedNative* wrapper,
name[0] != '{') { // we only allow contractids here
nsCOMPtr<nsIJSCID> nsid = nsJSCID::NewID(name.get());
if (nsid) {
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
RootedObject idobj(cx);
if (NS_SUCCEEDED(xpc->WrapNative(cx, obj,
static_cast<nsIJSCID*>(nsid),
@ -841,7 +841,7 @@ nsXPCComponents_ClassesByID::Resolve(nsIXPConnectWrappedNative* wrapper,
{
nsCOMPtr<nsIJSCID> nsid = nsJSCID::NewID(name.get());
if (nsid) {
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
RootedObject idobj(cx);
if (NS_SUCCEEDED(xpc->WrapNative(cx, obj,
static_cast<nsIJSCID*>(nsid),
@ -1320,7 +1320,7 @@ nsXPCComponents_Exception::Construct(nsIXPConnectWrappedNative* wrapper, JSConte
struct MOZ_STACK_CLASS ExceptionArgParser
{
ExceptionArgParser(JSContext* context,
nsIXPConnect* xpconnect)
nsXPConnect* xpconnect)
: eMsg("exception")
, eResult(NS_ERROR_FAILURE)
, cx(context)
@ -1464,7 +1464,7 @@ struct MOZ_STACK_CLASS ExceptionArgParser
// Various bits and pieces that are helpful to have around.
JSContext* cx;
nsIXPConnect* xpc;
nsXPConnect* xpc;
};
// static
@ -1473,7 +1473,7 @@ nsXPCComponents_Exception::CallOrConstruct(nsIXPConnectWrappedNative* wrapper,
JSContext* cx, HandleObject obj,
const CallArgs& args, bool* _retval)
{
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
MOZ_DIAGNOSTIC_ASSERT(nsContentUtils::IsCallerChrome());
@ -1682,7 +1682,7 @@ nsresult
nsXPCConstructor::CallOrConstruct(nsIXPConnectWrappedNative* wrapper,JSContext* cx,
HandleObject obj, const CallArgs& args, bool* _retval)
{
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
// security check not required because we are going to call through the
// code which is reflected into JS which will do that for us later.
@ -1859,7 +1859,7 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative* wrapper,
// get the various other object pointers we need
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
XPCWrappedNativeScope* scope = ObjectScope(obj);
nsCOMPtr<nsIXPCComponents> comp;

Просмотреть файл

@ -758,7 +758,7 @@ xpc_NewIDObject(JSContext* cx, HandleObject scope, const nsID& aID)
nsCOMPtr<nsIJSID> iid = nsJSID::NewID(aID);
if (iid) {
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
if (xpc) {
xpc->WrapNative(cx, scope, static_cast<nsISupports*>(iid),
NS_GET_IID(nsIJSID), obj.address());

Просмотреть файл

@ -677,7 +677,7 @@ void XPCJSRuntime::TraceNativeBlackRoots(JSTracer* trc)
roots->TraceJSAll(trc);
}
dom::TraceBlackJS(trc, nsIXPConnect::XPConnect()->GetIsShuttingDown());
dom::TraceBlackJS(trc, nsXPConnect::XPConnect()->IsShuttingDown());
}
void XPCJSRuntime::TraceAdditionalNativeGrayRoots(JSTracer* trc)

Просмотреть файл

@ -21,21 +21,26 @@
#define MOZJSSUBSCRIPTLOADER_CONTRACTID "@mozilla.org/moz/jssubscript-loader;1"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsJSID)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIXPConnect,
nsXPConnect::GetSingleton)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(mozJSComponentLoader,
mozJSComponentLoader::GetOrCreate);
NS_GENERIC_FACTORY_CONSTRUCTOR(mozJSSubScriptLoader)
NS_DEFINE_NAMED_CID(NS_JS_ID_CID);
NS_DEFINE_NAMED_CID(NS_XPCONNECT_CID);
NS_DEFINE_NAMED_CID(MOZJSCOMPONENTLOADER_CID);
NS_DEFINE_NAMED_CID(MOZ_JSSUBSCRIPTLOADER_CID);
#define XPCONNECT_CIDENTRIES \
{ &kNS_JS_ID_CID, false, nullptr, nsJSIDConstructor }, \
{ &kNS_XPCONNECT_CID, false, nullptr, nsIXPConnectConstructor }, \
{ &kMOZJSCOMPONENTLOADER_CID, false, nullptr, mozJSComponentLoaderConstructor },\
{ &kMOZ_JSSUBSCRIPTLOADER_CID, false, nullptr, mozJSSubScriptLoaderConstructor },
#define XPCONNECT_CONTRACTS \
{ XPC_XPCONNECT_CONTRACTID, &kNS_XPCONNECT_CID }, \
{ MOZJSCOMPONENTLOADER_CONTRACTID, &kMOZJSCOMPONENTLOADER_CID }, \
{ MOZJSSUBSCRIPTLOADER_CONTRACTID, &kMOZ_JSSUBSCRIPTLOADER_CID },

Просмотреть файл

@ -355,7 +355,7 @@ bool XPCVariant::InitializeData(JSContext* cx)
// XXX This could be smarter and pick some more interesting iface.
nsIXPConnect* xpc = nsIXPConnect::XPConnect();
nsXPConnect* xpc = nsXPConnect::XPConnect();
nsCOMPtr<nsISupports> wrapper;
const nsIID& iid = NS_GET_IID(nsISupports);

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/Likely.h"
#include "mozilla/Unused.h"
#include "xpcprivate.h"
#include "XPCWrapper.h"
#include "jsfriendapi.h"
#include "js/ProfilingStack.h"
@ -58,6 +59,7 @@ nsIPrincipal* nsXPConnect::gSystemPrincipal = nullptr;
const char XPC_EXCEPTION_CONTRACTID[] = "@mozilla.org/js/xpc/Exception;1";
const char XPC_CONSOLE_CONTRACTID[] = "@mozilla.org/consoleservice;1";
const char XPC_SCRIPT_ERROR_CONTRACTID[] = "@mozilla.org/scripterror;1";
const char XPC_XPCONNECT_CONTRACTID[] = "@mozilla.org/js/xpc/XPConnect;1";
/***************************************************************************/
@ -152,6 +154,12 @@ nsXPConnect::InitStatics()
gSelf->mRuntime->InitSingletonScopes();
}
already_AddRefed<nsXPConnect>
nsXPConnect::GetSingleton()
{
return do_AddRef(nsXPConnect::XPConnect());
}
// static
void
nsXPConnect::ReleaseXPConnectSingleton()
@ -1090,30 +1098,6 @@ nsXPConnect::ReadFunction(nsIObjectInputStream* stream, JSContext* cx, JSObject*
return ReadScriptOrFunction(stream, cx, nullptr, functionObjp);
}
NS_IMETHODIMP
nsXPConnect::GetIsShuttingDown(bool* aIsShuttingDown)
{
if (!aIsShuttingDown)
return NS_ERROR_INVALID_ARG;
*aIsShuttingDown = mShuttingDown;
return NS_OK;
}
// static
nsIXPConnect*
nsIXPConnect::XPConnect()
{
// Do a release-mode assert that we're not doing anything significant in
// XPConnect off the main thread. If you're an extension developer hitting
// this, you need to change your code. See bug 716167.
if (!MOZ_LIKELY(NS_IsMainThread()))
MOZ_CRASH();
return nsXPConnect::gSelf;
}
/* These are here to be callable from a debugger */
extern "C" {

Просмотреть файл

@ -229,6 +229,18 @@ public:
// non-interface implementation
public:
// These get non-addref'd pointers
static nsXPConnect* XPConnect()
{
// Do a release-mode assert that we're not doing anything significant in
// XPConnect off the main thread. If you're an extension developer hitting
// this, you need to change your code. See bug 716167.
if (!MOZ_LIKELY(NS_IsMainThread()))
MOZ_CRASH();
return gSelf;
}
static XPCJSRuntime* GetRuntimeInstance();
static bool IsISupportsDescendant(const nsXPTInterfaceInfo* info);
@ -247,11 +259,15 @@ public:
return gSystemPrincipal;
}
static already_AddRefed<nsXPConnect> GetSingleton();
// Called by module code in dll startup
static void InitStatics();
// Called by module code on dll shutdown.
static void ReleaseXPConnectSingleton();
bool IsShuttingDown() const {return mShuttingDown;}
void RecordTraversal(void* p, nsISupports* s);
protected:
@ -267,14 +283,11 @@ private:
XPCJSRuntime* mRuntime;
bool mShuttingDown;
friend class nsIXPConnect;
public:
static nsIScriptSecurityManager* gScriptSecurityManager;
static nsIPrincipal* gSystemPrincipal;
};
/***************************************************************************/
class XPCRootSetElem
@ -761,7 +774,7 @@ inline void CHECK_STATE(int s) const {MOZ_ASSERT(mState >= s, "bad state");}
private:
State mState;
nsCOMPtr<nsIXPConnect> mXPC;
RefPtr<nsXPConnect> mXPC;
XPCJSContext* mXPCJSContext;
JSContext* mJSContext;

Просмотреть файл

@ -22,7 +22,6 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsISupportsImpl.h"
#include "nsISupportsUtils.h"
#include "nsIXPConnect.h"
#include "nsContentUtils.h"
#include "nsDocShell.h"
#include "nsGlobalWindow.h"
@ -1173,7 +1172,7 @@ LoadInfo::GetRedirects(JSContext* aCx, JS::MutableHandle<JS::Value> aRedirects,
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIXPConnect> xpc = nsIXPConnect::XPConnect();
nsCOMPtr<nsIXPConnect> xpc = mozilla::services::GetXPConnect();
for (size_t idx = 0; idx < aArray.Length(); idx++) {
JS::RootedObject jsobj(aCx);

Просмотреть файл

@ -1341,7 +1341,7 @@ Connection::Close()
if (isAsyncExecutionThreadAvailable()) {
#ifdef DEBUG
if (NS_IsMainThread()) {
nsCOMPtr<nsIXPConnect> xpc = nsIXPConnect::XPConnect();
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
Unused << xpc->DebugDumpJSStack(false, false, false);
}
#endif

Просмотреть файл

@ -35,7 +35,7 @@ stepFunc(JSContext *aCtx, uint32_t argc, JS::Value *_vp)
{
JS::CallArgs args = CallArgsFromVp(argc, _vp);
nsCOMPtr<nsIXPConnect> xpc(nsIXPConnect::XPConnect());
nsCOMPtr<nsIXPConnect> xpc(mozilla::services::GetXPConnect());
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
if (!args.thisv().isObject()) {

Просмотреть файл

@ -228,7 +228,7 @@ already_AddRefed<nsIURI>
GetJSValueAsURI(JSContext* aCtx,
const JS::Value& aValue) {
if (!aValue.isPrimitive()) {
nsCOMPtr<nsIXPConnect> xpc = nsIXPConnect::XPConnect();
nsCOMPtr<nsIXPConnect> xpc = mozilla::services::GetXPConnect();
nsCOMPtr<nsIXPConnectWrappedNative> wrappedObj;
nsresult rv = xpc->GetWrappedNativeOfJSObject(aCtx, aValue.toObjectOrNull(),
@ -2521,7 +2521,7 @@ History::UpdatePlaces(JS::Handle<JS::Value> aPlaceInfos,
// a mistake.
if (data.visitTime < (PR_Now() / 1000)) {
#ifdef DEBUG
nsCOMPtr<nsIXPConnect> xpc = nsIXPConnect::XPConnect();
nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
Unused << xpc->DebugDumpJSStack(false, false, false);
MOZ_CRASH("invalid time format passed to updatePlaces");
#endif

Просмотреть файл

@ -107,7 +107,7 @@ PlaceInfo::GetVisits(JSContext* aContext,
JS::Rooted<JSObject*> global(aContext, JS::CurrentGlobalOrNull(aContext));
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
nsCOMPtr<nsIXPConnect> xpc = nsIXPConnect::XPConnect();
nsCOMPtr<nsIXPConnect> xpc = mozilla::services::GetXPConnect();
for (VisitsArray::size_type idx = 0; idx < mVisits.Length(); idx++) {
JS::RootedObject jsobj(aContext);

Просмотреть файл

@ -419,15 +419,19 @@ void nsMenuX::MenuConstruct()
// bug 365405: Manually wrap the menupopup node to make sure it's bounded
if (!mXBLAttached) {
nsCOMPtr<nsIXPConnect> xpconnect = nsIXPConnect::XPConnect();
nsIDocument* ownerDoc = menuPopup->OwnerDoc();
dom::AutoJSAPI jsapi;
if (ownerDoc && jsapi.Init(ownerDoc->GetInnerWindow())) {
JSContext* cx = jsapi.cx();
JS::RootedObject ignoredObj(cx);
xpconnect->WrapNative(cx, JS::CurrentGlobalOrNull(cx), menuPopup,
NS_GET_IID(nsISupports), ignoredObj.address());
mXBLAttached = true;
nsresult rv;
nsCOMPtr<nsIXPConnect> xpconnect =
do_GetService(nsIXPConnect::GetCID(), &rv);
if (NS_SUCCEEDED(rv)) {
nsIDocument* ownerDoc = menuPopup->OwnerDoc();
dom::AutoJSAPI jsapi;
if (ownerDoc && jsapi.Init(ownerDoc->GetInnerWindow())) {
JSContext* cx = jsapi.cx();
JS::RootedObject ignoredObj(cx);
xpconnect->WrapNative(cx, JS::CurrentGlobalOrNull(cx), menuPopup,
NS_GET_IID(nsISupports), ignoredObj.address());
mXBLAttached = true;
}
}
}

Просмотреть файл

@ -20,6 +20,8 @@ service('ObserverService', 'nsIObserverService',
"@mozilla.org/observer-service;1")
service('StringBundleService', 'nsIStringBundleService',
"@mozilla.org/intl/stringbundle;1")
service('XPConnect', 'nsIXPConnect',
"@mozilla.org/js/xpc/XPConnect;1")
service('PermissionManager', 'nsIPermissionManager',
"@mozilla.org/permissionmanager;1")
service('ServiceWorkerManager', 'nsIServiceWorkerManager',