Open Bug 340158 Opened 18 years ago Updated 2 years ago

Multiple SUBMITs performed when Submit Button "pushed" with Spacebar

Categories

(Core :: DOM: Events, defect, P5)

1.8 Branch
x86
Windows XP
defect

Tracking

()

UNCONFIRMED

People

(Reporter: AlKoch, Unassigned)

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4

In "Additional Information" is a simple FORM that contains a single field and a Submit button.  The Form has an OnSubmit= Javascript handler.

If the sample HTML is run in Internet Exploder 6 I can activate the handler by 1) clicking on the button or 2) tabbing to the button and pushing <Enter> or 3) tabbing to the button and pushing <Spacebar>.  In all three cases the
OnSubmit handler is called exactly once which, of course, is correct.

If the sample HTML is run in Firefox 1.5.0.4  I can again activate the handler by 1) clicking on the button or 2)  tabbing to the button and pushing <Enter> or 3) tabbing to the button and pushing <Spacebar>.  In the 1st two cases the OnSubmit handler is called exactly once, but if I push the <Spacebar> the OnSubmit handler is called *TWICE*!

Since the  HTML works with no problem with all three "submit techniques" in Internet Exploder and the 1st two "submit techniques" in Firefox it seems to me that the form and Javascript handler are correct and that there is something "flaky" about using the <Spacebar> to activate the Submit button in Firefox.

The problem is subtle.  I discovered that if an alert is displayed as a part of the Submit handler, doing so "blocks" the 2nd Submit.  The following is a simple example that demos the problem.  Here are some important notes:

1) In the sample HTML, the OnSubmit handler doesn't "do anything" unless it is being called a 2nd time.  As I mentioned above, we can't let the handler use an alert() to show that the handler was called because, for an unknown reason, the alert() prevents the 2nd Submit from happening.
2) You can view the page three times for three tests.  View the page once, enter some test text, Tab to the button and *click* on the button.  Nothing will appear to happen because the OnSubmit handler is called exactly once.  Refresh the page and then again enter some test text, Tab to the button and and push <Enter>.  Again nothing will appear to happen because the OnSubmit handler is called exactly once.  However, as a final test, refresh the page, again enter some test text, Tab to the button and and push <Spacebar>.  This time an alert is fired by the OnSubmit handler because it was called twice!


Reproducible: Always

Steps to Reproduce:
1. Please see Details for specific steps and notes to reproduce
2.
3.

Actual Results:  
When the Spacebar is used to "push" the Submit button the OnSubmit handler is called twice.

Expected Results:  
The OnSubmit handler should be called exactly once as it is if the Button is "activated" by a mouse click or by pushing <Enter>.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
	<HEAD>
		<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

		<SCRIPT language="JavaScript" defer>
		<!--
		var bAlreadyDoneSubmit = false;
		function submitTest()
		{
			if (bAlreadyDoneSubmit) {
				alert('We have already processed the Submit once; this is a duplicate Submit call!!!');
				return(false);
				}
			bAlreadyDoneSubmit = true;
			return(false);
		}
		//-->
		</SCRIPT>
	</HEAD>

	<BODY>
		<FORM Name='LoginForm' OnSubmit='return(submitTest(this));'>
			Be sure to refresh the page (and therefore reset the Javascript!) after each of the three tests!<BR>
			The 1st two tests (mouse click and push Enter) have no visible effect but test 3 with the Spacebar will show
a duplicate Submit!!!<BR>
			Enter a few chars of test data, then Tab to the button<INPUT TYPE='Text' ID='TestData' VALUE=''><BR>
			<BUTTON Type='Submit'>Test with 1) Click this button, OR 2) Tab to this button and push Enter, OR 3) Tab to
this button and push Spacebar</I></BUTTON>
		</FORM>
	</BODY>
</HTML>
Attached file testcase from reporter
I don't have this problem, tested with current trunk build and tested with Firefox 1.5.0.4 on windowsXP.
Reporter, do you get this problem also with a clean profile?
Assignee: nobody → events
Component: Form Manager → DOM: Events
Keywords: testcase
Product: Firefox → Core
QA Contact: form.manager → ian
Version: unspecified → 1.8 Branch
Assignee: events → nobody
QA Contact: ian → events
I was able to duplicate this in both:
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14 (.NET CLR 3.5.30729)
and:
Mozilla/5.0 (Windows NT 6.0; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1

I'm calling both of these in the keypress:
e.preventDefault();
e.stopImmediatePropagation();

Maybe I need to return false as well?
Here's a jsbin of what I'm running into: 
http://jsbin.com/iraper/1

I actually think I need to cancel the keyup event, then it appears to behave as intended:
http://jsbin.com/iraper/2

I'm not sure this is a bug now, it may be intended behavior.
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: minor → S4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: