Closed Bug 931900 Opened 7 years ago Closed 7 years ago

nsIPromptService.prompt's default value parameter acts differently between desktop and mobile

Categories

(Firefox for Android :: General, defect)

ARM
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 30

People

(Reporter: jason.barnabe, Assigned: wesj)

References

Details

Attachments

(1 file)

Firefox 24 on Android
Firefox 24 on Linux

"aValue" is an inout parameter of nsIPromptService.prompt that sets the default text and gets set to the user-entered value. When this parameter is set to an empty object or to an object with a null "value" member, there is different behaviour between mobile (Android) and desktop. On mobile, the pre-filled value is "null". On desktop, there is no pre-filled value. Desktop's behaviour seems more correct to me.

Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService).prompt(window, "test", "test", {}, null, {});

or

Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService).prompt(window, "test", "test", {value: null}, null, {});

As a workaround, I can do this:

Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService).prompt(window, "test", "test", {value: ""}, null, {});
Product: Core → Firefox for Android
Assignee: nobody → wjohnston
This fix is trivial, but I have a bunch of WIP for tests for these exact things in bug 757481 that are oh-so-close to landing. Holding off until I have that in place :)
Attached patch PatchSplinter Review
Forgot about this. The tests are a bit hung up, but we should fix this.
Attachment #8377865 - Flags: review?(margaret.leibovic)
Comment on attachment 8377865 [details] [diff] [review]
Patch

Review of attachment 8377865 [details] [diff] [review]:
-----------------------------------------------------------------

r+ with comment addressed.

::: mobile/android/components/PromptService.js
@@ +303,5 @@
>  
>    nsIPrompt_prompt: function nsIPrompt_prompt(aTitle, aText, aValue, aCheckMsg, aCheckState) {
>      let p = this._getPrompt(aTitle, aText, null, aCheckMsg, aCheckState);
>      p.setHint("prompt");
> +    this.addTextbox(p, aValue.value);

With this change, autofocus will be undefined. Unintentional change?
Attachment #8377865 - Flags: review?(margaret.leibovic) → review+
https://hg.mozilla.org/mozilla-central/rev/547342061dc3
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 30
Depends on: 977592
You need to log in before you can comment on or make changes to this bug.