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

RESOLVED FIXED in mozilla13

Status

()

Core
JavaScript Engine
RESOLVED FIXED
7 years ago
5 years ago

People

(Reporter: jimb, Assigned: jorendorff)

Tracking

(Blocks: 1 bug)

unspecified
mozilla13
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

7 years ago
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.
(Reporter)

Updated

7 years ago
Summary: Watchpoints set on setters do not trigger → Watchpoints set on setters do not always trigger
(Reporter)

Comment 1

7 years ago
Created attachment 483622 [details]
Test case.
(Reporter)

Comment 2

7 years ago
<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
(Reporter)

Comment 3

7 years ago
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!
(Reporter)

Updated

7 years ago
Summary: Watchpoints set on setters do not always trigger → Watchpoints set on setters do not always trigger; and, zombie setters!
(Reporter)

Updated

7 years ago
Blocks: 609924
(Assignee)

Updated

6 years ago
Depends on: 637985
(Assignee)

Comment 4

6 years ago
Created attachment 527673 [details] [diff] [review]
v1

This fix applies on top of bug 637985. Will request review once that one is ready.
Assignee: general → jorendorff
(Assignee)

Updated

6 years ago
Attachment #527673 - Flags: review?(jimb)
(Assignee)

Comment 5

5 years ago
Created attachment 595532 [details] [diff] [review]
v2

Unbitrotted. Let's get this in.
Attachment #527673 - Attachment is obsolete: true
Attachment #595532 - Flags: review?(jimb)
Attachment #527673 - Flags: review?(jimb)
(Assignee)

Comment 6

5 years ago
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.
(Reporter)

Updated

5 years ago
Attachment #595532 - Flags: review?(jimb) → review+
(Assignee)

Comment 7

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/502b21011c3e
https://hg.mozilla.org/mozilla-central/rev/502b21011c3e
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
You need to log in before you can comment on or make changes to this bug.