instanceof does not throw exception for objects not implementing [[HasInstance]] method

VERIFIED FIXED in mozilla1.8beta2

Status

()

P4
normal
VERIFIED FIXED
14 years ago
13 years ago

People

(Reporter: sukhisoul, Assigned: brendan)

Tracking

({js1.5})

Trunk
mozilla1.8beta2
x86
Linux
js1.5
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [have patch])

Attachments

(1 attachment)

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)
Build Identifier: 

According to specs -- section 11.8.6 of ECMA-262 -- instanceof operator
on objects NOT implementing [[HasInstance]] internal method should 
throw a TypeError exception. Hence, in the following script the
catch block must get executed, (since Math object does not implement
[[HasInstance]] method).

var varBool1;
var objNumber = new Number(5);
			
try{
    /* Math object can not be used for instantiation */
    /* Hence, TypeError */
    varBool1 = objNumber instanceof Math; 
			
}
catch(e){
    print("Exception " + e.name + "occurred");			
}



Reproducible: Always

Steps to Reproduce:
1. Copy the following script in a file, say t.js

var varBool1;
var objNumber = new Number(5);
			
try{
    /* Math object can not be used for instantiation */
    /* Hence, TypeError */
    varBool1 = objNumber instanceof Math; 
			
}
catch(e){
    print("Exception " + e.name + "occurred");			
}


2. Launch Spidermonkey shell with above script-file as input. eg. js t.js

3. Watch the output on the screen

Actual Results:  
Nothing was printed on screen


Expected Results:  
Should have printed following:

Exception TypeError occurred
(Assignee)

Updated

14 years ago
Assignee: general → brendan
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: js1.5
Priority: -- → P4
Target Milestone: --- → mozilla1.8beta2
(Assignee)

Comment 1

14 years ago
Reporter: no need for "STD Non-Compliance: " at the start of the summary.

/be
Status: NEW → ASSIGNED
Summary: STD Non-Compliance: instanceof does not throw exception for objects not implementing [[HasInstance]] method → instanceof does not throw exception for objects not implementing [[HasInstance]] method
(Assignee)

Comment 2

14 years ago
Created attachment 173932 [details] [diff] [review]
fix
Attachment #173932 - Flags: review?(shaver)
(Assignee)

Updated

14 years ago
Whiteboard: [have patch]
Comment on attachment 173932 [details] [diff] [review]
fix

r=shaver
Attachment #173932 - Flags: review?(shaver) → review+
(Assignee)

Comment 4

14 years ago
Fixed.

Bob, do you want to take over QA Contact for "JavaScript Engine" from
pschwartau@meer.net?

/be
Status: ASSIGNED → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → FIXED

Comment 5

14 years ago
If that is ok with Phil, I would be happy to be qa.

Comment 6

14 years ago
the second testcase in ecma_2/instanceof/instanceof-003.js is invalid.
o = {}; o instanceof o

Comment 7

14 years ago
the second testcase in js/tests/ecma_2/instanceof/regress-7635.js is a repeat of
the o = {}; o instanceof o which is invalid after this bug fix. checked in.

js/tests/js1_5/Regress/regress-281606.js checked in with Milind
<sukhisoul@yahoo.com> as primary contributor.

Comment 8

14 years ago
/cvsroot/mozilla/js/tests/ecma_2/instanceof/instanceof-003.js,v  <-- 
instanceof-003.js
new revision: 1.2; previous revision: 1.1

Updated

14 years ago
Flags: testcase+

Comment 9

13 years ago
verified fixed 1.8.0.2,1.8,1.9a1 20060401 win/mac/linux
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.