Closed
Bug 245113
Opened 21 years ago
Closed 21 years ago
instanceof operator returns true for class prototype
Categories
(Core :: JavaScript Engine, defect, P1)
Core
JavaScript Engine
Tracking
()
VERIFIED
FIXED
mozilla1.7final
People
(Reporter: jerfa, Assigned: brendan)
Details
(Keywords: js1.5, verified1.7, Whiteboard: fixed-aviary1.0)
Attachments
(2 files)
|
1.00 KB,
patch
|
shaver
:
review+
jesup
:
approval1.7+
|
Details | Diff | Splinter Review |
|
2.81 KB,
text/plain
|
Details |
User-Agent: Opera/7.23 (Windows NT 5.1; U) [de]
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040514
If I add a method to a class via prototype, then call that method direct via
"class.prototype.method()", "this instanceof class" is true. In Opera and IE it
is false.
Here is the testcase:
var res="";
Date.prototype.test = function() {
res += (this instanceof Date)+" ";
}
String.prototype.test = function() {
res += (this instanceof String)+" ";
}
res += (Date.prototype.test instanceof Date)+" ";
Date.prototype.test();
String.prototype.test();
(new Date()).test();
(new String()).test();
alert(res);
Reproducible: Always
Steps to Reproduce:
1. Run the testcase
Actual Results:
Alert box displaying "false true true true true"
Expected Results:
Alert box displaying "false false false true true"
| Assignee | ||
Comment 1•21 years ago
|
||
ECMA-262 Edition 3 agrees with comment 0.
/be
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: js1.5
Summary: instanceof operator returns true when it shouldn't → instanceof operator returns true for class prototype
| Assignee | ||
Updated•21 years ago
|
Assignee: general → brendan
Flags: blocking1.7+
OS: Windows XP → All
Priority: -- → P1
Hardware: PC → All
Target Milestone: --- → mozilla1.7final
| Assignee | ||
Comment 2•21 years ago
|
||
Easy patch, the bug here is specific to the brutal-sharing hack in
fun_hasInstance, whereby /hi/ instanceof RegExp is true even if /hi/ was
precompiled using a different RegExp object from the one used at runtime.
/be
Updated•21 years ago
|
Attachment #149863 -
Flags: review+
| Assignee | ||
Updated•21 years ago
|
Attachment #149863 -
Flags: approval1.7?
Updated•21 years ago
|
Attachment #149863 -
Flags: approval1.7? → approval1.7+
| Assignee | ||
Comment 3•21 years ago
|
||
Fixed on trunk and 1.7 branch.
/be
Updated•21 years ago
|
Whiteboard: needed-aviary1.0
| Reporter | ||
Comment 4•21 years ago
|
||
Works for me with rv:1.8a2 Gecko/20040603. Can I mark the bug as verified myself
or should a QA person do that?
| Assignee | ||
Comment 5•21 years ago
|
||
Erik: go for it, thanks!
/be
| Reporter | ||
Updated•21 years ago
|
Status: RESOLVED → VERIFIED
Whiteboard: needed-aviary1.0 → fixed-aviary1.0
Updated•21 years ago
|
Keywords: fixed1.7 → verified1.7
Comment 6•20 years ago
|
||
Erik, with your permission this will be included in the javascript test suite.
| Reporter | ||
Comment 7•20 years ago
|
||
You have my permission for this test and the tests in bug 274035 and bug 244470.
Comment 8•20 years ago
|
||
js1_5/Regress/regress-245113.js checked in.
Updated•20 years ago
|
Flags: testcase+
You need to log in
before you can comment on or make changes to this bug.
Description
•