Summary: | Democracy Player dies in NSException from WebScriptObject on startup | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Mark Rowe (bdash) <mrowe> | ||||||
Component: | WebKit Misc. | Assignee: | Nobody <webkit-unassigned> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Major | CC: | eric, timothy | ||||||
Priority: | P2 | Keywords: | InRadar, Regression | ||||||
Version: | 523.x (Safari 3) | ||||||||
Hardware: | Mac | ||||||||
OS: | OS X 10.5 | ||||||||
URL: | http://www.getdemocracy.com/ | ||||||||
Attachments: |
|
Description
Mark Rowe (bdash)
2007-03-20 06:31:18 PDT
Created attachment 13716 [details]
Patch
Comment on attachment 13716 [details]
Patch
Nice solution! You should really just use @try/@catch instead of NS_DURING/NS_HANDLER. Those macros just wrap @try now...
The patch landed here had incorrect selectors in it: count: and _count: rather than count and _count And we didn't test that the count method still works. It doesn't! In fact, the _shouldRespondToCount method is never called. As Darin points out my "fix" was bogus. It fixed Democracy Player by hiding "count" at all times. Created attachment 13903 [details]
Hide "count" at all times in an explicit fashion
This provides the same behaviour that ToT has but in an explicit manner. I haven't been able to determine anywhere, other than in Drosera, that -[WebScriptObject count] is called.
Count and objectAtIndex: was added to better support bindings. Fixed in bug 8389. Does Democracy Player blow up on the presence of count? Or the fact that calling count throws an exception? We could simply put a @try/@catch in count to prevent the exception. We could also call lower level JavaScriptCore methods to see if the script object has the count property first. That would be faster than a @try/@catch. Comment on attachment 13903 [details]
Hide "count" at all times in an explicit fashion
r=me
Tim, "count" is being called implicitly by PyObjC when Democracy does "if myDOMNode:". The fact it throws an exception makes this a very visible problem. If "count" were to *not* throw an exception what would it return when the "length" property is not present? 0 or nil would be the two obvious values, but both of these would make "myDOMNode" appear as boolean false to Python and would break Democracy in a more subtle manner. It's not clear to me how "count" helps for bindings support. If it is required we might want to wrap collection-like JS objects in a subclass of WebScriptObject which implements count/objectAtIndex: rather than exposing them on *all* JS objects? Landed in r20642. There is some #if 0 code in WebCore which references this bug: #if 0 // FIXME: We'd like to add this, but we can't do that until this issue is resolved: // http://bugs.webkit.org/show_bug.cgi?id=13129: presence of 'count' method on // WebScriptObject breaks Democracy player. - (unsigned)count { id length = [self valueForKey:@"length"]; if (![length respondsToSelector:@selector(intValue)]) return 0; return [length intValue]; } #endif Can we turn that on now? |