Cjxcz Odjcayrwl
Cjxcz Odjcayrwl

Reputation: 22847

What is changed for JavaScript when the IE Developers Tools are opened?

What is changed, from the point of view of running AJAX application, when the IE Developers Tools are opened?

I'm tracing now some Schrödinger bug. It's about dropdown lists from PrimeFaces in IE. They are sometimes not opening after click, and they got 'unblocked' after one maximizes browser or unzooms the content. Because those dropdowns are realized on the basic of normal input, with attached div, I supposed it's something with wrongly calculating the place to show that dropdown popup. I've also supposed AJAX errors.

But after opening IE Developers Tools it's hardly possible to reproduce the error. No error is showed in console, no AJAX request hangs, and, what's more, everything seems to function more.

The error is only for IE, so the developers tools are the only way to debug it. However, when they are opened, it seems that the observation changes the state somehow, like in quantum mechanics...

So, I need to know, what could be changed by opening those developers tools, that prevents the bug from showing up?

--edit-- It has nothing to do with console.log. It is the problem with calculating the size of invisible elements. The problem was solved by adding scroll to the body. However, the question is open, how the IE Developers Tools were influencing those calculations.

Upvotes: 2

Views: 159

Answers (1)

Ian
Ian

Reputation: 50905

If you really want to always include using console, I suggest using a polyfill for it:

(function(b){
    var a=0;
    var c=function(){};
    var d=["log","assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];
    b.console=b.console||{};
    for(;a<d.length;a++){
        b.console[d[a]]=b.console[d[a]]||b.console["log"]||c;
    }
})(window);

This a minified example that I tried to make readable. It's something I found awhile ago and modified some. I think the main thing I modified is that if you call a method that wasn't originally implemented by the browser's native console, it will call console.log. If console.log wasn't natively implemented, it just calls an empty function. The original version of this code didn't include this fallback to console.log.

This will "guarantee" that console calls will not fail. You can change the d variable to only include calls you are sure you will use, otherwise there's some extra unnecessary processing.

Upvotes: 1

Related Questions