Closed
Bug 355145
Opened 18 years ago
Closed 18 years ago
JS_GetMethodById() on XML objects no longer works
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
VERIFIED
FIXED
People
(Reporter: sync2d, Assigned: igor)
References
Details
(Keywords: regression, verified1.8.1)
Attachments
(1 file, 3 obsolete files)
2.14 KB,
patch
|
mtschrep
:
approval1.8.1+
|
Details | Diff | Splinter Review |
regression from bug 355075.
var obj = <x/>, exp = "foo", act;
obj.function::__iterator__ = function() { yield exp; };
for(var val in obj) act = val;
print("expect: " + exp);
print("actual: " + act);
jsapi.c rev 3.280:
expect: foo
actual: foo
jsapi.c rev 3.281:
expect: foo
actual: undefined
Assignee | ||
Updated•18 years ago
|
Assignee: general → igor.bukanov
Assignee | ||
Comment 1•18 years ago
|
||
Instead of reintroducing __iterator__ for XML which would require special checks to ensure that it is a default iterator, the fix calls js_LookupProperty on XML objects.
Attachment #241054 -
Flags: review?(brendan)
Comment 2•18 years ago
|
||
Comment on attachment 241054 [details] [diff] [review]
Fix v1
>+ /*
>+ * The function should not give any warnings if the method does not exist.
>+ * Hence we do extra OBJ_LOOKUP_PROPERTY to check for that as otherwise
>+ * OBJ_GET_PROPERTY when it calls js_GetProperty would produce a warning,
>+ * see bug 355075.
>+ *
>+ * For XML case we use js_LookupProperty since there OBJ_LOOKUP_PROPERTY
>+ * query property namespace, not function namespace, see bug 355145.
Nit: full stop, then "See bug ..." instead of ", see bug ..." run-ons.
>+ */
> #if JS_HAS_XML_SUPPORT
> if (OBJECT_IS_XML(cx, obj)) {
> JSXMLObjectOps *ops;
>
>- ops = (JSXMLObjectOps *) obj->map->ops;
>- obj = ops->getMethod(cx, obj, id, vp);
>- if (!obj)
>+ if (!js_LookupProperty(cx, obj, id, &obj2, &prop))
> return JS_FALSE;
>+ if (!prop) {
>+ *vp = JSVAL_VOID;
>+ } else {
>+ /* No OBJ_DROP_PROPERTY as js_LookupProperty does not have one. */
js_LookupProperty does leave obj2 locked on return with prop non-null, so you do need JS_UNLOCK_OBJ(cx, obj2) if not OBJ_DROP_PROPERTY here. Bypassing JSObjectOps via js_LookupProperty suggests using the same style and calling JS_UNLOCK_OBJ(cx, obj2).
>+ ops = (JSXMLObjectOps *) obj->map->ops;
>+ obj = ops->getMethod(cx, obj, id, vp);
>+ if (!obj)
>+ return JS_FALSE;
>+ }
/be
Assignee | ||
Comment 3•18 years ago
|
||
I was so wrong about DROP_PROPERTY up to now. My impression was that JSObject does not define own method since the macro explicitly checks for null. In fact js_ObjectOps speaks quite loudly about js_DropProperty.
Attachment #241054 -
Attachment is obsolete: true
Attachment #241076 -
Flags: review?(brendan)
Attachment #241054 -
Flags: review?(brendan)
(In reply to comment #3)
> Created an attachment (id=241076) [edit]
> Fix v2
This will not work because XML/XMLList object may delegate
the method invocation to the XML/string object it contains.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/js/src/jsxml.c&rev=3.126&cvsroot=/cvsroot#5251
Assignee | ||
Comment 5•18 years ago
|
||
(In reply to comment #4)
> (In reply to comment #3)
> > Created an attachment (id=241076) [edit]
> > Fix v2
>
> This will not work because XML/XMLList object may delegate
> the method invocation to the XML/string object it contains.
Very good point. So the best way to fix this would be to suppress the warning in js_GetProperty but for now I suggest to leave the bug open as a rather obscure problem.
Comment 6•18 years ago
|
||
The warning can be avoided in js_GetProperty with some ingenuity. The cost of an added test there is small, and should be born only by those who turn on the strict option.
/be
Assignee | ||
Comment 7•18 years ago
|
||
(In reply to comment #6)
> The warning can be avoided in js_GetProperty with some ingenuity. The cost of
> an added test there is small, and should be born only by those who turn on the
> strict option.
A trivial hack: do not warn about __iterator__ property.
Comment 8•18 years ago
|
||
(In reply to comment #7)
> (In reply to comment #6)
> > The warning can be avoided in js_GetProperty with some ingenuity. The cost of
> > an added test there is small, and should be born only by those who turn on the
> > strict option.
>
> A trivial hack: do not warn about __iterator__ property.
Sure.
/be
Comment 9•18 years ago
|
||
Given that trivial fix to js_GetProperty, jsapi.c can go back to rev 3.280.
/be
Assignee | ||
Comment 10•18 years ago
|
||
This stops warnings about __iterator__ in js_GetProperty and reverts jsapi.c to the state before the commit from bug 355075.
Attachment #241076 -
Attachment is obsolete: true
Attachment #241110 -
Flags: review?(brendan)
Attachment #241076 -
Flags: review?(brendan)
Comment 11•18 years ago
|
||
Comment on attachment 241110 [details] [diff] [review]
Fix v3
>+ * XXX: do not warn about missing __iterator__ as the function
Ultra-nit: XXX doesn't need a : after it.
Very safe fix to a last-minute regression for 1.8.1 if there's still time, else for 1.8.1.1.
/be
Attachment #241110 -
Flags: review?(brendan)
Attachment #241110 -
Flags: review+
Attachment #241110 -
Flags: approval1.8.1?
Assignee | ||
Comment 12•18 years ago
|
||
Patch to commit with comment text fix.
Comment 13•18 years ago
|
||
Looking for blocking1.8.1- and blocking1.8.1.1+, or ideally blocking1.8.1+ and remove the blocking1.8.1.1? nomination.
/be
Flags: blocking1.8.1?
Flags: blocking1.8.1.1?
Assignee | ||
Comment 14•18 years ago
|
||
I committed the patch from comment 12 to the trunk:
Checking in jsapi.c;
/cvsroot/mozilla/js/src/jsapi.c,v <-- jsapi.c
new revision: 3.282; previous revision: 3.281
done
Checking in jsobj.c;
/cvsroot/mozilla/js/src/jsobj.c,v <-- jsobj.c
new revision: 3.291; previous revision: 3.290
done
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•18 years ago
|
Attachment #241110 -
Attachment is obsolete: true
Attachment #241110 -
Flags: approval1.8.1?
Assignee | ||
Comment 15•18 years ago
|
||
Comment on attachment 241119 [details] [diff] [review]
Fix v3b
Asking approval for the committed patch.
Attachment #241119 -
Flags: approval1.8.1?
Comment 16•18 years ago
|
||
Checking in regress-355145.js;
/cvsroot/mozilla/js/tests/js1_7/regress/regress-355145.js,v <-- regress-355145.js
initial revision: 1.1
done
Flags: in-testsuite+
Comment 17•18 years ago
|
||
we already have respun RC2 bits in hand, will get this into 1.8.1.1
Flags: blocking1.8.1?
Flags: blocking1.8.1.1?
Flags: blocking1.8.1.1+
Flags: blocking1.8.1-
Comment 18•18 years ago
|
||
Comment on attachment 241119 [details] [diff] [review]
Fix v3b
please renom once there's a 1.8.1.1 flag
Attachment #241119 -
Flags: approval1.8.1?
Comment 19•18 years ago
|
||
(In reply to comment #18)
> (From update of attachment 241119 [details] [diff] [review] [edit])
> please renom once there's a 1.8.1.1 flag
Let's have that flag sooner rather than later, eh?
/be
Assignee | ||
Updated•18 years ago
|
Attachment #241119 -
Flags: approval1.8.1?
Comment 20•18 years ago
|
||
Comment on attachment 241119 [details] [diff] [review]
Fix v3b
Annnd, stay down. Igor, please nominate this for 1.8.1.1 when the flag comes into existence.
Attachment #241119 -
Flags: approval1.8.1? → approval1.8.1-
Updated•18 years ago
|
Attachment #241119 -
Flags: approval1.8.1- → approval1.8.1.1?
Assignee | ||
Comment 22•18 years ago
|
||
*** Bug 356129 has been marked as a duplicate of this bug. ***
Updated•18 years ago
|
Keywords: regression
Assignee | ||
Comment 23•18 years ago
|
||
*** Bug 355913 has been marked as a duplicate of this bug. ***
Assignee | ||
Comment 24•18 years ago
|
||
Given that this already got 2 dups, I suggest to reconsider this for 1.8.1. The patch effectively restore JS_GetMethodById to the state it had before all the rest patch flood and ads very safe check not to warn about __iterator__.
Flags: blocking1.8.1- → blocking1.8.1?
Assignee | ||
Comment 25•18 years ago
|
||
Comment on attachment 241119 [details] [diff] [review]
Fix v3b
Nominating for 1.8.1 to avoid more bug reports about the strict warning before 1.8.1.1
Attachment #241119 -
Flags: approval1.8.1?
Assignee | ||
Comment 26•18 years ago
|
||
*** Bug 355913 has been marked as a duplicate of this bug. ***
No longer blocks: 355913
Comment 27•18 years ago
|
||
Comment on attachment 241119 [details] [diff] [review]
Fix v3b
Approved for RC3.
Attachment #241119 -
Flags: approval1.8.1? → approval1.8.1+
Updated•18 years ago
|
Flags: blocking1.8.1? → blocking1.8.1+
Assignee | ||
Comment 28•18 years ago
|
||
I committed the patch from comment 12 to MOZILLA_1_8_BRANCH:
/cvsroot/mozilla/js/src/jsapi.c,v <-- jsapi.c
new revision: 3.214.2.28; previous revision: 3.214.2.27
done
Checking in jsobj.c;
/cvsroot/mozilla/js/src/jsobj.c,v <-- jsobj.c
new revision: 3.208.2.37; previous revision: 3.208.2.36
done
Keywords: fixed1.8.1
Assignee | ||
Updated•18 years ago
|
Attachment #241119 -
Flags: approval1.8.1.1?
Comment 29•18 years ago
|
||
verified fixed 1.8 20061010 windows/mac*/linux
Keywords: fixed1.8.1 → verified1.8.1
Comment 30•18 years ago
|
||
Clearing blocking flag for 1.8.1.1, as this made 1.8.1. If this is incorrect, please fwap me.
Flags: blocking1.8.1.1+
You need to log in
before you can comment on or make changes to this bug.
Description
•