Closed
Bug 116303
Opened 23 years ago
Closed 23 years ago
JavaScript prompt loses default input text
Categories
(SeaMonkey :: UI Design, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla0.9.9
People
(Reporter: tpowellmoz, Assigned: morse)
References
()
Details
(Keywords: regression)
Attachments
(1 file)
820 bytes,
patch
|
samir_bugzilla
:
review+
alecf
:
superreview+
|
Details | Diff | Splinter Review |
The JavaScript window.prompt function takes two parameters. The first is for the message to be displayed in the dialog about what you want the user to enter and the second is default input text. This default text is now being lost. I noticed this when using a bugzilla bookmarket and verified it by entering the javascript prompt directly into the URL box. To reproduce, try the URL above. javascript:prompt('Do you see any default text in the input box?','Yes'); Expected: You should see Yes in the input box. Technically it should also be selected so that typing will erase all that's there, but that's bug 28583 and been a problem for a long time. Actual: You see nothing in the input box. No default text is there. I saw this using 20011219 11 build on win2k. This was not a problem with 20011217 09 build.
Comment 1•23 years ago
|
||
wfm. 2001-12-24-08, Windows 98.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → WORKSFORME
Reporter | ||
Comment 2•23 years ago
|
||
Reopening. This does not work with the 20011228 build on Win2K. No text appears in the input box.
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
Comment 3•23 years ago
|
||
WFM 2002011506-trunk on windows 98. Closing after consult w/ reporter.
Status: REOPENED → RESOLVED
Closed: 23 years ago → 23 years ago
Resolution: --- → WORKSFORME
Reporter | ||
Comment 4•23 years ago
|
||
It appears that this bug is caused as a side effect of the pref for remembering passwords. To reporoduce, go to Edit menu, Preferences, expand the Privacy & Security tree, pick Web Passwords, and then uncheck the box for Remember passwords for sites that require me to log in. It will now consistently fail (the default text does not appear). Go back and check the box again and it works as expected. This behavior should not be tied to the passwords pref. JavaScript prompt should show default text no matter what. This breaks a number of my bookmarklets and the workaround (enabling the pref) is not at all intuitive. The workaround is also unacceptable for security reasons.
Reporter | ||
Comment 5•23 years ago
|
||
Should have mentioned that I saw this problem with the 2002012309 build on Win2K. It is completely reproducable.
Assignee | ||
Comment 7•23 years ago
|
||
Assignee | ||
Comment 8•23 years ago
|
||
alecf, sgehani, please review. Thanks.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.9
Comment 9•23 years ago
|
||
are we going to leak if the user actually enters some text? this doesn't look right.
Assignee | ||
Comment 10•23 years ago
|
||
The dialog->prompt statement in singsign.cpp calls nsPrompt::Prompt which in turn calls nsPromptService::Prompt. That gets us into nsPromptService.cpp with the following code: rv = DoDialog(parent, block, kPromptURL); if (NS_FAILED(rv)) return rv; PRInt32 tempInt = 0; block->GetInt(eButtonPressed, &tempInt); *_retval = tempInt ? PR_FALSE : PR_TRUE; if (*_retval) { PRUnichar *tempStr; rv = block->GetString(eEditfield1Value, &tempStr); if (NS_FAILED(rv)) return rv; if (*value) nsMemory::Free(*value); *value = tempStr; if (checkValue) block->GetInt(eCheckboxState, checkValue); } That's where the memory gets freed. At least as far as the resultText that we allocated in singsign.cpp before calling on the dialog. Of course there's now a new resultText which the dialog is returning and that gets freed up by the caller of the routine in singsign.cpp.
Comment 11•23 years ago
|
||
Comment on attachment 67038 [details] [diff] [review] put up default text even if pm pref is off r=sgehani Thanks for explaining.
Attachment #67038 -
Flags: review+
Comment 12•23 years ago
|
||
Comment on attachment 67038 [details] [diff] [review] put up default text even if pm pref is off yikes! I think that's really broken. (nsPromptService that is) - the parameter is designated as "inout" which means that when taken as an "in" the parameter should not be freed by the callee, but the callee should allocate a new result... i.e. nsPromptService should not be freeing "value", and your code SHOULD say: *resultText = ToNewUnicode(data); char *temp = *resultText; dialog->Prompt(..., &val, ...); nsMemory::Free(temp); nsMemory::Free(*resultText); // or maybe this gets passed on elswhere however I could be wrong here. I'm cc'ing jband for ownership issues on inout parameters. in the mean time, sr=alecf on this patch.
Attachment #67038 -
Flags: superreview+
Assignee | ||
Comment 13•23 years ago
|
||
checked in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago → 23 years ago
Resolution: --- → FIXED
Updated•23 years ago
|
QA Contact: sairuh → tpreston
Updated•20 years ago
|
Product: Core → Mozilla Application Suite
You need to log in
before you can comment on or make changes to this bug.
Description
•