Closed Bug 104097 Opened 25 years ago Closed 22 years ago

during form submission document.location waits for the rest of the function to execute before activating

Categories

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

x86
Windows 2000
defect

Tracking

()

RESOLVED INVALID
Future

People

(Reporter: stakadush, Assigned: alexsavulov)

References

()

Details

Attachments

(3 files)

go to the website and click on TEST FLIGHT and then LOG IN. on the menu in the left frame click on Web/FTP Server and then on Directory Settings. to the left there's a list of Settings and to the right a list of Subfolders. select one of the subfolders and click Go. as you can see the folder hasn't changed. do the same with ie and you'll see that the line in bold (URL: http://64.78.31.9/) has changed to URL: http://64.78.31.9/[subfolder] i'm using build 2001100803 on windows 2000
This is not JS Engine; based on description, reassigning to Style System for further triage. Compare bug 104030 at same URL. Is there a test userID and password we can use at this site?
Assignee: rogerl → dbaron
Component: Javascript Engine → Style System
QA Contact: pschwartau → ian
OOPS - you DON'T need a UserID, Password if you follow the instructions above. Sorry, my mistake. Reassigning back to JS Engine for a look at the functionality at this site -
Assignee: dbaron → rogerl
Component: Style System → Javascript Engine
QA Contact: ian → pschwartau
From the HTML in the attachment, we see that the "Go" button is coded as: <button class='button' onClick='onGoClick(this.form)'> Go </button> where function onGoClick( form ) { if( form.shortcutDirectory.selectedIndex>=0 ) { if( form.shortcutDirectory.options[form.shortcutDirectory.selectedIndex].text=='..' ) { location.href = '/asp/User/WebFTPServer/WebServer/DirectorySettings.asp?directory='+escape(''); } else { location.href = '/asp/User/WebFTPServer/WebServer/DirectorySettings.asp?directory='+escape(''+'\ \'+form.shortcutDirectory.options[form.shortcutDirectory.selectedIndex].text); } } else { alert('Please select a directory first'); } }
By doing some debugging, I found that Mozilla is correctly resolving the "this.form" passed to the function by the button. So that's not the problem. Inside the function, "form.shortcutDirectory" refers to the <SELECT> containing "FoxWeb", etc. This is just the "list of subfolders" in the steps to reproduce above. This is also correctly resolved in Mozilla. Now, say you've selected "FoxWeb"at the top of the list. Then form.shortcutDirectory.selectedIndex = 1 and form.shortcutDirectory.options[1].text = 'FoxWeb' and escape(''+'\\'+ 'FoxWeb')= '%5CFoxWeb' So in this case, the function is trying to assign this URL to location.href: '/asp/User/WebFTPServer/WebServer/DirectorySettings.asp?directory=%5CFoxWeb'
You can see the JavaScript in the function is working perfectly in Mozilla by following the steps to reproduce and selecting "FoxWeb" in the selectbox. Don't hit the "Go" button now, but key this javascript: URL (all on one line) and hit Enter: javascript: var select1 = window.frames[1].document.AccessForm.shortcutDirectory; var i = select1.selectedIndex; var location1 = '/asp/User/WebFTPServer/WebServer/DirectorySettings.asp?directory=' + escape(''+'\\'+ select1.options[ i].text); alert(location1); You will correctly get '/asp/User/WebFTPServer/WebServer/DirectorySettings.asp?directory=%5CFoxWeb' Now try this: javascript: location.href=location1; Mozilla correctly loads this URL and you see the bolded URL in the middle of the page change, from URL: http://64.78.31.9/ to URL: http://64.78.31.9/FoxWeb/ So the JS Engine is performing all its tasks correctly, and Mozilla renders the FoxWeb page correctly.
I think the problem may be this: the form containing the "Go" button has this tag: <form NAME="AccessForm" ACTION="/asp/User/WebFTPServer/WebServer/DirectorySettings.asp?Directory=" METHOD="POST" > Notice the ACTION is the same as the URL the "Go" button is building, with the value for "Directory" left out. I think that in Mozilla this ACTION attribute of the <FORM> tag is superseding the onClick attribute of the <BUTTON> "Go" inside the form. When this happens, the "FoxWeb" is left off, and you get the behavior the reporter describes. I don't know if this is correct behavior or not; reassigning to DOM Events for further triage -
Assignee: rogerl → joki
Status: UNCONFIRMED → NEW
Component: Javascript Engine → DOM Events
Ever confirmed: true
QA Contact: pschwartau → vladimire
cc'ing jst in case he recognizes this as a dupe -
SUMMARY: if the user selects "FoxWeb", we have something like this: <form ACTION="foo.asp?Directory=" METHOD="POST"> <button onClick='location.href="foo.asp?Directory=%5CFoxWeb"'>Go </button> </form> Apparently the form action is superseding the onClick of the button. Therefore the "FoxWeb" selection gets ignored. At least, that is what I think is going on -
<button> now defaults to submitting the form. However if I understand correctly, the original HTML has <button type="button"> which _doesn't_ submit the form. So unless that is bugged, it can't be the problem.
To try the reduced testcase, save it locally. To run it, you have to gain access to the secure site, so follow these steps: 1. Load https://hosting.intermedia.net/asp/User/Login.asp 2. Click on "TEST FLIGHT" 3. Load the reduced testcase 4. Click the "Go" button IE4.7 will then load https://hosting4.intermedia.net/asp/User/WebFTPServer/WebServer/ DirectorySettings.asp?Directory=%5CFoxWeb Moz loads the <FORM> action: https://hosting4.intermedia.net/asp/User/WebFTPServer/WebServer/ DirectorySettings.asp?Directory= Why the discrepancy? Is this an IE-ism?
Fabian's point is well-taken. If I modify the testcase to say <input type="button" onClick=etc. > then Moz honors the onClick over the form action, and performs the same as IE4.7. In the reduced testcase, it's <button onClick=etc.> and Moz honors the form action over the onClick (but IE4.7 does not). As far as I can see, the website has <button class='button' onClick=etc.>
cc'ing Vlad on this one -
CC'ing sicking. Jonas, should the form submit or the onclick handler take precedence? (that way you can already incorporate that in your form submission patch ;-)
The onclick event of the button is called first, before the onsubmit of the form is called, but for some reason changing location does not take place. If you put any other code, like an alert box in the onclick handler you will see that it does get executed. I dont know if this is a bug or not, but the current behaviour is confusing. It executes the script skipping redirects, and the does the action.. There is a workabout however, to add ;return false; at the end of the onclick to cancel the default behaviour of submitting the form.
Based on Phil's latest testcase, I can almost certainly state this is not a bug. See somewhat related bug 78599. What's happening is two separate settings of location.href. Before the first one can finish loading (or even really start), the second setting of location.href takes place. This is like what happens when you click on a link to one page, and while waiting for that page to load, you suddenly click on another link. I recommend this bug be marked INVALID.
yeah, this is invalid (unless setting location.href should somehow halt any further scripting or other actions, which i don't think it should). Doing |return false;| is not a workaround, it's the right thing to do, it means "cancel default action", where default action is submitting the form
But changing location of the page, should do it immedeately just as poping up an alert would act immedeately, not wait until the form is submitted...
All this becomes highly irrelevant if onGoClick sets this.form.action instead of location.href. The page developer will realize his intended result by doing so.
Attached file another testcase —
The above testcase runs the following code when submit button is clicked document.location = "http://www.yahoo.com"; i = 0; for(i = 0;i < 1000;i++) { document.form1.test.value = i; } alert("test"); behaves in the following fassion across browsers: Netscape 6> Count to 1000, show alert and switch page url simultaniously IE> Count to 1000, show alert wait for it to be dismissed, submit the page to the action specified specified Netscape 4.x> Start count and simultaniously submit to the specified action My oppinion is that if we ignore location change we should ignore it altogether, consistently, and do what IE does. But if we change the location we should not wait for counter to end counting, or for the form to be submited.
Mm. Yes, I see it now. That's a bug all right. Not sure how it relates to the original bug report, though.
/me eating crow
Summary: javascript problems → during form submission document.location waits for the rest of the function to execute before activating
There is a new issue found, if the action is specified in the last testcase, it goes to the location first, and then does submition to the action specified. Should do either one or the other.
Target Milestone: --- → mozilla1.1
-> form submission...
Assignee: joki → alexsavulov
Component: DOM Events → Form Submission
Priority: -- → P4
retargeting
Target Milestone: mozilla1.1alpha → Future
This is invalid. The only thing going on here is that document loads are async, so once you set location we start the load but how much of the load completes before the submit happens and cancels the load will depend on how much time elapses.... The only thing going on here is that IE mis-implements <button>.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
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: