Closed Bug 974466 Opened 11 years ago Closed 9 years ago

SelectHelper passed document instead of window to prompt

Categories

(Firefox for Android Graveyard :: General, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(firefox49 fixed)

RESOLVED FIXED
Firefox 49
Tracking Status
firefox49 --- fixed

People

(Reporter: wesj, Assigned: tldmartin)

Details

Attachments

(1 file, 1 obsolete file)

Prompt.jsm takes a window argument to prompts (for a future tab-modal-prompt world). SelectHelper passes a document instead of a window. We should fix that.
Whiteboard: [mentor=wesj][lang=js]
Mentor: wjohnston
Whiteboard: [mentor=wesj][lang=js] → [lang=js]
Tristan, are you interested in taking a look at this? I'm not sure if it's valid anymore.
Mentor: wjohnston2000
Flags: needinfo?(tldmartin)
Whiteboard: [lang=js]
Cheers. I'll take a look.
Flags: needinfo?(tldmartin)
Assignee: nobody → tldmartin
Attached patch 974466.patch (obsolete) — Splinter Review
Here's the code in question: let p = new Prompt({ window: element.contentDocument }); It's wrong, but doesn't seem to cause any bugs. It's actually passing undefined. The fix is to use either of these: let p = new Prompt({ window: window }); or... let p = new Prompt(); // also requires minor changes to Prompt.jsm to handle no argument If we pass a reference to window then the instance of Prompt will be associated with its tab [ref 2]. The only benefit I can find is that the prompt could hide/show itself when you change tabs [ref 3], but because the prompt is modal (greys out the rest if the UI) I don't think it's possible to change tabs with it open anyway and I can't properly test it. I think the second approach is better, but let me know if you want to do the first. Here are the test results for the second approach: https://treeherder.mozilla.org/#/jobs?repo=try&revision=0c4925c3c437 . It looks like somthing unrelated failed, but I'm not across the testing yet. [1] https://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/SelectHelper.js#59 [2] https://lxr.mozilla.org/mozilla-central/source/mobile/android/modules/Prompt.jsm#24 [3] https://mxr.mozilla.org/mozilla-central/source/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java#123
Attachment #8746924 - Flags: review?(margaret.leibovic)
Comment on attachment 8746924 [details] [diff] [review] 974466.patch Review of attachment 8746924 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/chrome/content/SelectHelper.js @@ -56,5 @@ > show: function(element) { > let list = this.getListForElement(element); > - let p = new Prompt({ > - window: element.contentDocument > - }); I think we should actually still pass the window here, so that this is associated with the tab. You can use WebIDE to set a breakpoint and inspect the JS here to figure out what methods you need to call to get at the window, but I think what you want is `element.ownerDocument.defaultView`. ::: mobile/android/modules/Prompt.jsm @@ +15,5 @@ > function log(msg) { > Services.console.logStringMessage(msg); > } > > function Prompt(aOptions) { Instead, you could use a default parameter value here, declaring this as: function Prompt(aOptions = {}) { https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters
Attachment #8746924 - Flags: review?(margaret.leibovic) → feedback+
Attached patch 974466.patchSplinter Review
This works for me, and looks right under a debugger. Thanks Margaret.
Attachment #8746924 - Attachment is obsolete: true
Attachment #8749544 - Flags: review?(margaret.leibovic)
Comment on attachment 8749544 [details] [diff] [review] 974466.patch Review of attachment 8749544 [details] [diff] [review]: ----------------------------------------------------------------- Excellent, thanks!
Attachment #8749544 - Flags: review?(margaret.leibovic) → review+
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 49
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: