Closed Bug 790898 Opened 12 years ago Closed 11 years ago

Match desktop in restrictions for "Add Search Engine" option

Categories

(Firefox for Android Graveyard :: General, defect)

ARM
Android
defect
Not set
normal

Tracking

(firefox16 affected, firefox17 affected, firefox18 affected)

RESOLVED FIXED
Firefox 28
Tracking Status
firefox16 --- affected
firefox17 --- affected
firefox18 --- affected

People

(Reporter: xti, Assigned: retornam)

References

Details

(Whiteboard: [mentor=liuche])

Attachments

(2 files, 3 obsolete files)

Firefox 18.0a1 (2012-09-12) Device: Galaxy Note OS: Android 4.0.4 Steps to reproduce: 1. Open Firefox for Android 2. Go to about:feedback and tap on I have an idea 3. Long tap on the text field Expected result: Add Search Engine is not displayed in the context options. Actual result: After step 3, when context menu is triggered, Add Search Engine option is listed as you can see in the attached screenshot. Nothing happens if it is tapped.
Attached image screenshot
Desktop also supports adding search engines for most form fields, but has more restrictions than Android. We should at least match Desktop in the checks we do. http://mxr.mozilla.org/mozilla-central/source/browser/base/content/nsContextMenu.js#1486
Whiteboard: [mentor=liuche]
Summary: Add restrictions for "Add Search Engine" option → Match desktop in restrictions for "Add Search Engine" option
The desktop link is bitrotted, but the checks are in "isTargetAKeywordField", and the relevant Android code is in mobile/android/chrome/content/browser.js, at the "filter" function in SearchEngines.init() [1]. [1] http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#6642
Wes or Brian, or whomever - I think I might have a mentee who's interested in working on this bug, but since I'll be on away for 2 weeks, can you keep an eye on this and help them out if they need it? Thanks!
Flags: needinfo?(wjohnston)
Attached patch bug-790898.patch (obsolete) — Splinter Review
Attachment #8341199 - Flags: review?(wjohnston)
Assignee: nobody → mozbugs.retornam
Attachment #8341199 - Flags: review?(wjohnston) → review?(margaret.leibovic)
Comment on attachment 8341199 [details] [diff] [review] bug-790898.patch Review of attachment 8341199 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for taking this on! This is a good start, but it looks like we're still missing some checks that desktop does. Here's a better link to that code: http://hg.mozilla.org/mozilla-central/file/4bf430d990e5/browser/base/content/nsContextMenu.js#l1503 ::: mobile/android/chrome/content/browser.js @@ +6642,5 @@ > let filter = { > matches: function (aElement) { > + if (!(aElement instanceof HTMLInputElement)) > + return false; > + else { You don't need an else statement after a return. @@ +6643,5 @@ > matches: function (aElement) { > + if (!(aElement instanceof HTMLInputElement)) > + return false; > + else { > + return (aElement.form && NativeWindow.contextmenus.textContext.matches(aElement)); This NativeWindow.contextmenus check is somewhat redundant with the `instanceof HTMLInputElement` check above. I think we should just go ahead and replace the body of this `matches` function with the body of desktop's `isTargetAKeywordField` function (and add a comment saying that's where we got that logic from).
Attachment #8341199 - Flags: review?(margaret.leibovic) → review-
Flags: needinfo?(wjohnston)
Attached patch bug-790898.patch (obsolete) — Splinter Review
Attachment #8341199 - Attachment is obsolete: true
Attachment #8342512 - Flags: review?(margaret.leibovic)
Attached patch bug-790898.patch (obsolete) — Splinter Review
Attachment #8342512 - Attachment is obsolete: true
Attachment #8342512 - Flags: review?(margaret.leibovic)
Attachment #8342541 - Flags: review?(margaret.leibovic)
Comment on attachment 8342541 [details] [diff] [review] bug-790898.patch Review of attachment 8342541 [details] [diff] [review]: ----------------------------------------------------------------- Nice, this looks good. I just have a few small issues to address before we land this. ::: mobile/android/chrome/content/browser.js @@ +6629,5 @@ > > let filter = { > matches: function (aElement) { > + //Copied over from body of isTargetAKeywordField > + //function in nsContextMenu.js Nit: This could all be one line, and you should add a space after the // before the text (e.g. // Copied...) @@ +6632,5 @@ > + //Copied over from body of isTargetAKeywordField > + //function in nsContextMenu.js > + if(!(aElement instanceof HTMLInputElement)) > + return false; > + var form = aElement.form; Nit: Looks like you accidentally put 2 spaces after var. And please include an empty line above this line. We can also update this code to use `let` instead of `var` (the code in nsContextMenu.js was written before `let` existed).
Attachment #8342541 - Flags: review?(margaret.leibovic) → review+
Attached patch bug-790898.patchSplinter Review
Attachment #8342541 - Attachment is obsolete: true
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 28
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

Created:
Updated:
Size: