Closed Bug 372477 Opened 17 years ago Closed 17 years ago

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

Categories

(Core :: JavaScript Engine, defect)

1.8 Branch
x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 371576

People

(Reporter: huberto.kusters, Unassigned)

Details

(Keywords: regression)

Attachments

(1 file)

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.
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
Similar testcase and same regression range as bug 371576, so probably a dup.
Status: NEW → RESOLVED
Closed: 17 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.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: