Closed Bug 145142 Opened 22 years ago Closed 22 years ago

form double submit protection applies even after JS sets src and target

Categories

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

x86
Windows 2000
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: Trevor_campbell, Assigned: john)

References

()

Details

(Whiteboard: [FIX])

Attachments

(3 files, 3 obsolete files)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc2)
Gecko/20020510
BuildID:    2002051006

In order to more easily handle error messages and resubmit sie effects in our
web application we use an invisible IFrame as a target for POST actions.  The
page returned to the IFrame does a redirect of the parent frame to show the next
form in the application;
The javascript code is ( for example ).
<script LANGUAGE=JAVASCRIPT>

//Redirect the outer frame to show the template jsp with all the form stuff from
//the outer form
var targetDoc;
var form;
targetDoc = window.top.document;



 form = targetDoc.forms[0];
 form.action="/kits/atune/app/incidentselectuser";
 form.target="_top";
 form.submit();

</SCRIPT>

This no longer works in Mozilla.  The action and target are correctly set (
easily checked in the DOM Inspector ) but the submit does not occur.  This works
in IE 5 & 5.5 and I think used to work in Mozzilla 0.7 or 0.8.

Reproducible: Always
Steps to Reproduce:
Build a page with a form and an Iframe in it.
Have a submit button that targets the iFrame and requests a form containing the
above style of script from the server.
submit the form.

Actual Results:  Nothing

Expected Results:  Go to new page
This works for me on a build from 05/17 on win 2k and on 2002-05-13-08-trunk on
win98
Can you please attach the source of the page that contains the iframe?
Attachment requested by vladimire.
(I retested with the latest nightly build (2002052008) and had the same
failure.
Ok, I saved the page as test.html, added src="test2.html" where test2.html is a
page with the script described. When I load test.html it imedeatly submits to
the action specified in the script... 

Oh, wait a second! The testcase worked when I loaded it from the server. However
when I load it with the File:// protocol it does not work! Are you loading the
testcase with File:// protocol?
No I am loading from a Tomcat JSP server.  I will try a small/simple test case &
try to reproduce with that. 
Attached file Simple test script (obsolete) —
Attached file Simple test script part 2 (redirect) (obsolete) —
I get the same behavior with these 2 simple example .html pages
Workaround by adding a delay.  The following in the redirect script gets around
the problem.
 form = targetDoc.forms[0];
 form.action="www.kaz.com.au";
 form.target="_top";
 setTimeout('form.submit()', 100);
hehe! I know what this is! Is the double form submission prevention.
the javascript in the header of the document loaded in the iframe is executing
before the document has been loaded. That's why setting a timeout helps. In that
case the document ends loading and the from can submit a second time.

Dr. Keiser, uebernehmen Sie bitte!
Assignee: alexsavulov → jkeiser
alexandru is this invalid?
Nope, not invalid.  I want to disable double form submit protection when JS
changes target / action / method / etc.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Status: NEW → ASSIGNED
Summary: submit of parent form from iframe not working → form double submit protection applies even after JS sets src and target
Attached patch Patch (obsolete) — Splinter Review
This patch works, with the minor problem that it crashes on shutdown.  I
haven't been able to ascertain why.
Comment on attachment 95083 [details] [diff] [review]
Patch

OK, it turns out that is a general problem with today's builds (backing out
doesn't change it), this patch is up for review.
Attachment #95083 - Attachment description: Patch v0.9 (do not apply) → Patch
Whiteboard: [FIX]
Attached file Testcase
The testcases from before don't work at all--they are missing crucial JS
functions.

The bug is about making form resubmit when you change action= or target= on the
form.  That is what this testcase does: submit,change action/target,submit
again.
Attachment #84370 - Attachment is obsolete: true
Attachment #84371 - Attachment is obsolete: true
Comment on attachment 95083 [details] [diff] [review]
Patch

aren't you going to declare the  methods GetAction and SetAction in the class
declaration  of nsHTMLFormElement?
Comment on attachment 95083 [details] [diff] [review]
Patch

sorry i was blind!

r= alexsavulov
I just realized, I really want to check for this in SetAttr().
Attached patch Patch v2.0Splinter Review
This version catches SetAttr() so that setAttribute('target') and
setAttribute('action') will do the same thing.	Also extra comments and some
cleanup.
Attachment #95083 - Attachment is obsolete: true
Comment on attachment 95672 [details] [diff] [review]
Patch v2.0

r= alexsavulov
Attachment #95672 - Flags: review+
Comment on attachment 95672 [details] [diff] [review]
Patch v2.0

sr=jst
Attachment #95672 - Flags: superreview+
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
*** Bug 159770 has been marked as a duplicate of this bug. ***
verifying on build 2003-01-17-04-trunk win2k
Status: RESOLVED → VERIFIED
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: