Closed Bug 355145 Opened 18 years ago Closed 18 years ago

JS_GetMethodById() on XML objects no longer works

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: sync2d, Assigned: igor)

References

Details

(Keywords: regression, verified1.8.1)

Attachments

(1 file, 3 obsolete files)

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: general → igor.bukanov
Blocks: js1.7src
Attached patch Fix v1 (obsolete) — Splinter Review
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 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
Attached patch Fix v2 (obsolete) — Splinter Review
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
(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.
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
(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.
(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
Given that trivial fix to js_GetProperty, jsapi.c can go back to rev 3.280. /be
Attached patch Fix v3 (obsolete) — Splinter Review
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 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?
Attached patch Fix v3bSplinter Review
Patch to commit with comment text fix.
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?
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
Attachment #241110 - Attachment is obsolete: true
Attachment #241110 - Flags: approval1.8.1?
Comment on attachment 241119 [details] [diff] [review] Fix v3b Asking approval for the committed patch.
Attachment #241119 - Flags: approval1.8.1?
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+
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 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?
(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
Attachment #241119 - Flags: approval1.8.1?
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-
Attachment #241119 - Flags: approval1.8.1- → approval1.8.1.1?
verified fixed 1.9 20061005 windows/linux
Status: RESOLVED → VERIFIED
*** Bug 356129 has been marked as a duplicate of this bug. ***
*** Bug 355913 has been marked as a duplicate of this bug. ***
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?
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?
Blocks: 355913
*** Bug 355913 has been marked as a duplicate of this bug. ***
No longer blocks: 355913
Comment on attachment 241119 [details] [diff] [review] Fix v3b Approved for RC3.
Attachment #241119 - Flags: approval1.8.1? → approval1.8.1+
Flags: blocking1.8.1? → blocking1.8.1+
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
Attachment #241119 - Flags: approval1.8.1.1?
verified fixed 1.8 20061010 windows/mac*/linux
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.

Attachment

General

Creator:
Created:
Updated:
Size: