Dynamic execution of scripts (via appendChild) does not function anymore.

RESOLVED DUPLICATE of bug 371576

Status

()

Core
JavaScript Engine
--
major
RESOLVED DUPLICATE of bug 371576
11 years ago
11 years ago

People

(Reporter: Huberto Kusters, Unassigned)

Tracking

({regression})

1.8 Branch
x86
Windows XP
regression
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0 papmoel
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0 papmoel

Dynamic script execution wont work as of FireFox 2.0.0.2 The script (see steps) did work prior to FireFox 2.0.0.2 and does work in IE7 (and earlier) and Opera 9.10 (and earlier).

It looks like the dynamic script is not executed synchronously anymore!

Reproducible: Always

Steps to Reproduce:
1. Create an file with the following content:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl">
    <head>
        <title>Dynamic Script Test</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <script type="text/javascript">
            var gsScriptId = '__eval_script__';

            var evalScript = function(psScript) {

                var oScript = document.getElementById(gsScriptId);
                try {
                    if (oScript) {
            		    oScript.parentNode.removeChild(oScript);
                    }
                    oScript = document.createElement('script');
        		    oScript.setAttribute('type', 'text\/javascript');
        		    oScript.setAttribute('id', gsScriptId);
        		    oScript = document.getElementsByTagName('head')[0].appendChild(oScript);
        		    oScript.text = psScript;
                }
                catch(e) {
                    throw Error('Unable to evaluate "' + psScript.substr(0,10) + '..." ->' + e + '.');
                }
                finally {
                    if (oScript && oScript.parentNode && oScript.tagName == 'SCRIPT') {
            		    oScript.parentNode.removeChild(oScript);
                    }
                }
            };

            var init = function() {
                evalScript('function testScript(){window.alert(\'YES!\');}');
                testScript();
            };

            window.onload = init;
        </script>
    </head>
    <body>
    </body>
</html>

2. Run it in FireFox 2.0.0.2

Actual Results:  
Error message indicating that the function 'testScript' does not exist. 


Expected Results:  
It should display 'YES' in a message box.
(Reporter)

Updated

11 years ago
Version: unspecified → 2.0 Branch
Regression range for this on 1.8 branch is 2007-01-16 03 - 2007-01-17 03.
I see it also in 1.8.0.
http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=AviarySuiteBranchTinderbox&branch=MOZILLA_1_8_BRANCH&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=2&date=explicit&mindate=2007-01-16+02&maxdate=2007-01-17+04&cvsroot=%2Fcvsroot
Assignee: nobody → general
Status: UNCONFIRMED → NEW
Component: General → JavaScript Engine
Ever confirmed: true
Keywords: regression
Product: Firefox → Core
QA Contact: general → general
Version: 2.0 Branch → 1.8 Branch
Created attachment 257125 [details]
Reporter's test case

Comment 3

11 years ago
Similar testcase and same regression range as bug 371576, so probably a dup.
Status: NEW → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → DUPLICATE
Summary: Dynamic execution of scripts (via script.text) does not function anymore. → Dynamic execution of scripts (via appendChild) does not function anymore.
Duplicate of bug: 371576
You need to log in before you can comment on or make changes to this bug.