Closed Bug 384364 Opened 17 years ago Closed 14 years ago

button tag inside link fires two requests

Categories

(Core :: DOM: Events, defect)

x86
All
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 346401

People

(Reporter: dennisml, Unassigned)

References

Details

Attachments

(4 files, 5 obsolete files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a6pre) Gecko/20070612 Minefield/3.0a6pre
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a6pre) Gecko/20070612 Minefield/3.0a6pre

Putting a <button> tag inside a link causes the target page to be called twice. Example code:

<html><body><a href="test.php"><button>xxx</button></a></body></html>
<?php
error_log("called\n",3,"/tmp/error.log");
?>

Putting this in a page "test.php", loading the page and clicking the button results in a single entry of "called" in the logfile on Firefox 2 but when used in Firefox 3 "called" gets dumped into the logfile twice.

Reproducible: Always

Steps to Reproduce:
Use the above example.
Actual Results:  
test.php gets requested twice.

Expected Results:  
test.php should get requested only once.
Version: unspecified → Trunk
Flags: blocking-firefox3?
Flags: blocking-firefox3?
Product: Firefox → Core
QA Contact: general → general
Confirmed.
(tested Firefox)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a6pre) Gecko/20070612 Minefield/3.0a6pre  

(Local HTML)
<a href="http://www.h2.dion.ne.jp/~radon/test/domlist.html"><button>xxx</button></a>
(Remote HTML contains next script. only external resource in HTML)
<script type="text/javascript" src="domlist.js"></script>

HTTP GET was issued twice.
(1) First  HTTP GET to domlist.html <= by <button>?
(2) Second HTTP GET to domlist.html <= by <A HREF>
    (HTTP GET to favico.ico)
    HTTP GET to domlist.js
Status: UNCONFIRMED → NEW
Ever confirmed: true
Correct(2 HTTP GET) NSPR log. Sorry for spam. 
(Previous log was different one. No 2 HTTP GET because cache was was used)

1. Clear cahce, shutdown Fx.
2. Restart Fx, and open local HTML (test.html)
3. Click <a href=...><button>xxx</button></a> => URL is loaded
4. Shutdown Fx.
Attachment #268471 - Attachment is obsolete: true
Tested again with Name=Firefox,Version=3.1a2pre,BuildID=2008072803 on
MS Win-XP SP3. Problem still remains. Problem occurs also with <input type="button"> and <input type="submit">.
OS: Linux → All
Bug 127903 is for problem of "Form submit is not executed" when next HTML.
> <form action="http://www.mozilla.org">
> <a href="http://www.mozillazine.org">
> <input type="submit" value="Click here; should take you to mozilla, not
mozillazine">
> </a>
> </form>
Setting dependency to Bug 127903. 
Depends on: 127903
When <input type="submit> in <form> case, execution of submit event can be halted a while by alert() in onSubmit handler of <form>.
If alert() is issued by onSubmit handler, problem of this bug and problem of Bug 127903 disappears.

Tested with Fx trunk on MS Win-XP SP3.
> [App]   Name=Firefox, Version=3.1a2pre, BuildID=2008073103
>         ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
> [Gecko] MinVersion=1.9.1a2pre, MaxVersion=1.9.1a2pre
Test cases use FORM action=www.mozillazine.org, A href=www.mozilla.org.

(Case-1) alert() is issued by onSubmit handler.
1. alert() by onSubmit. Keep dialog open.
2. www.mozilla.org is loaded
3. OK to alert dialog => www.mozillazine.org is loaded
   => Problem of Bug 127903 didn't occur
NSPR log says:
   1. Single HTTP GET to www.mozilla.org
   2. 200 response
      => This bug(Bug 362539) didn't occur
   3. Single HTTP GET to www.mozillazine.org
   4. 200 response

(Case-2) alert() is not issued by onSubmit handler.
1. www.mozilla.org is loaded
NSPR log says:  
   1. Single HTTP GET to www.mozillazine.org
   2. First HTTP GET to www.mozilla.org
   3. Immediate second HTTP GET to www.mozilla.org
      => This bug(Bug 362539) occurred
   4. 200 response to second HTTP GET
