Bug 4263
| Summary: | Version bug: js1_2/version120/boolean-001.js | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Geoffrey Garen <ggaren> |
| Component: | JavaScriptCore | Assignee: | Geoffrey Garen <ggaren> |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | Normal | CC: | barraclough, digdog, ian, jhaygood |
| Priority: | P2 | ||
| Version: | 412 | ||
| Hardware: | Mac | ||
| OS: | OS X 10.4 | ||
| Bug Depends on: | |||
| Bug Blocks: | 4262 | ||
Geoffrey Garen
This test fails because it expects new Boolean(false) to return false, as it did in JS 1.2.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Justin Haygood
Comparison to other JS engines without having a version set:
JS 1.6 (Firefox 1.5.0.1 / Windows)
* Returns False
JScript 5.6 (Internet Explorer 6 SP2 / Windows)
* Returns False
Should we follow this old behavior since JScript and JS both do this?
Geoffrey Garen
It looks like new Boolean(false) is supposed to return false in JS 1.5:
15.6.2.1 new Boolean(value)
The [[Prototype]] property of the newly constructed object is set to the original Boolean prototype object, the one that is the initial value of Boolean.prototype (15.6.3.1).
The [[Class]] property of the newly constructed Boolean object is set to "Boolean".
The [[Value]] property of the newly constructed Boolean object is set to ToBoolean(value).
Alexey Proskuryakov
*** Bug 11579 has been marked as a duplicate of this bug. ***
digdog
The real cause that failed the test was IF statement.
var variable = new Boolean(false);
if (variable == false) print("EqualityExpression == RelationalExpression will be true");
if (variable) print("RelationalExpression will apply ToBollean operator on this Boolean 'object'"); // js1.2 sample use this, and expect the result of IF statement will be 'false'
In the sample above, JSCore and other JS engines are acting the same, both these two IF statements will be true, since 'variable' is a Boolean 'object' not a 'boolean' value, so the second IF statement will apply ToBollean(Object) and return true.
If you check js1_3/Boolean/boolean-001.js, you will see they already fixed this issue. (http://bugs.webkit.org/show_bug.cgi?id=11579#c7)
Gavin Barraclough
We don't support language versions in JSC (other than strict / non-strict), and al behaviour seems ES5 compliant. I don't think we need change anything here - the test documents our deliberate non-compliance with JS1.2.