Bug 388665 Javascript interferes with STATE_EDITABLE

r=aaronleventhal sr=bzbarsky
This commit is contained in:
ginn.chen%sun.com 2007-07-25 06:24:00 +00:00
Родитель e103411cfc
Коммит 533388e4cf
2 изменённых файлов: 18 добавлений и 0 удалений

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

@ -54,6 +54,7 @@ REQUIRES = content \
gfx \ gfx \
imglib2 \ imglib2 \
intl \ intl \
js \
layout \ layout \
locale \ locale \
necko \ necko \
@ -61,6 +62,7 @@ REQUIRES = content \
webshell \ webshell \
widget \ widget \
xpcom \ xpcom \
xpconnect \
$(NULL) $(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2) ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)

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

@ -51,6 +51,9 @@
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsINameSpaceManager.h" #include "nsINameSpaceManager.h"
#include "nsISelectionController.h" #include "nsISelectionController.h"
#include "jsapi.h"
#include "nsIJSContextStack.h"
#include "nsIServiceManager.h"
#include "nsITextControlFrame.h" #include "nsITextControlFrame.h"
// --- checkbox ----- // --- checkbox -----
@ -556,11 +559,24 @@ void nsHTMLTextFieldAccessible::CheckForEditor()
return; return;
} }
// nsGenericHTMLElement::GetEditor has a security check.
// Make sure we're not restricted by the permissions of
// whatever script is currently running.
nsCOMPtr<nsIJSContextStack> stack =
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
PRBool pushed = stack && NS_SUCCEEDED(stack->Push(nsnull));
nsCOMPtr<nsIEditor> editor; nsCOMPtr<nsIEditor> editor;
nsresult rv = editableElt->GetEditor(getter_AddRefs(editor)); nsresult rv = editableElt->GetEditor(getter_AddRefs(editor));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
SetEditor(editor); SetEditor(editor);
} }
if (pushed) {
JSContext* cx;
stack->Pop(&cx);
NS_ASSERTION(!cx, "context should be null");
}
} }
// --- groupbox ----- // --- groupbox -----