Closed
Bug 371720
Opened 18 years ago
Closed 14 years ago
Firefox 2.0.0.2 makes Embedded Javascript to fail.
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
INCOMPLETE
People
(Reporter: fbelloso, Unassigned)
References
Details
(Whiteboard: [CLOSEME 5-15-2010])
Attachments
(3 files)
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070220 Firefox/2.0.0.2
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070220 Firefox/2.0.0.2
When injecting a node with both Javascript and HTML nodes, Firefox update 2.0.0.2 doesn't execute Javascript code.
Opera and previous versions of Firefox work fine.
As "additional information" I submit a small test case in order to run this.
Reproducible: Always
Steps to Reproduce:
1.Make an HTML document "~/test.html" with the test case's source code provided with this bug.
2.Open firefox 2.0.0.2 and go to local file: "~/test.html"
3.Click on button "Do it"
4.Open the Error Console and see that "embedJS" is not defined.
Actual Results:
Error Console shows that "embedJS" is not defined.
Expected Results:
Function embedJS must be called and no error is shown on Error console.
-- Begin HTML Source Code ---------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script type="text/javascript">
function doit()
{
var html =
'<div style="border: 1px solid silver; padding: 5px;">' +
' Its full of divs ...' +
' <script type="text/javascript">' +
' function embedJS(){' +
' alert("In embed");' +
' } ' +
' </scr' + 'ipt> ' +
'</div>' +
'<i> ' +
' On FF 2.0.0.2 you will see an javascript exception en Error console. <br>' +
' Previous firefox versions (2.0.0.1) and Opera work fine. Not tested on IEs.' +
'</i>' +
'';
var div = document.createElement("div");
div.innerHTML = html;
document.body.appendChild(div);
embedJS();
}
</script>
</head>
<body>
Press this button to insert new HTML with embedded Javascript.
<button onclick="doit()">Do it</button>
</body>
</html>
-- End of HTML Source Code ---------------------------------------
Reporter | ||
Comment 1•18 years ago
|
||
I imagine you are a little bussy, I've downloaded mozilla source code and compiled firefox on my debian.
I found that content/../nsDocument implements dom's element ::AppendChild() and at the end of the DOM modification is called the function RemoveExecuteBlocker() from nsScriptLoader which ...
- for version 2.0.0.2 calls "ProcessPendingRequestsAsync();"
- for version 2.0.0.1 calls "ProcessPendingRequests();" (synchronous)
I've changed this to do script evaluation synchronously and i've rebuild Firefox and now It works fine (like prior versions and Opera).
I don't understand because it seams that on the 2.0.0.2 release notes doesnt show a change that leads to a change such that. I'm confused about it.
Anyway. Probably althought Opera works synchronously its possible I'am doing something non-standard. I'll see the DOM specfications to see if they cover this issue.
Please give me a clue.
Thanks in advance.
Comment 2•18 years ago
|
||
Wow! Great investigation work! Looking at the CVS logs, this is a regression from the patch in bug 364692. Adding a dependency for now. You might want to stay tuned to bug 371576, as that tracks a similarly reported regression.
Blocks: 364692
Reporter | ||
Comment 3•18 years ago
|
||
Health!
If no possible fixes are in a near sight I will make a change on my functions to avoid inserting javascript nodes and save and evaluate them via javascript eval() function. A modified version of the testcase is likeis shown above.
To do my own appendChild() (indeed i have a version of this method) is fifteen lines of code so far and continue the good work. Firefox is in credible (in two words ;-).
Thanks anyway.
-- Begin HTML Source Code ---------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<script type="text/javascript">
function doit()
{
var html =
'<script type="text/javascript">' +
' function embedJS(){' +
' alert("In embed");' +
' } ' +
'</scr' + 'ipt>' +
'<div style="border: 1px solid silver; padding: 5px;">' +
' Its full of divs ...' +
'</div>' +
'<i> ' +
' On FF 2.0.0.2 you will see an javascript exception en Error console. <br>' +
' Previous firefox versions (2.0.0.1) and Opera work fine. Not tested on IEs.' +
'</i>' +
'';
var div = document.createElement("div");
div.innerHTML = html;
// I save the nodes on variables to be more clear
var scriptNode = div.childNodes[0];
var adivNode = div.childNodes[1];
var italicNode = div.childNodes[2];
// script node. Dont append, only eval
eval(scriptNode.text);
// div
document.body.appendChild(adivNode);
// italic
document.body.appendChild(italicNode);
embedJS();
}
</script>
</head>
<body>
Press this button to insert new HTML with embedded Javascript.
<button onclick="doit()">Do it</button>
</body>
</html>
-- End of HTML Source Code ---------------------------------------
Comment 4•18 years ago
|
||
It'd be really helpful to have a testcase that shows the problem attached using https://bugzilla.mozilla.org/attachment.cgi?bugid=371720&action=enter instead of just having HTML pasted into the bug...
Depends on: 371576
Reporter | ||
Comment 5•18 years ago
|
||
Reporter | ||
Comment 6•18 years ago
|
||
Comment 9•18 years ago
|
||
I want to confirm these not clear changes in 2.0.0.2.
Here is simple example of bookmarklet, which skeleton I use often in my works:
javascript:
(function(){
function addscript(){
var js=document.createElement("script");
js.setAttribute("language","JavaScript");
js.setAttribute("type","text/javascript");
js.text="function someactions(){alert('hello');}";
document.getElementsByTagName('head').item(0).appendChild(js);
}
function runscript(){
someactions();
}
addscript();
runscript();
}
)()
I works in firefox 2.0.0.1 (and opera, hm), but does not work in 2.0.0.2. The "someactions()" function does not exist when "runscript()" calls it.
The following script works fine (note, just "setTimeout" is used):
javascript:
(function(){
function addscript(){
var js=document.createElement("script");
js.setAttribute("language","JavaScript");
js.setAttribute("type","text/javascript");
js.text="function someactions(){alert('hello');}";
document.getElementsByTagName('head').item(0).appendChild(js);
}
function runscript(){
setTimeout("someactions()", 0);
}
addscript();
runscript();
}
)()
This way works in 2.0.0.2 (and opera too), but... I would like to know, is the first example some sort of a bug or not? Whether it is necessary to alter all in view of some new policy?
Comment 10•18 years ago
|
||
So is this working with current branch builds? See http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla1.8/firefox-2.0.0.3pre.en-US.linux-i686.tar.gz ?
Comment 11•18 years ago
|
||
Seems to be working alright!
Comment 12•15 years ago
|
||
This bug was reported on Firefox 2.x or older, which is no longer supported and will not be receiving any more updates. I strongly suggest that you update to Firefox 3.6.3 or later, update your plugins (flash, adobe, etc.), and retest in a new profile. If you still see the issue with the updated Firefox, please post here. Otherwise, please close as RESOLVED > WORKSFORME
http://www.mozilla.com
http://support.mozilla.com/kb/Managing+profiles
http://support.mozilla.com/kb/Safe+mode
Whiteboard: [CLOSEME 5-15-2010]
Version: unspecified → 2.0 Branch
Comment 13•14 years ago
|
||
No reply, INCOMPLETE. Please retest with Firefox 3.6.x or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
You need to log in
before you can comment on or make changes to this bug.
Description
•