Closed
Bug 522924
Opened 15 years ago
Closed 11 years ago
Testing object with instanceof against its type returns false if type defined within a namespace.
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: andorsalga, Unassigned)
Details
(Whiteboard: [WFM?])
Attachments
(2 files)
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.3a1pre) Gecko/20091006 Minefield/3.7a1pre Creating an instance of a class which is in a 'namespace' and then testing it with instanceof returns false in Minefield 3.7a1pre. If the class isn't in a namespace, the conditional returns true. Reproducible: Always Steps to Reproduce: 1. create a namespace var ns = {}; 2. create a class within that namespace. ns.test = function(){} 3. create an instance of that class var iTest = new ns.test(); 4. test if instance instanceof type if(iTest instanceof ns.test) { // will not run } Actual Results: instanceof return false Expected Results: instanceof should return true instanceof returns true if the class isn't in a namespace.
Reporter | ||
Comment 1•15 years ago
|
||
Script has 2 tests. first test check if object is instanceof type. Other test checks if object is instanceof type within a namespace. Second test fails.
Reporter | ||
Updated•15 years ago
|
Summary: Testing object with instanceof against its class returns false if class is in a namespace. → Testing object with instanceof against its type returns false if type defined within a namespace.
Reporter | ||
Updated•15 years ago
|
Version: unspecified → Trunk
Comment 2•15 years ago
|
||
This WFM in Fx3 and 3.5 (1.9.4). Any add-ons? Anyone able to confirm? The shell testcase: var ns = {}; ns.test = function(){}; var iTest = new ns.test(); print(iTest instanceof ns.test); prints true as well, tm and m-c shells. /be
Reporter | ||
Comment 3•15 years ago
|
||
It works fine in FF3.5, but not in FF 3.7a1pre. I had a JavaScript Debugger. I uninstalled it, but I get the same result.
Reporter | ||
Comment 4•15 years ago
|
||
I ran this code in the error console: var ns = {}; ns.test = function(){}; var iTest = new ns.test(); if(iTest instanceof ns.test){alert('PASS');} and it strangely returned true.
Reporter | ||
Comment 5•15 years ago
|
||
Same as first test, but simply prints either PASS or FAIL.
Reporter | ||
Comment 6•15 years ago
|
||
Please disregard comment #4, I was running this in 3.5 by mistake. The test fails in 3.7a1pre when running it in the error console as well as the JavaScript shell. I did an hg pull and did a full build, but I still have the same problem.
Comment 7•15 years ago
|
||
This appears to pass for me in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a1pre) Gecko/20091016 Minefield/3.7a1pre
Comment 8•14 years ago
|
||
I tested with steps from comment 4 and it passes for me too: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.3a4pre) Gecko/20100403 Minefield/3.7a4pre Andor, does it work for you now?
Whiteboard: [WFM?]
Comment 9•11 years ago
|
||
Still works.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•