Closed Bug 604781 Opened 9 years ago Closed 8 years ago

Watchpoints set on setters do not always trigger; and, zombie setters!

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: jimb, Assigned: jorendorff)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 1 obsolete file)

Depending on the details of how the property is defined, watchpoints on setter properties may not trigger. In particular, a watchpoint set on p.x does trigger:

var p = { set x(v) { setter(v); } };

But a watchpoint set on o.x does not:

var o = Object.defineProperty({}, 'x', { set:setter, enumerable:true, configurable:true });

The two should be identical, except for the specific setter function.
Summary: Watchpoints set on setters do not trigger → Watchpoints set on setters do not always trigger
Attached file Test case.
<jorendorff> jimb: In the second case, the property so defined is
             JSPROP_READONLY  [14:45]
<jorendorff> jimb: which i think is nonsense, and we rightly ignore it in most
             places, but perhaps not in the watch_setter
Here's another lovely bit of behavior:

function watcher(id,old,newval) { print("assignment watched"); return newval; }
var o = { set x(v) { print("setting x"); } };
o.watch('x', watcher);
Object.defineProperty(o, 'x', { value:3,
                                writable:true,
                                enumerable:true,
                                configurable:true });
o.x = 3;

Both the watchpoint and the setter run!
Summary: Watchpoints set on setters do not always trigger → Watchpoints set on setters do not always trigger; and, zombie setters!
Blocks: 609924
Depends on: 637985
Attached patch v1 (obsolete) — Splinter Review
This fix applies on top of bug 637985. Will request review once that one is ready.
Assignee: general → jorendorff
Attachment #527673 - Flags: review?(jimb)
Attached patch v2Splinter Review
Unbitrotted. Let's get this in.
Attachment #527673 - Attachment is obsolete: true
Attachment #595532 - Flags: review?(jimb)
Attachment #527673 - Flags: review?(jimb)
Incidentally the tests pass even without the change to obj_watch, I think because that property is not JSPROP_READONLY anymore; but there is no point having a line of code in obj_watch that doesn't do anything.
Attachment #595532 - Flags: review?(jimb) → review+
https://hg.mozilla.org/mozilla-central/rev/502b21011c3e
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
You need to log in before you can comment on or make changes to this bug.