Open Bug 389007 Opened 18 years ago Updated 3 years ago

FF throws "Component returned failure" exception when submiting dynamically created form in JavaScript

Categories

(Core :: DOM: Core & HTML, defect, P5)

1.8 Branch
x86
Windows XP
defect

Tracking

()

UNCONFIRMED

People

(Reporter: greg, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5 In Zimbra Admin application we create an form dynamically and then submit it. Here's the JS code that does it var body = this.document.body; if(!body) { body = this.document.createElement('body'); this.document.appendChild(body); } var form = this.document.createElement('form'); form.style.display = 'none'; body.appendChild(form); var html = new Array(); var i = 0; if(!delegateToken) alert("Error! Failed to acquire authenticaiton token!"); lifetime = tokenLifetime ? tokenLifetime : 300000; html[i++] = "<input type='hidden' name='authToken' value='" + delegateToken + "'>"; if (tokenLifetime) { html[i++] = "<input type='hidden' name='atl' value='" + tokenLifetime + "'>"; } form.innerHTML = html.join(''); form.action = mailServer; form.method = 'post'; form.submit(); this line: form.submit(); makes FireFox throw an exception with the following details: QueryInterface: function QueryInterface() { [native code] } message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLFormElement.submit] result: 2147500037 name: NS_ERROR_FAILURE I get this all the time on versions from 2.0.0.1 to 2.0.0.5 (latest at this time) Reproducible: Always Steps to Reproduce: 1.log in to Zimbra Administration console 2.Select any account in Accounts view 3.Click View Mail button Actual Results: New window opens, but the form that is being created in the new window is not submitted. The exception is reported in the parent window. Expected Results: Should not get an exception, should just submit the form. Tested on WinXP with and without FireBug. FF versions prior to 2.0.0.1 do not have the problem.
Zimbra's bug related to this issue is http://bugzilla.zimbra.com/show_bug.cgi?id=18606
Summary: FF throws Component returned failure exception when submiting dynamically created form in JavaScript → FF throws "Component returned failure" exception when submiting dynamically created form in JavaScript
So you're saying this regressed between Firefox 2.0.0.0 and 2.0.0.1 or between Firefox 1.5 and 2.0.0.1? Also, does this error occur on the latest Firefox trunk builds? http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/
Component: General → DOM: HTML
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → 1.8 Branch
So far, I have tried only released FF builds: 1.5, 2.0.0.1, 2.0.0.2 and 2.0.0.5. Among these, it is happening only on 2.0.0.1, 2.0.0.2, and 2.0.0.5.
Unfortunately, I cannot test it on the trunk build, because Zimbra Admin UI does not work on the trunk build. I tried an isolated test script which performs the same action in an empty HTML page and it does not have the same problem. So far, the problem occurs only when using Zimbra Admin UI. For Zimbra Admin UI, this is not critical, because I found a workaround. The test page that I tried (and which does not confirm the bug) is this: <html> <script language="JavaScript"> /** * Launches mail app to view user's email **/ launch = function (delegateToken, tokenLifetime, mailServer) { var body = this.document.body; if(!body) { body = this.document.createElement('body'); this.document.appendChild(body); } var form = this.document.createElement('form'); form.style.display = 'none'; body.appendChild(form); var html = new Array(); var i = 0; if(!delegateToken) alert("Error! Failed to acquire authenticaiton token!"); lifetime = tokenLifetime ? tokenLifetime : 300000; html[i++] = "<input type='hidden' name='authToken' value='" + delegateToken + "'>"; if (tokenLifetime) { html[i++] = "<input type='hidden' name='atl' value='" + tokenLifetime + "'>"; } form.innerHTML = html.join(''); form.action = mailServer; form.method = 'post'; form.submit(); } function doTest() { var win = window.open("about:blank", "_blank"); launch.call(win, "asd", "bca", "http://localhost/"); } </script> <body> <form> <input type=button onClick = "doTest()" value="Do Test"><input type=text></form> </body> </html>
(In reply to comment #4) > I found a workaround. > <input type=button onClick = "doTest()" value="Do Test"> Problem of comment #0 sounds to be caused by schedule of submit while preparing DOM nodes under form produced by innerHTML. Bug 388563 has relation? (seems to be new in 2.0.0.5) If cause is innerHTML, followings are possible workarounds. 1. <form><script>document.writeln(html.join("\n"));</script></form> 2. Use standard createElement/appendChild instead of non-standard innerHTML. http://developer.mozilla.org/en/docs/DOM:element.innerHTML
Component: DOM: HTML → DOM: Core & HTML
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.