// @sourceurl on script tag in firefox

Greetings,

In firefox 19 and firebug 1.X i encoutered a strange bug when trying //@sourceurl.

Basically i'm dynamically adding script tag through dom manipulation as you can see in the sample below. This does not work.

Maybe it's a limitation of ff but i find it odd that it works in chrome and not in ff.
Can you confirm this and do you have any bypass to this bug ?

Ps: i don't want to use global eval() as it crash in ie when using document.write

    <script type="text/javascript">
    var count=0;
    function addNewScriptToHead()
    {
            var newScriptElem;
            var newScriptText;

            newScriptElem = document.createElement('script');
            newScriptElem.setAttribute('type', 'text/javascript');
            newScriptElem.setAttribute('id', '' + count);
            newScriptElem.text= 'console.log("Yay !");//@ sourceURL=root/test'+count++ +'.js';

            document.body.appendChild(newScriptElem);
    };
    </script>
    </head>

    <body>
            <button onclick="addNewScriptToHead()">add script</button><br><br>
    </body>

Experimentation has lead me to believe the following:

  1. As of version 20.0, FF still does not support //@ sourceURL directly in its inbuilt web console.

  2. //@ sourceURL does work with the Firebug addon in FF, but not completely as expected/hoped.

    A. It only works for eval. It doesn't work at all for appended script nodes like in the original question.

    B. Errors will have a line number and the URL, and you can click
    the error to see the line of code. However, console.log does not
    seem to be affected and shows no line number or URL.

  3. Testing this feature from within FF's web console is not advised. I got different results than testing directly in HTML at least some of the time.