Report an error when trying to watch an E4X property with a qualified name, rather than set a watchpoint that will not hit reliably. Bug 691746, r=jimb.

This commit is contained in:
Jason Orendorff 2011-10-24 10:51:52 -05:00
Родитель c631916068
Коммит 4bfbc87471
5 изменённых файлов: 19 добавлений и 1 удалений

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

@ -370,3 +370,4 @@ MSG_DEF(JSMSG_DEBUG_BAD_LINE, 283, 0, JSEXN_TYPEERR, "invalid line numbe
MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGING, 284, 0, JSEXN_ERR, "can't set breakpoint: script global is not a debuggee")
MSG_DEF(JSMSG_DEBUG_COMPARTMENT_MISMATCH, 285, 2, JSEXN_TYPEERR, "{0}: descriptor .{1} property is an object in a different compartment than the target object")
MSG_DEF(JSMSG_DEBUG_NOT_SCRIPT_FRAME, 286, 0, JSEXN_ERR, "stack frame is not running JavaScript code")
MSG_DEF(JSMSG_CANT_WATCH_PROP, 287, 0, JSEXN_TYPEERR, "properties whose names are objects can't be watched")

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

@ -297,6 +297,9 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id,
AutoValueRooter idroot(cx);
if (JSID_IS_INT(id)) {
propid = id;
} else if (JSID_IS_OBJECT(id)) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_WATCH_PROP);
return false;
} else {
if (!js_ValueToStringId(cx, IdToValue(id), &propid))
return false;
@ -328,7 +331,7 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id,
}
cx->compartment->watchpointMap = wpmap;
}
return wpmap->watch(cx, obj, id, handler, closure);
return wpmap->watch(cx, obj, propid, handler, closure);
}
JS_PUBLIC_API(JSBool)

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

@ -84,6 +84,8 @@ WatchpointMap::watch(JSContext *cx, JSObject *obj, jsid id,
JSWatchPointHandler handler, JSObject *closure)
{
JS_ASSERT(id == js_CheckForStringIndex(id));
JS_ASSERT(JSID_IS_STRING(id) || JSID_IS_INT(id));
obj->setWatched(cx);
Watchpoint w;
w.handler = handler;

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

@ -58,3 +58,4 @@ require-or(debugMode,skip) script regress-672804-2.js
require-or(debugMode,skip) script regress-672804-3.js
skip-if(!xulRuntime.shell) script regress-677589.js
script regress-677924.js
script regress-691746.js

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

@ -0,0 +1,11 @@
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/
var obj = {};
try {
obj.watch(QName(), function () {});
} catch (exc) {
}
gc();
reportCompare(0, 0, 'ok');