diff --git a/dom/tests/mochitest/bugs/Makefile.in b/dom/tests/mochitest/bugs/Makefile.in index 6f39e72957ef..62eaf858addc 100644 --- a/dom/tests/mochitest/bugs/Makefile.in +++ b/dom/tests/mochitest/bugs/Makefile.in @@ -144,6 +144,7 @@ _TEST_FILES = \ test_bug648465.html \ test_bug654137.html \ test_bug684544.html \ + test_bug698551.html \ test_window_bar.html \ file_window_bar.html \ test_resize_move_windows.html \ diff --git a/dom/tests/mochitest/bugs/test_bug698551.html b/dom/tests/mochitest/bugs/test_bug698551.html new file mode 100644 index 000000000000..70a002bb97b9 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug698551.html @@ -0,0 +1,39 @@ + + + +
++ ++ + diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 0c670ffe01b1..1f1ef983e993 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -3833,11 +3833,18 @@ JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, siz JS_PUBLIC_API(JSBool) JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp) +{ + return JS_ForwardGetPropertyTo(cx, obj, id, obj, vp); +} + +JS_PUBLIC_API(JSBool) +JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id, JSObject *onBehalfOf, jsval *vp) { CHECK_REQUEST(cx); assertSameCompartment(cx, obj, id); + assertSameCompartment(cx, onBehalfOf); JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED); - return obj->getGeneric(cx, id, vp); + return obj->getGeneric(cx, onBehalfOf, id, vp); } JS_PUBLIC_API(JSBool) @@ -3848,12 +3855,17 @@ JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, jsva JS_PUBLIC_API(JSBool) JS_GetElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp) +{ + return JS_ForwardGetElementTo(cx, obj, index, obj, vp); +} + +JS_PUBLIC_API(JSBool) +JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32 index, JSObject *onBehalfOf, jsval *vp) { CHECK_REQUEST(cx); - jsid id; - if (!IndexToId(cx, index, &id)) - return false; - return JS_GetPropertyById(cx, obj, id, vp); + assertSameCompartment(cx, obj); + JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED); + return obj->getElement(cx, onBehalfOf, index, vp); } JS_PUBLIC_API(JSBool) @@ -3909,10 +3921,9 @@ JS_PUBLIC_API(JSBool) JS_SetElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp) { CHECK_REQUEST(cx); - jsid id; - if (!IndexToId(cx, index, &id)) - return false; - return JS_SetPropertyById(cx, obj, INT_TO_JSID(index), vp); + assertSameCompartment(cx, obj); + JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING); + return obj->setElement(cx, index, vp, false); } JS_PUBLIC_API(JSBool) diff --git a/js/src/jsapi.h b/js/src/jsapi.h index f004601d852d..9641cf841a08 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3431,6 +3431,9 @@ JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, jsval *vp); +extern JS_PUBLIC_API(JSBool) +JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id, JSObject *onBehalfOf, jsval *vp); + extern JS_PUBLIC_API(JSBool) JS_GetMethodById(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, jsval *vp); @@ -3563,6 +3566,9 @@ JS_LookupElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp); extern JS_PUBLIC_API(JSBool) JS_GetElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp); +extern JS_PUBLIC_API(JSBool) +JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32 index, JSObject *onBehalfOf, jsval *vp); + extern JS_PUBLIC_API(JSBool) JS_SetElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp); diff --git a/js/xpconnect/src/dombindings.cpp b/js/xpconnect/src/dombindings.cpp index b1f38681622b..55f120594e90 100644 --- a/js/xpconnect/src/dombindings.cpp +++ b/js/xpconnect/src/dombindings.cpp @@ -975,7 +975,7 @@ ListBase