Login Register

Chrome strange behaviors !

Hello.

Please, help me with this because it's getting me crazy ...

While working on a Tatami demo app, i noticed a strange bug which appeared only in Safari.
The bug is, when i start dragging an item from my tree, the avatar shows up in the bottom left corner in the page and is "frozen".

I failed to reproduce the bug in chrome, but i tried to understand what went wrong using the built-in debugger (google's one, not the webkit inspector JS console). When i turned the javascript debugger on, the bug also happened in chrome...

It appeared it was due to a test in dojo.getComputedStyle fails because testing the given element instance with "n instanceof HTMLElement" returns false.

I did not understood why it was failing, because when printing the node constructor, it was HTMLDivElement ...
When i printed the element in the debugger, Chrome displayed it as "# " ...

I did a little test, which was really surprising !
The following code is a log from the debugger ...

$ print document.createElement("div");
#
$ print document.createElement("div").constructor;
function HTMLDivElement() { [native code] }
$ print (document.createElement("div") instanceof HTMLDivElement)
false
$ print (document.createElement("div") instanceof HTMLElement)
false
$ print (document.createElement("div") instanceof Element)
false 
$ print document.createElement("div");
#
$ print document.createElement("div").constructor;
function HTMLDivElement() { [native code] }
$ print (document.createElement("div") instanceof HTMLDivElement)
false
$ print (document.createElement("div") instanceof HTMLElement)
false
$ print (document.createElement("div") instanceof Element)
false

It is really surprising !
Testing it in Chrome's webkit's web inspector, the output was really different : the instanceof test returned true...

To conclude, i tested the following simple code to have a test case independent from GWT and dojo, and i was really surprised to notice the following code output :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
        <head>
                <title>Show Bug</title>
        </head>
        <body>
                <div id="main">
                       
                </div>
                <script type="text/javascript">
                        var myElem = document.createElement("div");
                        myElem.id = "test";
                        document.getElementById("main").appendChild(myElem);
                        var string = "I'm an HTMLElement and your browser thinks it is ";
                        string += myElem instanceof HTMLElement;
                        myElem.innerHTML = string;
                </script>
    </body>

In Chrome, when the Webkit debugger is turned off, the browser prints:
I'm an HTMLElement and your browser thinks it is true
But if you turn the Webkit debugger on, and reload the page, it prints :
I'm an HTMLElement and your browser thinks it is false

Anyone has an explanation ?