зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 9787. Implemented a stub version of document.clear. Fix necessary for getting in 20737. a=chofmann r=pollmann.
This commit is contained in:
Родитель
f05a2f0ff4
Коммит
657729a882
|
@ -74,6 +74,8 @@ public:
|
|||
|
||||
NS_IMETHOD Writeln(JSContext* cx, jsval* argv, PRUint32 argc)=0;
|
||||
|
||||
NS_IMETHOD Clear()=0;
|
||||
|
||||
NS_IMETHOD CaptureEvents(PRInt32 aEventFlags)=0;
|
||||
|
||||
NS_IMETHOD ReleaseEvents(PRInt32 aEventFlags)=0;
|
||||
|
@ -102,6 +104,7 @@ public:
|
|||
NS_IMETHOD Open(JSContext* cx, jsval* argv, PRUint32 argc); \
|
||||
NS_IMETHOD Write(JSContext* cx, jsval* argv, PRUint32 argc); \
|
||||
NS_IMETHOD Writeln(JSContext* cx, jsval* argv, PRUint32 argc); \
|
||||
NS_IMETHOD Clear(); \
|
||||
NS_IMETHOD CaptureEvents(PRInt32 aEventFlags); \
|
||||
NS_IMETHOD ReleaseEvents(PRInt32 aEventFlags); \
|
||||
NS_IMETHOD RouteEvent(nsIDOMEvent* aEvt); \
|
||||
|
@ -128,6 +131,7 @@ public:
|
|||
NS_IMETHOD Open(JSContext* cx, jsval* argv, PRUint32 argc) { return _to Open(cx, argv, argc); } \
|
||||
NS_IMETHOD Write(JSContext* cx, jsval* argv, PRUint32 argc) { return _to Write(cx, argv, argc); } \
|
||||
NS_IMETHOD Writeln(JSContext* cx, jsval* argv, PRUint32 argc) { return _to Writeln(cx, argv, argc); } \
|
||||
NS_IMETHOD Clear() { return _to Clear(); } \
|
||||
NS_IMETHOD CaptureEvents(PRInt32 aEventFlags) { return _to CaptureEvents(aEventFlags); } \
|
||||
NS_IMETHOD ReleaseEvents(PRInt32 aEventFlags) { return _to ReleaseEvents(aEventFlags); } \
|
||||
NS_IMETHOD RouteEvent(nsIDOMEvent* aEvt) { return _to RouteEvent(aEvt); } \
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
void open(/* ... */);
|
||||
void write(/* ... */);
|
||||
void writeln(/* ... */);
|
||||
void clear();
|
||||
|
||||
void captureEvents(in long eventFlags);
|
||||
void releaseEvents(in long eventFlags);
|
||||
|
|
|
@ -676,6 +676,7 @@ enum nsDOMProp {
|
|||
NS_DOM_PROP_NSHTMLDOCUMENT_ALINKCOLOR,
|
||||
NS_DOM_PROP_NSHTMLDOCUMENT_BGCOLOR,
|
||||
NS_DOM_PROP_NSHTMLDOCUMENT_CAPTUREEVENTS,
|
||||
NS_DOM_PROP_NSHTMLDOCUMENT_CLEAR,
|
||||
NS_DOM_PROP_NSHTMLDOCUMENT_EMBEDS,
|
||||
NS_DOM_PROP_NSHTMLDOCUMENT_FGCOLOR,
|
||||
NS_DOM_PROP_NSHTMLDOCUMENT_GETSELECTION,
|
||||
|
|
|
@ -852,7 +852,7 @@ HTMLDocumentClose(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLDOCUMENT_CLOSE,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLDOCUMENT_CLOSE, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -897,7 +897,7 @@ HTMLDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLDOCUMENT_GETELEMENTBYID,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLDOCUMENT_GETELEMENTBYID, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -947,7 +947,7 @@ HTMLDocumentGetElementsByName(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLDOCUMENT_GETELEMENTSBYNAME,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLDOCUMENT_GETELEMENTSBYNAME, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ NSHTMLDocumentGetSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_GETSELECTION,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_GETSELECTION, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -1051,7 +1051,7 @@ NSHTMLDocumentNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_NAMEDITEM,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_NAMEDITEM, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -1104,7 +1104,7 @@ NSHTMLDocumentOpen(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_OPEN,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_OPEN, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -1152,7 +1152,7 @@ NSHTMLDocumentWrite(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_WRITE,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_WRITE, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -1200,7 +1200,7 @@ NSHTMLDocumentWriteln(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_WRITELN,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_WRITELN, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -1225,6 +1225,54 @@ NSHTMLDocumentWriteln(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Clear
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NSHTMLDocumentClear(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMHTMLDocument *privateThis = (nsIDOMHTMLDocument*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMNSHTMLDocument *nativeThis = nsnull;
|
||||
nsresult result = NS_OK;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLDocumentIID, (void **)&nativeThis)) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR);
|
||||
}
|
||||
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(getter_AddRefs(secMan))) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECMAN_ERR);
|
||||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_CLEAR, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
result = nativeThis->Clear();
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, result);
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method CaptureEvents
|
||||
//
|
||||
|
@ -1249,7 +1297,7 @@ NSHTMLDocumentCaptureEvents(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_CAPTUREEVENTS,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_CAPTUREEVENTS, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -1305,7 +1353,7 @@ NSHTMLDocumentReleaseEvents(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_RELEASEEVENTS,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_RELEASEEVENTS, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -1361,7 +1409,7 @@ NSHTMLDocumentRouteEvent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
}
|
||||
{
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_ROUTEEVENT,PR_FALSE , &ok);
|
||||
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLDOCUMENT_ROUTEEVENT, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -1457,6 +1505,7 @@ static JSFunctionSpec HTMLDocumentMethods[] =
|
|||
{"open", NSHTMLDocumentOpen, 0},
|
||||
{"write", NSHTMLDocumentWrite, 0},
|
||||
{"writeln", NSHTMLDocumentWriteln, 0},
|
||||
{"clear", NSHTMLDocumentClear, 0},
|
||||
{"captureEvents", NSHTMLDocumentCaptureEvents, 1},
|
||||
{"releaseEvents", NSHTMLDocumentReleaseEvents, 1},
|
||||
{"routeEvent", NSHTMLDocumentRouteEvent, 1},
|
||||
|
|
Загрузка…
Ссылка в новой задаче