Attachment #331892 - Attachment description: NSPR log(nsHttp:5) of Case-1 → NSPR log of Case-1 (nsHttp:5,DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5)
Attachment #331893 - Attachment description: NSPR log(nsHttp:5) of Case-2 → NSPR log of Case-2((nsHttp:5,DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5))
Previous NSPR logs are too big to analyze problem, because many HTTP GETs for an URI are issued. Updated test case uses http:// URL of simplest HTML file.
Attachment #268476 - Attachment is obsolete: true
Attachment #331891 - Attachment is obsolete: true
Attachment #331892 - Attachment is obsolete: true
Attachment #331893 - Attachment is obsolete: true
NSPR log is obtained by following option, with DebugView on MS Win-XP SP3, with Fx trunk.
> SET NSPR_LOG_MODULES=nsHttp:5,DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5
> SET NSPR_LOG_FILE=WinDebug

When Case-5(a href='javascript:alert('Hello');'), alert was executed twice when Fx 3/Fx trunk.
It causes double HTTP GET when <a href='http:// URI'>(Case-4).  
Attachment #332073 - Attachment mime type: application/octet-stream → text/plain
Component: General → DOM: Events
QA Contact: general → events
NSPR log says;

(javascript: URI case)
> 00000002 10.17856503 [2752] 0[72b140]: DOCSHELL 876aa0 InternalLoad javascript:alert('Hello');	
> 00000003 10.17885017 [2752] 0[72b140]: DOCSHELL 876aa0 InternalLoad javascript:alert('Hello');	

(http: URI case. not held in Cache ==> Double HTTP GET)
> 00000008 11.51838779 [2752] 0[72b140]: DOCSHELL 876aa0 InternalLoad http://www.h2.dion.ne.jp/~radon/mozilla/bug-test/foo-via-link.html
>(snip)
> 00000028 11.52166748 [2752] 0[72b140]: http request [	
> 00000029 11.52173710 [2752] 0[72b140]:   GET /~radon/mozilla/bug-test/foo-via-link.html HTTP/1.1	
>(snip)
> 00000040 11.52269936 [2752] 0[72b140]: DOCSHELL 876aa0 InternalLoad http://www.h2.dion.ne.jp/~radon/mozilla/bug-test/foo-via-link.html
>(snip)
> 00000093 11.55312157 [2752] 0[72b140]: http request [	
> 00000094 11.55319881 [2752] 0[72b140]:   GET /~radon/mozilla/bug-test/foo-via-link.html HTTP/1.1
Attachment #332071 - Attachment description: Updated test cases, in order to reduce log sige of HTTP GET → Updated test cases, in order to reduce log size of HTTP GET
href="javascript:..." was executed twice with ;
 (A) Case_10,Case_12,Case_13 : BUTTON type=submit/button/reset
     (This bug. New from Fx 3. Doesn't occur with Fx 2)
 (B) Case_14,Case_15,case_16 : INPUT type=submit/button/reset
     (Bug 350390. Regression during Fx 1.6 era).

I feel problem can be said as;
  Double scheduling of HREF of <a> when form's button element is used in <a>,
  (Fault of handler of <a href>. When "Default Action" by button/input exists?)
instead of "button tag fires two requests" (fault in click handling of button),
because problem occurs also with type=button/reset.

Note:
With old Fx 1.6, problem of Bug 127903 could be observed with Case_21 to Case_26.
  <a> <form> <button> or <input> of type=submit </form> </a>
  ACTION of <form> was not scheduled. Only HREF of <a> was scheduled.
With Fx 3/Fx Trunk, both ACTION of <form> & HREF of <a> were scheduled, and double schedule of HREF(this bug's problm) was observed with all of submit, button, and reset.
Regression Range:
>(No problem)
> Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060307 Firefox/1.6a1
(This bug started to occur)
> Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060308 Firefox/1.6a1
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: