зеркало из https://github.com/mozilla/pjs.git
Backing out js security changes.
This commit is contained in:
Родитель
92f61aa84f
Коммит
cc8b77b488
|
@ -113,9 +113,6 @@ public:
|
|||
NS_IMETHOD
|
||||
Initialize(PRBool *result);
|
||||
|
||||
NS_IMETHOD
|
||||
InitializeFrameWalker(nsICapsSecurityCallbacks* aInterface);
|
||||
|
||||
/**
|
||||
* Registers the given Principal with the system.
|
||||
*
|
||||
|
@ -212,9 +209,6 @@ public:
|
|||
NS_IMETHOD
|
||||
NewPrincipalArray(PRUint32 count, void* *result);
|
||||
|
||||
NS_IMETHOD
|
||||
CreateMixedPrincipalArray(void *zig, char* name, const char* codebase, void** result);
|
||||
|
||||
NS_IMETHOD
|
||||
FreePrincipalArray(void *prinArray);
|
||||
|
||||
|
|
|
@ -4,4 +4,3 @@ nsICodebasePrincipal.h
|
|||
nsICodeSourcePrincipal.h
|
||||
nsIPrincipal.h
|
||||
nsCapsPublicEnums.h
|
||||
nsICapsSecurityCallbacks.h
|
||||
|
|
|
@ -28,8 +28,7 @@ EXPORTS = nsIPrincipal.h \
|
|||
nsICertPrincipal.h \
|
||||
nsICapsManager.h \
|
||||
nsICodeSourcePrincipal.h \
|
||||
nsCapsPublicEnums.h \
|
||||
nsICapsSecurityCallbacks.h
|
||||
nsCapsPublicEnums.h
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ EXPORTS= \
|
|||
nsICertPrincipal.h \
|
||||
nsICapsManager.h \
|
||||
nsICodeSourcePrincipal.h \
|
||||
nsCapsPublicEnums.h \
|
||||
nsICapsSecurityCallbacks.h
|
||||
nsCapsPublicEnums.h
|
||||
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsCapsPublicEnums.h"
|
||||
|
||||
class nsITarget;
|
||||
class nsICapsSecurityCallbacks;
|
||||
|
||||
#define NS_ALL_PRIVILEGES ((nsITarget*)NULL)
|
||||
|
||||
|
@ -133,14 +132,6 @@ public:
|
|||
NS_IMETHOD
|
||||
Initialize(PRBool *result) = 0;
|
||||
|
||||
/**
|
||||
* Initializes the capabilities frame walking code.
|
||||
*
|
||||
* @param aInterface - interface for calling frame walking code.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
InitializeFrameWalker(nsICapsSecurityCallbacks* aInterface) = 0;
|
||||
|
||||
/**
|
||||
* Registers the given Principal with the system.
|
||||
*
|
||||
|
@ -237,9 +228,6 @@ public:
|
|||
NS_IMETHOD
|
||||
NewPrincipalArray(PRUint32 count, void* *result) = 0;
|
||||
|
||||
NS_IMETHOD
|
||||
CreateMixedPrincipalArray(void *zig, char* name, const char* codebase, void** result) = 0;
|
||||
|
||||
NS_IMETHOD
|
||||
FreePrincipalArray(void *prinArray) = 0;
|
||||
|
||||
|
|
|
@ -24,14 +24,6 @@
|
|||
#include "nsCCertPrincipal.h"
|
||||
#include "nsCCodeSourcePrincipal.h"
|
||||
#include "nsCaps.h"
|
||||
#include "nsICapsSecurityCallbacks.h"
|
||||
#include "nsLoadZig.h"
|
||||
#include "secnav.h"
|
||||
|
||||
#ifdef MOZ_SECURITY
|
||||
#include "navhook.h"
|
||||
#include "jarutil.h"
|
||||
#endif /* MOZ_SECURITY */
|
||||
|
||||
static NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID);
|
||||
static NS_DEFINE_IID(kICapsManagerIID, NS_ICAPSMANAGER_IID);
|
||||
|
@ -244,19 +236,6 @@ nsCCapsManager::Initialize(PRBool *result)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the capabilities frame walking code.
|
||||
*
|
||||
* @param aInterface - interface for calling frame walking code.
|
||||
*/
|
||||
NS_METHOD
|
||||
nsCCapsManager::InitializeFrameWalker(nsICapsSecurityCallbacks* aInterface)
|
||||
{
|
||||
//XXX write me
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the given Principal with the system.
|
||||
*
|
||||
|
@ -540,95 +519,6 @@ nsCCapsManager::NewPrincipalArray(PRUint32 count, void* *ret_val)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* CreateMixedPrincipalArray take codebase and ZIG file information and returns a
|
||||
* pointer to an array of nsIPrincipal objects.
|
||||
*/
|
||||
NS_METHOD
|
||||
nsCCapsManager::CreateMixedPrincipalArray(void *aZig, char* name, const char* codebase, void** result)
|
||||
{
|
||||
*result = NULL;
|
||||
PRBool hasCodebase;
|
||||
int i;
|
||||
PRUint32 count;
|
||||
nsIPrincipal *principal;
|
||||
|
||||
hasCodebase = (PRBool)codebase;
|
||||
|
||||
/* First count the number of principals */
|
||||
count = codebase ? 1 : 0;
|
||||
|
||||
//Should possibly be #ifdef MOZ_SECURITY but I don't want to break the sec build
|
||||
#if 0
|
||||
SOBITEM *item;
|
||||
ZIG_Context * zig_aCx = NULL;
|
||||
ZIG *zig = (ZIG*)aZig;
|
||||
|
||||
if (zig && name) {
|
||||
/* Make sure file is signed */
|
||||
if ((zig_aCx = SOB_find(zig, name, ZIG_SIGN)) != NULL) {
|
||||
int zig_count=0;
|
||||
/* count the number of signers */
|
||||
while (SOB_find_next(zig_aCx, &item) >= 0) {
|
||||
zig_count++;
|
||||
}
|
||||
SOB_find_end(zig_aCx);
|
||||
count += zig_count;
|
||||
}
|
||||
else {
|
||||
zig = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (count == 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NewPrincipalArray(count, result);
|
||||
|
||||
if (*result == NULL) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (zig && ((zig_aCx = SOB_find(zig, name, ZIG_SIGN)) == NULL)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
i = 0;
|
||||
while (zig && SOB_find_next(zig_aCx, &item) >= 0) {
|
||||
FINGERZIG *fingPrint;
|
||||
|
||||
fingPrint = (FINGERZIG *) item->data;
|
||||
|
||||
/* create a new nsIPrincipal(CERT_KEY, fingPrint->key) */
|
||||
NewPrincipal(nsPrincipalType_CertKey,
|
||||
fingPrint->key,
|
||||
fingPrint->length,
|
||||
zig,
|
||||
&principal);
|
||||
RegisterPrincipal(principal, NULL);
|
||||
SetPrincipalArrayElement(*result, i++, principal);
|
||||
}
|
||||
|
||||
if (zig) {
|
||||
SOB_find_end(zig_aCx);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (codebase) {
|
||||
// Add a codebase principal.
|
||||
NewPrincipal(nsPrincipalType_CodebaseExact,
|
||||
(void*)codebase,
|
||||
PL_strlen(codebase),
|
||||
NULL,
|
||||
&principal);
|
||||
RegisterPrincipal(principal, NULL);
|
||||
SetPrincipalArrayElement(*result, i++, principal);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsCCapsManager::FreePrincipalArray(void *prinArray)
|
||||
{
|
||||
|
|
|
@ -38,14 +38,11 @@
|
|||
#include "nsIScriptEventListener.h"
|
||||
#include "nsDOMEventsIIDs.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptGlobalObjectData.h"
|
||||
|
||||
static NS_DEFINE_IID(kIEventListenerManagerIID, NS_IEVENTLISTENERMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventIID, NS_IDOMEVENT_IID);
|
||||
static NS_DEFINE_IID(kIScriptEventListenerIID, NS_ISCRIPTEVENTLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectDataIID, NS_ISCRIPTGLOBALOBJECTDATA_IID);
|
||||
|
||||
nsEventListenerManager::nsEventListenerManager()
|
||||
{
|
||||
|
@ -416,20 +413,6 @@ nsresult nsEventListenerManager::AddScriptEventListener(nsIScriptContext* aConte
|
|||
nsIAtom *aName, const nsString& aFunc, REFNSIID aIID)
|
||||
{
|
||||
JSObject *mScriptObject;
|
||||
nsIScriptGlobalObject *global;
|
||||
nsIScriptGlobalObjectData *globalData;
|
||||
JSPrincipals* principals = nsnull;
|
||||
|
||||
global = aContext->GetGlobalObject();
|
||||
if (global && NS_SUCCEEDED(global->QueryInterface(kIScriptGlobalObjectDataIID, (void**)&globalData))) {
|
||||
if (NS_FAILED(globalData->GetPrincipals((void**)&principals))) {
|
||||
NS_RELEASE(global);
|
||||
NS_RELEASE(globalData);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(globalData);
|
||||
}
|
||||
NS_IF_RELEASE(global);
|
||||
|
||||
if (NS_OK == aScriptObjectOwner->GetScriptObject(aContext, (void**)&mScriptObject)) {
|
||||
JSContext* mJSContext = (JSContext*)aContext->GetNativeContext();
|
||||
|
@ -440,9 +423,8 @@ nsresult nsEventListenerManager::AddScriptEventListener(nsIScriptContext* aConte
|
|||
mName.ToLowerCase(mLowerName);
|
||||
mCharName = mLowerName.ToNewCString();
|
||||
|
||||
|
||||
if (nsnull != mCharName) {
|
||||
JS_CompileUCFunctionForPrincipals(mJSContext, mScriptObject, principals, mCharName,
|
||||
JS_CompileUCFunction(mJSContext, mScriptObject, mCharName,
|
||||
1, mEventArgv, (jschar*)aFunc.GetUnicode(), aFunc.Length(),
|
||||
nsnull, 0);
|
||||
delete[] mCharName;
|
||||
|
|
|
@ -27,8 +27,6 @@ nsIDOMScriptObjectFactory.h
|
|||
nsIDOMNativeObjectRegistry.h
|
||||
nsDOMCID.h
|
||||
nsIScriptSecurityManager.h
|
||||
nsIScriptGlobalObjectData.h
|
||||
nsIScriptSecurityManager.h
|
||||
nsIScriptNameSetRegistry.h
|
||||
nsIScriptExternalNameSet.h
|
||||
nsIScriptNameSpaceManager.h
|
||||
|
|
|
@ -40,7 +40,6 @@ EXPORTS = \
|
|||
nsIDOMNativeObjectRegistry.h \
|
||||
nsDOMCID.h \
|
||||
nsIScriptSecurityManager.h \
|
||||
nsIScriptGlobalObjectData.h \
|
||||
nsIScriptNameSetRegistry.h \
|
||||
nsIScriptExternalNameSet.h \
|
||||
nsIScriptNameSpaceManager.h \
|
||||
|
|
|
@ -36,8 +36,7 @@ EXPORTS=nsIScriptContext.h \
|
|||
nsIScriptSecurityManager.h \
|
||||
nsIScriptNameSetRegistry.h \
|
||||
nsIScriptExternalNameSet.h \
|
||||
nsIScriptNameSpaceManager.h \
|
||||
nsIScriptGlobalObjectData.h
|
||||
nsIScriptNameSpaceManager.h
|
||||
|
||||
MODULE=dom
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIScriptGlobalObjectData_h__
|
||||
#define nsIScriptGlobalObjectData_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_ISCRIPTGLOBALOBJECTDATA_IID \
|
||||
{ 0x98485f80, 0x9615, 0x11d2, \
|
||||
{ 0xbd, 0x92, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
|
||||
|
||||
/**
|
||||
* JS Global Object information.
|
||||
*/
|
||||
|
||||
class nsIScriptGlobalObjectData : public nsISupports {
|
||||
public:
|
||||
NS_IMETHOD GetPrincipals(void** aPrincipals) = 0;
|
||||
NS_IMETHOD SetPrincipals(void* aPrincipals) = 0;
|
||||
NS_IMETHOD GetOrigin(nsString* aOrigin) = 0;
|
||||
};
|
||||
|
||||
#endif //nsIScriptGlobalObjectData_h__
|
|
@ -20,14 +20,9 @@
|
|||
#define nsIScriptSecurityManager_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsString.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIScriptGlobalObject;
|
||||
class nsIScriptContext;
|
||||
class nsIDOMEvent;
|
||||
class nsIURI;
|
||||
|
||||
/*
|
||||
* Event listener interface.
|
||||
|
@ -38,23 +33,6 @@ class nsIURI;
|
|||
0x58df5780, 0x8006, 0x11d2, \
|
||||
{0xbd, 0x91, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
|
||||
|
||||
typedef enum eJSTarget {
|
||||
eJSTarget_UniversalBrowserRead,
|
||||
eJSTarget_UniversalBrowserWrite,
|
||||
eJSTarget_UniversalSendMail,
|
||||
eJSTarget_UniversalFileRead,
|
||||
eJSTarget_UniversalFileWrite,
|
||||
eJSTarget_UniversalPreferencesRead,
|
||||
eJSTarget_UniversalPreferencesWrite,
|
||||
eJSTarget_UniversalDialerAccess,
|
||||
eJSTarget_Max
|
||||
} eJSTarget;
|
||||
|
||||
typedef struct nsJSPrincipalsList {
|
||||
JSPrincipals *principals;
|
||||
struct nsJSPrincipalsList *next;
|
||||
} nsJSPrincipalsList;
|
||||
|
||||
class nsIScriptSecurityManager : public nsISupports {
|
||||
|
||||
public:
|
||||
|
@ -65,45 +43,14 @@ public:
|
|||
*/
|
||||
NS_IMETHOD Init() = 0;
|
||||
|
||||
NS_IMETHOD CheckScriptAccess(nsIScriptContext* aContext, void* aObj, const char* aProp, PRBool* aResult) = 0;
|
||||
/**
|
||||
* Existing API from lib/libmocha/lm_taint.c. I'm maintaining the api largely as is, just xpcom'ifying
|
||||
* it. After I get security working I'll reevaluate the need for each of these individually -joki
|
||||
/**
|
||||
* Checks script access to the property/method in question
|
||||
*/
|
||||
NS_IMETHOD GetSubjectOriginURL(JSContext *aCx, nsString* aOrigin) = 0;
|
||||
NS_IMETHOD GetObjectOriginURL(JSContext *aCx, JSObject *object, nsString* aOrigin) = 0;
|
||||
NS_IMETHOD GetPrincipalsFromStackFrame(JSContext *aCx, JSPrincipals** aPrincipals) = 0;
|
||||
NS_IMETHOD GetCompilationPrincipals(nsIScriptContext *aContext, nsIScriptGlobalObject* aGlobal,
|
||||
JSPrincipals *aLayoutPrincipals, JSPrincipals** aPrincipals) = 0;
|
||||
NS_IMETHOD CanAccessTarget(JSContext *cx, eJSTarget target, PRBool* aReturn) = 0;
|
||||
NS_IMETHOD CheckPermissions(JSContext *cx, JSObject *obj, eJSTarget target, PRBool* aReturn) = 0;
|
||||
NS_IMETHOD CheckContainerAccess(JSContext *aCx, JSObject *aObj, eJSTarget aTarget, PRBool* aReturn) = 0;
|
||||
NS_IMETHOD GetContainerPrincipals(JSContext *aCx, JSObject *aContainer, JSPrincipals** aPrincipals) = 0;
|
||||
NS_IMETHOD SetContainerPrincipals(JSContext *aCx, JSObject *aContainer, JSPrincipals* aPrincipals) = 0;
|
||||
NS_IMETHOD CanCaptureEvent(JSContext *aCx, JSFunction *aFun, JSObject *aEventTarget, PRBool* aReturn) = 0;
|
||||
NS_IMETHOD SetExternalCapture(JSContext *aCx, JSPrincipals *aPrincipals, PRBool aBool) = 0;
|
||||
NS_IMETHOD CheckSetParentSlot(JSContext *aCx, JSObject *aObj, jsval aId, jsval *aVp, PRBool* aReturn) = 0;
|
||||
NS_IMETHOD SetDocumentDomain(JSContext *aCx, JSPrincipals *aPrincipals,
|
||||
nsString* aNewDomain, PRBool* aReturn) = 0;
|
||||
NS_IMETHOD DestroyPrincipalsList(JSContext *aCx, nsJSPrincipalsList *aList) = 0;
|
||||
NS_IMETHOD NewJSPrincipals(nsIURI *aURL, nsString* aName, nsString* aCodebase, JSPrincipals** aPrincipals) = 0;
|
||||
#ifdef DO_JAVA_STUFF
|
||||
NS_IMETHOD ExtractFromPrincipalsArchive(JSPrincipals *aPrincipals, char *aName,
|
||||
uint *aLength, char** aReturn) = 0;
|
||||
NS_IMETHOD SetUntransformedSource(JSPrincipals *principals, char *original,
|
||||
char *transformed, PRBool* aReturn) = 0;
|
||||
NS_IMETHOD GetJSPrincipalsFromJavaCaller(JSContext *cx, void *principalsArray, void *pNSISecurityContext, JSPrincipals** aPrincipals) = 0;
|
||||
#endif
|
||||
#if 0
|
||||
NS_IMETHOD CanAccessTargetStr(JSContext *cx, const char *target, PRBool* aReturn)= 0;
|
||||
#endif
|
||||
NS_IMETHOD RegisterPrincipals(nsIScriptContext *aContext, nsIScriptGlobalObject* aGlobal, JSPrincipals *principals,
|
||||
nsString* aName, nsString* aSrc, JSPrincipals** aPrincipals) = 0;
|
||||
NS_IMETHOD CheckScriptAccess(nsIScriptContext* aContext, void* aObj, const char* aProp, PRBool* aResult) = 0;
|
||||
|
||||
};
|
||||
|
||||
//Security flags
|
||||
#define SCRIPT_SECURITY_ALL_ACCESS 0x0000
|
||||
#define SCRIPT_SECURITY_NO_ACCESS 0x0001
|
||||
#define SCRIPT_SECURITY_SAME_DOMAIN_ACCESS 0x0002
|
||||
//XXX expand this flag out once we know the privileges we'll support
|
||||
|
|
|
@ -26,7 +26,7 @@ LIBRARY_NAME = jsdombase_s
|
|||
|
||||
MODULE=dom
|
||||
|
||||
REQUIRES = xpcom raptor dom js netlib caps oji
|
||||
REQUIRES = xpcom raptor dom js netlib
|
||||
|
||||
DEFINES += -D_IMPL_NS_DOM
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ EXPORTS=nsJSUtils.h
|
|||
|
||||
MODULE=raptor
|
||||
|
||||
REQUIRES=xpcom raptor js netlib caps oji
|
||||
REQUIRES=xpcom raptor js netlib
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsBarProps.obj \
|
||||
|
@ -80,7 +80,7 @@ CPP_OBJS= \
|
|||
|
||||
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor \
|
||||
-I$(XPDIST)\public\dom -I$(XPDIST)\public\js -I$(PUBLIC)\netlib -I$(PUBLIC)\plugin -I$(PUBLIC)\oji \
|
||||
-I$(PUBLIC)\java -I$(PUBLIC)\xpconnect -I$(PUBLIC)\pref -I$(PUBLIC)\caps
|
||||
-I$(PUBLIC)\java -I$(PUBLIC)\xpconnect -I$(PUBLIC)\pref
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
#include "nsScreen.h"
|
||||
#include "nsHistory.h"
|
||||
#include "nsBarProps.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#ifndef NECKO
|
||||
#include "nsINetService.h"
|
||||
#else
|
||||
|
@ -80,7 +79,6 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
|||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectDataIID, NS_ISCRIPTGLOBALOBJECTDATA_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIScriptEventListenerIID, NS_ISCRIPTEVENTLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIDOMWindowIID, NS_IDOMWINDOW_IID);
|
||||
|
@ -129,7 +127,6 @@ GlobalWindowImpl::GlobalWindowImpl()
|
|||
mLocation = nsnull;
|
||||
mFrames = nsnull;
|
||||
mOpener = nsnull;
|
||||
mPrincipals = nsnull;
|
||||
|
||||
mTimeouts = nsnull;
|
||||
mTimeoutInsertionPoint = nsnull;
|
||||
|
@ -144,10 +141,6 @@ GlobalWindowImpl::GlobalWindowImpl()
|
|||
|
||||
GlobalWindowImpl::~GlobalWindowImpl()
|
||||
{
|
||||
if (mPrincipals && mContext) {
|
||||
JSPRINCIPALS_DROP((JSContext*)mContext->GetNativeContext(), mPrincipals);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mContext);
|
||||
NS_IF_RELEASE(mDocument);
|
||||
NS_IF_RELEASE(mNavigator);
|
||||
|
@ -186,11 +179,6 @@ GlobalWindowImpl::QueryInterface(const nsIID& aIID,
|
|||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIScriptGlobalObjectDataIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIScriptGlobalObjectData*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIDOMWindowIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIDOMWindow*)this);
|
||||
AddRef();
|
||||
|
@ -277,18 +265,13 @@ GlobalWindowImpl::SetNewDocument(nsIDOMDocument *aDocument)
|
|||
|
||||
ClearAllTimeouts();
|
||||
|
||||
if (mPrincipals && mContext) {
|
||||
JSPRINCIPALS_DROP((JSContext *)mContext->GetNativeContext(), mPrincipals);
|
||||
mPrincipals = nsnull;
|
||||
}
|
||||
|
||||
if ((nsnull != mScriptObject) &&
|
||||
(nsnull != mContext) /* &&
|
||||
(nsnull != aDocument) */ ) {
|
||||
JS_ClearScope((JSContext *)mContext->GetNativeContext(),
|
||||
(JSObject *)mScriptObject);
|
||||
}
|
||||
|
||||
|
||||
if (nsnull != mDocument) {
|
||||
NS_RELEASE(mDocument);
|
||||
}
|
||||
|
@ -1530,7 +1513,7 @@ GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
|||
timeout->filename,
|
||||
timeout->lineno, nsAutoString(""), &isundefined);
|
||||
#endif
|
||||
JS_EvaluateScriptForPrincipals(cx, (JSObject *)mScriptObject, timeout->principals,
|
||||
JS_EvaluateScript(cx, (JSObject *)mScriptObject,
|
||||
timeout->expr,
|
||||
PL_strlen(timeout->expr),
|
||||
timeout->filename, timeout->lineno,
|
||||
|
@ -1649,11 +1632,6 @@ GlobalWindowImpl::SetTimeoutOrInterval(JSContext *cx,
|
|||
nsTimeoutImpl *timeout, **insertion_point;
|
||||
jsdouble interval;
|
||||
PRInt64 now, delta;
|
||||
JSPrincipals* principals;
|
||||
|
||||
if (NS_FAILED(GetPrincipals((void**)&principals))) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
if (!JS_ValueToNumber(cx, argv[1], &interval)) {
|
||||
|
@ -1692,7 +1670,7 @@ GlobalWindowImpl::SetTimeoutOrInterval(JSContext *cx,
|
|||
timeout->interval = (PRInt32)interval;
|
||||
timeout->expr = expr;
|
||||
timeout->funobj = funobj;
|
||||
timeout->principals = principals;
|
||||
timeout->principals = nsnull;
|
||||
if (expr) {
|
||||
timeout->argv = 0;
|
||||
timeout->argc = 0;
|
||||
|
@ -2578,117 +2556,6 @@ GlobalWindowImpl::ReleaseEvent(const nsString& aType)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetPrincipals(void** aPrincipals)
|
||||
{
|
||||
if (!mPrincipals) {
|
||||
if (mContext) {
|
||||
nsIScriptSecurityManager* secMan = nsnull;
|
||||
mContext->GetSecurityManager(&secMan);
|
||||
if (secMan) {
|
||||
nsAutoString codebase;
|
||||
if (NS_SUCCEEDED(GetOrigin(&codebase))) {
|
||||
secMan->NewJSPrincipals(nsnull, nsnull, &codebase, &mPrincipals);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mPrincipals) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (mContext) {
|
||||
JSPRINCIPALS_HOLD((JSContext *)mContext->GetNativeContext(), mPrincipals);
|
||||
}
|
||||
}
|
||||
|
||||
*aPrincipals = (void*)mPrincipals;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::SetPrincipals(void* aPrincipals)
|
||||
{
|
||||
if (mPrincipals && mContext) {
|
||||
JSPRINCIPALS_DROP((JSContext *)mContext->GetNativeContext(), mPrincipals);
|
||||
}
|
||||
|
||||
mPrincipals = (JSPrincipals*)aPrincipals;
|
||||
|
||||
if (mPrincipals && mContext) {
|
||||
JSPRINCIPALS_HOLD((JSContext *)mContext->GetNativeContext(), mPrincipals);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::GetOrigin(nsString* aOrigin)
|
||||
{
|
||||
nsIDocument* doc;
|
||||
if (mDocument && NS_OK == mDocument->QueryInterface(kIDocumentIID, (void**)&doc)) {
|
||||
nsIURI* docURL = doc->GetDocumentURL();
|
||||
if (docURL) {
|
||||
PRUnichar* str;
|
||||
docURL->ToString(&str);
|
||||
*aOrigin = str;
|
||||
delete str;
|
||||
NS_RELEASE(docURL);
|
||||
}
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//Old code from 4.0 to show what funcitonality needs replicating
|
||||
History_entry *he;
|
||||
const char *address;
|
||||
JSContext *aCx;
|
||||
MochaDecoder *decoder;
|
||||
|
||||
he = SHIST_GetCurrent(&context->hist);
|
||||
if (he) {
|
||||
address = he->wysiwyg_url;
|
||||
if (!address)
|
||||
address = he->address;
|
||||
switch (NET_URL_Type(address)) {
|
||||
case MOCHA_TYPE_URL:
|
||||
/* This type cannot name the true origin (server) of JS code. */
|
||||
break;
|
||||
case VIEW_SOURCE_TYPE_URL:
|
||||
NS_ASSERTION(0, "Invalid url type");
|
||||
default:
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
||||
if (context->grid_parent) {
|
||||
address = FindCreatorURL(context->grid_parent);
|
||||
if (address)
|
||||
return address;
|
||||
}
|
||||
|
||||
aCx = context->mocha_context;
|
||||
if (aCx) {
|
||||
decoder = JS_GetPrivate(aCx, JS_GetGlobalObject(aCx));
|
||||
if (decoder && decoder->opener) {
|
||||
/* self.opener property is valid, check its MWContext. */
|
||||
MochaDecoder *opener = JS_GetPrivate(aCx, decoder->opener);
|
||||
if (!opener->visited) {
|
||||
opener->visited = PR_TRUE;
|
||||
address = opener->window_context
|
||||
? FindCreatorURL(opener->window_context)
|
||||
: nsnull;
|
||||
opener->visited = PR_FALSE;
|
||||
if (address)
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" NS_DOM nsresult
|
||||
NS_NewScriptGlobalObject(nsIScriptGlobalObject **aResult)
|
||||
{
|
||||
|
@ -2706,8 +2573,6 @@ NS_NewScriptGlobalObject(nsIScriptGlobalObject **aResult)
|
|||
return global->QueryInterface(kIScriptGlobalObjectIID, (void **)aResult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Navigator class implementation
|
||||
//
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIDOMEventCapturer.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsFrameList.h"
|
||||
#include "nsIScriptGlobalObjectData.h"
|
||||
#include "nsDOMWindowList.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
||||
|
@ -59,8 +57,8 @@ class ScreenImpl;
|
|||
class HistoryImpl;
|
||||
|
||||
// Global object for scripting
|
||||
class GlobalWindowImpl : public nsIScriptObjectOwner, public nsIScriptGlobalObject, public nsIDOMWindow,
|
||||
public nsIJSScriptObject, public nsIDOMEventCapturer, public nsIScriptGlobalObjectData
|
||||
class GlobalWindowImpl : public nsIScriptObjectOwner, public nsIScriptGlobalObject, public nsIDOMWindow,
|
||||
public nsIJSScriptObject, public nsIDOMEventCapturer
|
||||
{
|
||||
public:
|
||||
GlobalWindowImpl();
|
||||
|
@ -203,11 +201,6 @@ public:
|
|||
virtual PRBool Convert(JSContext *aContext, jsval aID);
|
||||
virtual void Finalize(JSContext *aContext);
|
||||
|
||||
// nsIScriptGlobalObjectData interface
|
||||
NS_IMETHOD GetPrincipals(void** aPrincipals);
|
||||
NS_IMETHOD SetPrincipals(void* aPrincipals);
|
||||
NS_IMETHOD GetOrigin(nsString* aOrigin);
|
||||
|
||||
friend void nsGlobalWindow_RunTimeout(nsITimer *aTimer, void *aClosure);
|
||||
|
||||
protected:
|
||||
|
@ -244,8 +237,6 @@ protected:
|
|||
HistoryImpl *mHistory;
|
||||
nsIWebShell *mWebShell;
|
||||
nsIDOMWindow *mOpener;
|
||||
JSPrincipals *mPrincipals;
|
||||
|
||||
BarPropImpl *mMenubar;
|
||||
BarPropImpl *mToolbar;
|
||||
BarPropImpl *mLocationbar;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "nsJSEnvironment.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptGlobalObjectData.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
@ -48,7 +47,6 @@ const size_t gStackSize = 8192;
|
|||
static NS_DEFINE_IID(kIScriptContextIID, NS_ISCRIPTCONTEXT_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectDataIID, NS_ISCRIPTGLOBALOBJECTDATA_IID);
|
||||
static NS_DEFINE_IID(kIScriptNameSetRegistryIID, NS_ISCRIPTNAMESETREGISTRY_IID);
|
||||
static NS_DEFINE_IID(kCScriptNameSetRegistryCID, NS_SCRIPT_NAMESET_REGISTRY_CID);
|
||||
static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID);
|
||||
|
@ -129,23 +127,10 @@ nsJSContext::EvaluateString(const nsString& aScript,
|
|||
PRBool* aIsUndefined)
|
||||
{
|
||||
jsval val;
|
||||
nsIScriptGlobalObject *global = GetGlobalObject();
|
||||
nsIScriptGlobalObjectData *globalData;
|
||||
JSPrincipals* principals = nsnull;
|
||||
|
||||
if (global && NS_SUCCEEDED(global->QueryInterface(kIScriptGlobalObjectDataIID, (void**)&globalData))) {
|
||||
if (NS_FAILED(globalData->GetPrincipals((void**)&principals))) {
|
||||
NS_RELEASE(global);
|
||||
NS_RELEASE(globalData);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(globalData);
|
||||
}
|
||||
NS_IF_RELEASE(global);
|
||||
|
||||
PRBool ret = ::JS_EvaluateUCScriptForPrincipals(mContext,
|
||||
JS_GetGlobalObject(mContext),
|
||||
principals,
|
||||
nsnull,
|
||||
(jschar*)aScript.GetUnicode(),
|
||||
aScript.Length(),
|
||||
aURL,
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -19,52 +19,18 @@
|
|||
#define nsJSSecurityManager_h___
|
||||
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsICapsSecurityCallbacks.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsdbgapi.h"
|
||||
|
||||
class nsICapsManager;
|
||||
class nsIPref;
|
||||
|
||||
typedef struct nsJSFrameIterator {
|
||||
JSStackFrame *fp;
|
||||
JSContext *cx;
|
||||
void *intersect;
|
||||
PRBool sawEmptyPrincipals;
|
||||
} nsJSFrameIterator;
|
||||
|
||||
enum Signedness {
|
||||
HAS_NO_SCRIPTS,
|
||||
HAS_UNSIGNED_SCRIPTS,
|
||||
HAS_SIGNED_SCRIPTS
|
||||
};
|
||||
|
||||
typedef struct nsJSPrincipalsData {
|
||||
JSPrincipals principals;
|
||||
void* principalsArrayRef;
|
||||
nsIURI *url;
|
||||
char* name;
|
||||
void* zip; //ns_zip_t
|
||||
uint32 externalCapturePrincipalsCount;
|
||||
nsString* untransformed;
|
||||
nsString* transformed;
|
||||
PRBool needUnlock;
|
||||
char* codebaseBeforeSettingDomain;
|
||||
enum Signedness signedness;
|
||||
void* pNSISecurityContext;
|
||||
// nsJSSecurityManager* secManager;
|
||||
} nsJSPrincipalsData;
|
||||
|
||||
class nsJSSecurityManager : public nsIScriptSecurityManager,
|
||||
public nsICapsSecurityCallbacks {
|
||||
class nsJSSecurityManager : public nsIScriptSecurityManager {
|
||||
public:
|
||||
nsJSSecurityManager();
|
||||
virtual ~nsJSSecurityManager();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
//nsIScriptSecurityManager interface
|
||||
NS_IMETHOD Init();
|
||||
|
||||
NS_IMETHOD CheckScriptAccess(nsIScriptContext* aContext,
|
||||
|
@ -72,87 +38,7 @@ public:
|
|||
const char* aProp,
|
||||
PRBool* aResult);
|
||||
|
||||
//XXX From lib/libmocha/lm.h
|
||||
NS_IMETHOD GetSubjectOriginURL(JSContext *aCx, nsString* aOrigin);
|
||||
NS_IMETHOD GetObjectOriginURL(JSContext *aCx, JSObject *object, nsString* aOrigin);
|
||||
NS_IMETHOD GetPrincipalsFromStackFrame(JSContext *aCx, JSPrincipals** aPrincipals);
|
||||
NS_IMETHOD GetCompilationPrincipals(nsIScriptContext *aContext, nsIScriptGlobalObject* aGlobal,
|
||||
JSPrincipals *aLayoutPrincipals, JSPrincipals** aPrincipals);
|
||||
NS_IMETHOD CanAccessTarget(JSContext *aCx, eJSTarget target, PRBool* aReturn);
|
||||
NS_IMETHOD CheckPermissions(JSContext *aCx, JSObject *aObj, eJSTarget target, PRBool* aReturn);
|
||||
NS_IMETHOD CheckContainerAccess(JSContext *aCx, JSObject *aObj, eJSTarget aTarget, PRBool* aReturn);
|
||||
NS_IMETHOD GetContainerPrincipals(JSContext *aCx, JSObject *aContainer, JSPrincipals** aPrincipals);
|
||||
NS_IMETHOD SetContainerPrincipals(JSContext *aCx, JSObject *aContainer, JSPrincipals* aPrincipals);
|
||||
NS_IMETHOD CanCaptureEvent(JSContext *aCx, JSFunction *aFun, JSObject *aEventTarget, PRBool* aReturn);
|
||||
NS_IMETHOD SetExternalCapture(JSContext *aCx, JSPrincipals* aPrincipals, PRBool aBool);
|
||||
NS_IMETHOD CheckSetParentSlot(JSContext *aCx, JSObject *aObj, jsval id, jsval *vp, PRBool* aReturn);
|
||||
NS_IMETHOD SetDocumentDomain(JSContext *aCx, JSPrincipals *principals,
|
||||
nsString* newDomain, PRBool* aReturn);
|
||||
NS_IMETHOD DestroyPrincipalsList(JSContext *aCx, nsJSPrincipalsList *list);
|
||||
//XXX End from lib/libmocha/lm.h
|
||||
|
||||
//XXX From include/libmocha.h
|
||||
NS_IMETHOD NewJSPrincipals(nsIURI *aURL, nsString* aName, nsString* aCodebase, JSPrincipals** aPrincipals);
|
||||
#ifdef DO_JAVA_STUFF
|
||||
NS_IMETHOD ExtractFromPrincipalsArchive(JSPrincipals *aPrincipals, char *aName,
|
||||
uint *aLength, char** aReturn);
|
||||
NS_IMETHOD SetUntransformedSource(JSPrincipals *principals, char *original,
|
||||
char *transformed, PRBool* aReturn);
|
||||
NS_IMETHOD GetJSPrincipalsFromJavaCaller(JSContext *aCx, void *principalsArray, void *pNSISecurityContext, JSPrincipals** aPrincipals);
|
||||
#endif
|
||||
#if 0
|
||||
NS_IMETHOD CanAccessTargetStr(JSContext *aCx, const char *target, PRBool* aReturn);
|
||||
#endif
|
||||
NS_IMETHOD RegisterPrincipals(nsIScriptContext *aContext, nsIScriptGlobalObject* aGlobal, JSPrincipals *aPrincipals,
|
||||
nsString* aName, nsString* aSrc, JSPrincipals** aRetPrincipals);
|
||||
//XXX End from include/libmocha.h
|
||||
|
||||
|
||||
//nsICapsSecurityCallbacks interface
|
||||
NS_IMETHOD NewNSJSJavaFrameWrapper(void *aContext, struct nsFrameWrapper ** aWrapper);
|
||||
NS_IMETHOD FreeNSJSJavaFrameWrapper(struct nsFrameWrapper *aWrapper);
|
||||
NS_IMETHOD GetStartFrame(struct nsFrameWrapper *aWrapper);
|
||||
NS_IMETHOD IsEndOfFrame(struct nsFrameWrapper *aWrapper, PRBool* aReturn);
|
||||
NS_IMETHOD IsValidFrame(struct nsFrameWrapper *aWrapper, PRBool* aReturn);
|
||||
NS_IMETHOD GetNextFrame(struct nsFrameWrapper *aWrapper, int *aDepth, void** aReturn);
|
||||
NS_IMETHOD OJIGetPrincipalArray(struct nsFrameWrapper *aWrapper, void** aReturn);
|
||||
NS_IMETHOD OJIGetAnnotation(struct nsFrameWrapper *aWrapper, void** aReturn);
|
||||
NS_IMETHOD OJISetAnnotation(struct nsFrameWrapper *aWrapper, void *aPrivTable, void** aReturn);
|
||||
|
||||
private:
|
||||
void PrintToConsole(const char *data);
|
||||
void PrintPrincipalsToConsole(JSContext *cx, JSPrincipals *principals);
|
||||
|
||||
PRUint32 GetPrincipalsCount(JSContext *aCx, JSPrincipals *aPrincipals);
|
||||
PRBool PrincipalsCanAccessTarget(JSContext *cx, eJSTarget target);
|
||||
void InvalidateCertPrincipals(JSContext *cx, JSPrincipals *principals);
|
||||
|
||||
//Helper funcs for RegisterPrincipals
|
||||
#ifdef EARLY_ACCESS_STUFF
|
||||
PRBool CheckEarlyAccess(MochaDecoder *decoder, JSPrincipals *principals);
|
||||
#endif
|
||||
PRBool IntersectPrincipals(JSContext *aCx, JSPrincipals *principals,
|
||||
JSPrincipals *newPrincipals);
|
||||
PRBool PrincipalsEqual(JSContext *aCx, JSPrincipals *aA, JSPrincipals *aB);
|
||||
|
||||
PRBool IsExternalCaptureEnabled(JSContext *cx, JSPrincipals *principals);
|
||||
PRBool CanExtendTrust(JSContext *cx, void *from, void *to);
|
||||
char* GetJavaCodebaseFromOrigin(const char *origin);
|
||||
|
||||
nsString* GetOriginFromSourceURL(nsString* sourceURL);
|
||||
char* FindOriginURL(JSContext *aCx, JSObject *aGlobal);
|
||||
|
||||
PRBool SameOrigins(JSContext *aCx, const char* aOrigin1, const char* aOrigin2);
|
||||
PRBool SameOriginsStr(JSContext *aCx, nsString* aOrigin1, nsString* aOrigin2);
|
||||
nsString* GetCanonicalizedOrigin(JSContext *cx, nsString* aUrlString);
|
||||
|
||||
// Glue code for JS stack crawling callbacks
|
||||
nsJSFrameIterator* NewJSFrameIterator(void *aContext);
|
||||
PRBool NextJSJavaFrame(struct nsJSFrameIterator *aIterator);
|
||||
PRBool NextJSFrame(struct nsJSFrameIterator **aIterator);
|
||||
|
||||
void InitCaps(void);
|
||||
|
||||
//Helper funcs
|
||||
char* AddSecPolicyPrefix(JSContext *cx, char *pref_str);
|
||||
char* GetSitePolicy(const char *org);
|
||||
|
@ -167,9 +53,15 @@ private:
|
|||
|
||||
//Local vars
|
||||
nsIPref* mPrefs;
|
||||
nsICapsManager* mCapsManager;
|
||||
};
|
||||
|
||||
|
||||
#define NS_SECURITY_FLAG_SAME_ORIGINS 0x0001
|
||||
#define NS_SECURITY_FLAG_NO_ACCESS 0x0002
|
||||
#define NS_SECURITY_FLAG_READ_ONLY 0x0004
|
||||
//xxx break into privilege levels
|
||||
#define NS_SECURITY_FLAG_SIGNED 0x0008
|
||||
|
||||
//XXX temporarily bit flags for determining what we want to parse from the URL
|
||||
#define GET_ALL_PARTS 127
|
||||
#define GET_PASSWORD_PART 64
|
||||
|
|
|
@ -29,7 +29,7 @@ LIBRARY_NAME = jsdom
|
|||
|
||||
MODULE=dom
|
||||
|
||||
REQUIRES=xpcom raptor caps oji
|
||||
REQUIRES=xpcom raptor
|
||||
|
||||
CPPSRCS=nsDOMFactory.cpp \
|
||||
nsHTMLTagsEnums.cpp \
|
||||
|
|
|
@ -20,7 +20,7 @@ DEPTH=..\..\..
|
|||
DEFINES=-D_IMPL_NS_DOM
|
||||
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor dom caps oji
|
||||
REQUIRES=xpcom raptor dom
|
||||
|
||||
CPPSRCS = nsDOMFactory.cpp \
|
||||
nsHTMLTagsEnums.cpp \
|
||||
|
@ -57,8 +57,6 @@ MISCDEP = \
|
|||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\plds3.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\caps.lib \
|
||||
$(DIST)\lib\oji.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
LCFLAGS = \
|
||||
|
@ -85,8 +83,6 @@ LLIBS= \
|
|||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\plds3.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
$(DIST)\lib\caps.lib \
|
||||
$(DIST)\lib\oji.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -38,14 +38,11 @@
|
|||
#include "nsIScriptEventListener.h"
|
||||
#include "nsDOMEventsIIDs.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptGlobalObjectData.h"
|
||||
|
||||
static NS_DEFINE_IID(kIEventListenerManagerIID, NS_IEVENTLISTENERMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventListenerIID, NS_IDOMEVENTLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIDOMEventIID, NS_IDOMEVENT_IID);
|
||||
static NS_DEFINE_IID(kIScriptEventListenerIID, NS_ISCRIPTEVENTLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectDataIID, NS_ISCRIPTGLOBALOBJECTDATA_IID);
|
||||
|
||||
nsEventListenerManager::nsEventListenerManager()
|
||||
{
|
||||
|
@ -416,20 +413,6 @@ nsresult nsEventListenerManager::AddScriptEventListener(nsIScriptContext* aConte
|
|||
nsIAtom *aName, const nsString& aFunc, REFNSIID aIID)
|
||||
{
|
||||
JSObject *mScriptObject;
|
||||
nsIScriptGlobalObject *global;
|
||||
nsIScriptGlobalObjectData *globalData;
|
||||
JSPrincipals* principals = nsnull;
|
||||
|
||||
global = aContext->GetGlobalObject();
|
||||
if (global && NS_SUCCEEDED(global->QueryInterface(kIScriptGlobalObjectDataIID, (void**)&globalData))) {
|
||||
if (NS_FAILED(globalData->GetPrincipals((void**)&principals))) {
|
||||
NS_RELEASE(global);
|
||||
NS_RELEASE(globalData);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(globalData);
|
||||
}
|
||||
NS_IF_RELEASE(global);
|
||||
|
||||
if (NS_OK == aScriptObjectOwner->GetScriptObject(aContext, (void**)&mScriptObject)) {
|
||||
JSContext* mJSContext = (JSContext*)aContext->GetNativeContext();
|
||||
|
@ -440,9 +423,8 @@ nsresult nsEventListenerManager::AddScriptEventListener(nsIScriptContext* aConte
|
|||
mName.ToLowerCase(mLowerName);
|
||||
mCharName = mLowerName.ToNewCString();
|
||||
|
||||
|
||||
if (nsnull != mCharName) {
|
||||
JS_CompileUCFunctionForPrincipals(mJSContext, mScriptObject, principals, mCharName,
|
||||
JS_CompileUCFunction(mJSContext, mScriptObject, mCharName,
|
||||
1, mEventArgv, (jschar*)aFunc.GetUnicode(), aFunc.Length(),
|
||||
nsnull, 0);
|
||||
delete[] mCharName;
|
||||
|
|
Загрузка…
Ссылка в новой задаче