Bug 15985
Summary: | function declaration inside a statement behaves differently from Firefox, but the same as IE | ||
---|---|---|---|
Product: | WebKit | Reporter: | Feng Qian <ian.eng.webkit> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED WONTFIX | ||
Severity: | Normal | CC: | mrowe |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | PC | ||
OS: | OS X 10.4 | ||
URL: | http://trac.webkit.org/projects/webkit/browser/trunk/LayoutTests/fast/js/resources/function-declarations-in-switch-statement.js |
Feng Qian
In the layout test, fast/js/function-declarations-in-switch-statement.html. Function declarations in a switch statement. SpiderMonkey assigns function body to function name dynamically (only initializes the function name when the statement is executed). KJS and IE initialize the function name with the last declaration no matter the statement is executed or not.
Function declaration in a statement is not part of ECMA-262. The real question is which behavior should KJS have, IE or Firefox?
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Eric Seidel (no email)
Generally we work hard to be compatible both, but when we have to choose: IE over firefox. The reason is generally simple market share advantage. If 80% of the web is surfing with IE, it's more likely that pages will be written to be compatible with IE than firefox.
Now, I'm not certain that in this specific issue it's "correct" to follow one or the other. But if we ever were aware of this choice, we probably chose to follow IE's behavior.
Mark Rowe (bdash)
See http://bugs.webkit.org/show_bug.cgi?id=8993#c9. Without a specific real-world case for changing this, matching IE and Opera seems like the best approach for compatibility.
Eric Seidel (no email)
It looks like we very intentionally try to match IE's behavior here, based on the layout test you mention:
http://trac.webkit.org/projects/webkit/browser/trunk/LayoutTests/fast/js/resources/function-declarations-in-switch-statement.js
I would argue that firefox diverging from the "common behavior" is a bug on their side.