Search code examples
javascriptjqueryunit-testingjquery-uiqunit

"Introduced global variable(s) _firebug" in QUnit tests


I am using QUnit to perform various simple tests on my website. One of the tests is creating a dialog, showing it and then closing it. The test runs fine, but when run on Firefox with Firebug activated I get an error:

3. Introduced global variable(s): _firebug

I can live with it, but it is annoying: the same code on Chrome runs fine. I ruled out jQuery UI as the culprit since the same error appears without it. However, running without Firebug or without console.log traces does not show the problem.

I grepped all the javascript code I am using and found no mention of any "firebug" variables; and Google was silent on the matter. I want my green screen (all tests passed) back! Any ideas?


Solution

  • After googling a little bit more, I am not the first to find this problem: badglobals.js, blog, Google groups. The solution to my particular problem (QUnit reports a leaky global variable) is to add the declaration of the global before starting the tests, for example before the first module is run:

    var _firebug;
    module('myModule');
    

    I am seeing a spurious xdc variable too; same solution. My first QUnit test file now looks like this:

    /* declare spurious Firebug globals */
    var _firebug;
    var _xdc_;
    
    /* run tests */
    module('myModule');
    

    My bar is all green now, even with noglobals checked! I hope this helps anyone else who finds this annoying issue.