Last Comment Bug 394908 - Dynamic script tags that are removed are still executed once script source is received
: Dynamic script tags that are removed are still executed once script source is...
Status: RESOLVED DUPLICATE of bug 707154
[CLOSEME 2010-11-01]
Product: Firefox
Classification: Client Software
Component: General (show other bugs)
: unspecified
: PowerPC Mac OS X
-- normal with 1 vote (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
Depends on:
  Show dependency treegraph
Reported: 2007-09-04 13:21 PDT by James Burke
Modified: 2011-12-02 11:47 PST (History)
4 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description User image James Burke 2007-09-04 13:21:24 PDT
User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv: Gecko/20070725 Firefox/
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv: Gecko/20070725 Firefox/

In general, scripts that have been removed from the DOM before they have been loaded by the browser should not be executed.

A script element with a src attribute is attached to the head element after the page loads. If that script element is removed from the DOM before the script source is processed by the browser, the browser will still execute the script source.

This causes problems with JSONP APIs (, where the callback specified in the script source may not exist once the script tag is removed.

This issue comes up if a JSONP API took a long time to respond, but the web page decided not to wait for it to complete. The web page may decide to remove the script tag and try the request again using some different parameters.

Reproducible: Always

Steps to Reproduce:
1. Go to test URL above.
2. Click "Start Test" button. A script tag will be added to the head element, but the JavaScript code will remove the script element 500 ms later. The URL the script element referenced in the source attribute will take about 5 seconds to complete.
3. If you have Firebug installed, you should see a "TEST OK. No errors should be seen after this timeout error." in the console. If no Firebug, the in-document Firebug lite should report the same thing.
Actual Results:  
After about 5 seconds, there will be an error in the Firebug console: " has no properties"

Also, if you click on the "Test for SuperXFooBarVariable". It will show an "Oh no" message because a global script variable named SuperXFooBarVariable was defined in the script source for the script element that was removed.

Expected Results:  
There should be no " has no properties" error after 5 seconds (or when the response for timeout.php is received). Also, after the 5 seconds, clicking on the "Test for SuperXFooBarVariable" variable should return something like "undefined".

Tested the above page with all Add-Ons turned off, and the issue still occurred.
Comment 1 User image Tyler Downer [:Tyler] 2010-10-06 11:24:23 PDT
This is a mass search for bugs that are in the Firefox General component, are
UNCO, and have not been changed for 800 days and have an unspecified version. 

Reporter, can you please update to Firefox 3.6.10, create a fresh profile,, and test again. If you
still see the bug, please update this bug. If the issue is gone, please set the
resolution to RESOLVED > WORKSFORME.
Comment 2 User image Tyler Downer [:Tyler] 2010-11-01 22:41:10 PDT
No reply from reporter, INCOMPLETE. Please retest with Firefox 3.6.12 or later and a new profile ( If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Comment 3 User image dynalon 2011-11-24 01:30:31 PST
I am not the original bug reporter, but I've tested with FF 5.0.1 and just today with 8.0.1 on Mac OS X (Intel) and the bug is still present and should be reopened as unresolved.

Details of the problems along with testcases can be found  here:  and here:

the basic problem is that FF does not cancel script loading after a script got removed from the DOM. This is, however, important as for JSONP requests a timeout may be set after which loading of the script is not necessary and will result in an "unknown function" error in FF if the callback has been freed in the meantime.
Comment 4 User image Boris Zbarsky [:bz] (still a bit busy) 2011-12-02 11:47:24 PST
Bug 707154 was filed as a followup to comment 3.  Forward-dupping this, since that bug is clearer at this point....

*** This bug has been marked as a duplicate of bug 707154 ***

Note You need to log in before you can comment on or make changes to this bug.