instanceof issues
Andor Salga | 18 October, 2009 | 11:58
When I first started work on porting the C3DL library from using Canvas 3D to WebGL, I ran into a problem with instanceof. In a particular line of code, I check if an object is an instance of a type. It always worked on Firefox 3.5 using Canvas 3D and everything renders properly. However, using Firefox 3.7a1pre, the conditional evaluated to false. I commented the line and I continued working eventually getting something drawn. I did this by adding ID’s to most of the C3DL classes as well as a getObjectType() function. This was simply a workaround so I could focus on more important tasks.
This week I went back to the instanceof problem. I needed an isolated case to see if perhaps the library was at fault, so I wrote a short script in an HTML file. I found that on Firefox 3.5, it worked fine, but on Firefox 3.7a1pre, it didn’t. After mentioning this in #seneca on irc.mozilla.org, Chris Tyler suggested I file the bug. So I did.
The next morning I continued to work on the bug. After talking with a number of people on IRC, I learned a few things. There is a JavaScript shell available when you check out the Firefox source.
On my machine I found it at
Back to the issue, I ran the test again and it still fails. I’m pretty much stuck and this point in regards to the bug. I’ll either have to wait for someone else to confirm or I may try on another system. While I wait for that, I’ll be returning my attention back to porting to WebGL.
mozilla-central/obj-ff-dbg/dist/bin/jsI started the shell and tried the folowing:
macbook-pro:bin andor$ ./js
js> var ns = {};
js> ns.test = function(){};
(function () {})
js> var iTest = new ns.test();
js> print(iTest instanceof ns.test);
false
Still false. I decided to update my repository and rebuild. Maybe the issue was already resolved and only existed for a few days?
I went back to my console and updated.
hg pullI then did a full build.
make -f client.mk buildThe first thing I noticed is that the small icons in each tab are now cute little progress bars.
Back to the issue, I ran the test again and it still fails. I’m pretty much stuck and this point in regards to the bug. I’ll either have to wait for someone else to confirm or I may try on another system. While I wait for that, I’ll be returning my attention back to porting to WebGL. 