Closed
Bug 542864
Opened 14 years ago
Closed 14 years ago
with js -z, getters don't resolve correctly against the split global object
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: smparkes, Assigned: mrbkap)
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file)
971 bytes,
patch
|
mrbkap
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 GTB7.0 Build Identifier: Gettters don't seem to resolve correctly against the global split object in the shell. Exceuting this code in the shell works fine with a normal global and fails in the second lookup with a split global: this.__defineGetter__("foo",function(){return"fooy";}); a = this.foo; b = foo; Reproducible: Always
Assignee | ||
Updated•14 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Reporter | ||
Comment 1•14 years ago
|
||
This patch works. I think it might not be quite right; there are subtitles here I'm not 100% on. But I think it might be close, so: http://gist.github.com/298781 I'm not sure about the setting of the global object part of the diff. I mostly left it in to remind me to ask; I haven't seen anywhere where it makes a difference, but the tests I've been running don't rebind outer. My thoughts were based upon http://groups.google.com/group/mozilla.dev.tech.js-engine/msg/df81825b338fb84f the wording "Every web page has a global object. This is an inner window, and has the same lifetime as the page" in particular. But I'm not sure it matters. I'm not sure I see any place the global object is accessible since inner overrides the scope "this" to point to outer. I think. This stuff makes my head hurt. Here's the test I use http://gist.github.com/298789
Reporter | ||
Comment 2•14 years ago
|
||
You know, I thought this looked strange (the asId stuff). Pretty sure the - return JS_DefinePropertyById(cx, cpx->inner, asId, *vp, NULL, NULL, JSPROP_ENUMERATE); In the original should have been - return JS_DefinePropertyById(cx, cpx->inner, id, asId, NULL, NULL, JSPROP_ENUMERATE); even without the getter/setter support. Now I know why all my values where showing up as keys ... So the current version for me is static JSBool split_addProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { ComplexObject *cpx; jsid asId; cpx = split_get_private(cx, obj); if (!cpx) return JS_TRUE; if (!cpx->isInner && cpx->inner) { /* Make sure to define this property on the inner object. */ /* Patched. See https://bugzilla.mozilla.org/show_bug.cgi?id=542864 */ JSPropertyOp setter = 0; JSPropertyOp getter = 0; uintN attrs = 0; JSBool found; JS_GetPropertyAttrsGetterAndSetterById(cx, obj, id, &attrs, &found, &getter, &setter); if (!JS_ValueToId(cx, *vp, &asId)) { return JS_FALSE; } return JS_DefinePropertyById(cx, cpx->inner, id, asId, getter, setter, attrs | JSPROP_ENUMERATE); } return JS_TRUE; }
Assignee | ||
Comment 3•14 years ago
|
||
You were close, but this is the fix. A really stupid typo if I've ever made one.
Assignee: general → mrbkap
Attachment #429610 -
Flags: review+
Assignee | ||
Comment 4•14 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/7af412b6d23f
Whiteboard: fixed-in-tracemonkey
Reporter | ||
Comment 5•14 years ago
|
||
Ah. Right. I see that. But that doesn't seem to address the actual root issue regarding getters/setters, does it? Did I miss something? This http://gist.github.com/298789 still seems to generate the wrong result w/o the JS_GetPropertyAttrsGetterAndSetterById?
Reporter | ||
Updated•14 years ago
|
Summary: with js -z, getters don't resolve correctly against the global object → with js -z, getters don't resolve correctly against the split global object
Comment 6•14 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/7af412b6d23f
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 7•14 years ago
|
||
The test in the original description does seem to work against tip, but the more extensive case that I put in later (at http://gist.github.com/298789) still seems to fail with -z (but works w/o -z). It shouldn't print anything. I could reopen this. Or open a new bug. Or go away. :)
You need to log in
before you can comment on or make changes to this bug.
Description
•