mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-18 16:00:18 +01:00
Closes issue #698.
This commit is contained in:
@@ -38,10 +38,20 @@
|
||||
#include "dactylUtils.h"
|
||||
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsobj.h"
|
||||
// #include "jsobj.h"
|
||||
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
#if GECKO_MAJOR < 10
|
||||
static inline JSObject*
|
||||
JS_GetGlobalForScopeChain(JSContext *cx) {
|
||||
JSObject *callingScope = JS_GetScopeChain(cx);
|
||||
if (!callingScope)
|
||||
return nsnull;
|
||||
return JS_GetGlobalForObject(cx, callingScope);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Evil. Evil, evil, evil.
|
||||
*/
|
||||
@@ -244,9 +254,8 @@ dactylUtils::EvalInContext(const nsAString &aSource,
|
||||
{
|
||||
JSAutoRequest req(cx);
|
||||
|
||||
callingScope = JS_GetScopeChain(cx);
|
||||
callingScope = JS_GetGlobalForScopeChain(cx);
|
||||
NS_ENSURE_TRUE(callingScope, NS_ERROR_FAILURE);
|
||||
callingScope = JS_GetGlobalForObject(cx, callingScope);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -313,6 +322,10 @@ dactylUtils::CreateContents(nsIDOMElement *aElement)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace XPCWrapper {
|
||||
extern JSObject *UnsafeUnwrapSecurityWrapper(JSObject *obj);
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
dactylUtils::GetGlobalForObject(const jsval &aObject,
|
||||
JSContext *cx,
|
||||
@@ -323,18 +336,16 @@ dactylUtils::GetGlobalForObject(const jsval &aObject,
|
||||
NS_ENSURE_FALSE(JSVAL_IS_PRIMITIVE(aObject),
|
||||
NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
|
||||
JSObject *obj = JSVAL_TO_OBJECT(aObject);
|
||||
#ifndef WIN32 /* Why? No idea. */
|
||||
if (obj->isProxy())
|
||||
#endif
|
||||
obj = obj->unwrap();
|
||||
JSObject *obj = XPCWrapper::UnsafeUnwrapSecurityWrapper(JSVAL_TO_OBJECT(aObject));
|
||||
|
||||
JSObject *global = JS_GetGlobalForObject(cx, obj);
|
||||
*rval = OBJECT_TO_JSVAL(global);
|
||||
|
||||
/*
|
||||
// Outerize if necessary.
|
||||
if (JSObjectOp outerize = global->getClass()->ext.outerObject)
|
||||
*rval = OBJECT_TO_JSVAL(outerize(cx, global));
|
||||
*/
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,13 @@ inline PRBool EnsureStringLength(T& aStr, PRUint32 aLen)
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#if GECKO_MAJOR < 10
|
||||
static inline JSVersion
|
||||
JS_GetVersion(JSContext *cx) {
|
||||
return cx->findVersion();
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
#include "mozilla/scache/StartupCache.h"
|
||||
#include "mozilla/scache/StartupCacheUtils.h"
|
||||
@@ -519,7 +526,7 @@ dactylUtils::LoadSubScript (const PRUnichar * aURL
|
||||
|
||||
bool writeScript = false;
|
||||
JSScriptType *scriptObj = nsnull;
|
||||
JSVersion version = cx->findVersion();
|
||||
JSVersion version = JS_GetVersion(cx);
|
||||
|
||||
nsCAutoString cachePath;
|
||||
cachePath.Append("jssubloader/");
|
||||
|
||||
@@ -877,7 +877,7 @@ var Buffer = Module("Buffer", {
|
||||
showElementInfo: function showElementInfo(elem) {
|
||||
let { dactyl } = this.modules;
|
||||
|
||||
dactyl.echo(<><!--L-->Element:<br/>{util.objectToString(elem, true)}</>, commandline.FORCE_MULTILINE);
|
||||
dactyl.echo(<><!--L-->Element:<br/>{util.objectToString(elem, true)}</>);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user