Closed
Bug 1192788
Opened 10 years ago
Closed 9 years ago
Can't install add-on panel at position 0
Categories
(Firefox for Android Graveyard :: General, defect)
Tracking
(firefox48 fixed)
RESOLVED
FIXED
Firefox 48
Tracking | Status | |
---|---|---|
firefox48 | --- | fixed |
People
(Reporter: sebastian, Assigned: shatur, Mentored)
References
Details
(Whiteboard: [good first bug][lang=js])
Attachments
(1 file, 3 obsolete files)
969 bytes,
patch
|
Margaret
:
review+
|
Details | Diff | Splinter Review |
When creating an add-on that creates a home panel and specifying position 0 then the panel is added as last item to the list.
Comment 2•10 years ago
|
||
Aha, options.position is falsy if it is 0:
http://hg.mozilla.org/mozilla-central/rev/43512d4631b7#l2.31
To fix this bug we should be more explicit and check options.position !== undefined:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/modules/Home.jsm#384
Mentor: margaret.leibovic, s.kaspari
Whiteboard: [good first bug][lang=js]
Comment 3•10 years ago
|
||
Possible fix. I can't confirm it because I don't have an add-on that triggers the bug.
Flags: needinfo?(s.kaspari)
Attachment #8648386 -
Flags: feedback?(s.kaspari)
Attachment #8648386 -
Flags: feedback?(margaret.leibovic)
Reporter | ||
Comment 4•10 years ago
|
||
Comment on attachment 8648386 [details] [diff] [review]
Possible fix
Review of attachment 8648386 [details] [diff] [review]:
-----------------------------------------------------------------
Thank you for the patch Heiko!
I tested it with the speed-dial sample add-on[1] (Set position to 0 in bootstrap.js) and it works.
[1] https://github.com/pocmo/speed-dial
::: mobile/android/modules/Home.jsm
@@ +380,5 @@
> this.authConfig.imageUrl = options.auth.imageUrl;
> }
> }
>
> + if (typeof options.position !== "undefined" && typeof options.position === "number") {
Can the type ever be 'number' AND 'undefined'? My JavaScript is rusty and I wouldn't be surprised if JavaScript does weird things. :) Otherwise I'd just check for 'number' and do some validation like >= 0? But let's wait for Margaret's feedback.
Attachment #8648386 -
Flags: feedback?(s.kaspari) → feedback+
Comment 5•10 years ago
|
||
(In reply to Sebastian Kaspari (:sebastian) from comment #4)
> Comment on attachment 8648386 [details] [diff] [review]
> Possible fix
>
> Review of attachment 8648386 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Thank you for the patch Heiko!
>
> I tested it with the speed-dial sample add-on[1] (Set position to 0 in
> bootstrap.js) and it works.
>
> [1] https://github.com/pocmo/speed-dial
>
> ::: mobile/android/modules/Home.jsm
> @@ +380,5 @@
> > this.authConfig.imageUrl = options.auth.imageUrl;
> > }
> > }
> >
> > + if (typeof options.position !== "undefined" && typeof options.position === "number") {
>
> Can the type ever be 'number' AND 'undefined'? My JavaScript is rusty and I
> wouldn't be surprised if JavaScript does weird things. :) Otherwise I'd just
> check for 'number' and do some validation like >= 0? But let's wait for
> Margaret's feedback.
Good call. I don't think the type can ever be both 'number' and 'undefined', so a check for type 'number' should suffice, and I agree the check for >= 0 makes a lot of sense, since we don't support negative position values.
Updated•10 years ago
|
Assignee: nobody → mozilla
Updated•10 years ago
|
Attachment #8648386 -
Flags: feedback?(margaret.leibovic)
Reporter | ||
Updated•10 years ago
|
Flags: needinfo?(s.kaspari)
Comment 6•10 years ago
|
||
Looks like my first patch was a little halfhearted as I only concentrated on the first part of the test condition :-)
I attached a new version of the patch for completeness.
If I read the source correctly, options.position basically maps to the position member of Android's android.widget.GridView which should handle all remaining cases. I tested both negative numbers and large integers using the speed-dial sample add-on and it was added last in both cases.
Attachment #8648386 -
Attachment is obsolete: true
Comment 7•10 years ago
|
||
Comment on attachment 8650762 [details] [diff] [review]
“Minified” Patch
Review of attachment 8650762 [details] [diff] [review]:
-----------------------------------------------------------------
::: mobile/android/modules/Home.jsm
@@ +380,5 @@
> this.authConfig.imageUrl = options.auth.imageUrl;
> }
> }
>
> + if (typeof options.position === "number") {
I think we should still follow Sebastian's suggestion to validate that options.position is >= 0, since a position < 0 won't do anything useful.
Also, please make sure to set the review? flag when you upload new patches. Otherwise patches tend to fall through the cracks! :)
Attachment #8650762 -
Flags: feedback+
Reporter | ||
Comment 8•9 years ago
|
||
Heiko, do you have time to push this over the finish line or do you want someone else to pick this up? :)
Flags: needinfo?(mozilla)
Reporter | ||
Comment 9•9 years ago
|
||
Maybe somebody else wants to pick it up from here. :)
Assignee: mozilla → nobody
Reporter | ||
Updated•9 years ago
|
Flags: needinfo?(mozilla)
Reporter | ||
Updated•9 years ago
|
Blocks: home-panel-addons
Assignee | ||
Comment 10•9 years ago
|
||
Hi.
This is my first patch for js, Please Review.
Attachment #8731652 -
Flags: review?(margaret.leibovic)
Comment 11•9 years ago
|
||
Comment on attachment 8731652 [details] [diff] [review]
BUG-1192788.patch
Review of attachment 8731652 [details] [diff] [review]:
-----------------------------------------------------------------
::: mobile/android/modules/Home.jsm
@@ +380,5 @@
> this.authConfig.imageUrl = options.auth.imageUrl;
> }
> }
>
> + if (typeof options.position >= 0) {
This statement evaluates the type of options.position, then compares that to 0. That's not what you want.
You should remove the `typeof` operator here.
Attachment #8731652 -
Flags: review?(margaret.leibovic) → review-
Assignee | ||
Comment 12•9 years ago
|
||
Hi,
Sorry for that. Hope this will solved the issue.
Regards.
Attachment #8731652 -
Attachment is obsolete: true
Attachment #8732005 -
Flags: review?(margaret.leibovic)
Comment 13•9 years ago
|
||
Comment on attachment 8732005 [details] [diff] [review]
Bug-1192788-v2.patch
Review of attachment 8732005 [details] [diff] [review]:
-----------------------------------------------------------------
Great, thanks for the update. I'll mark this bug as ready to check in for you.
Let us know if you need help finding more bugs to work on! There is a long list of mentor bugs maintained here:
http://www.joshmatthews.net/bugsahoy/?mobileandroid=1
Attachment #8732005 -
Flags: review?(margaret.leibovic) → review+
Updated•9 years ago
|
Attachment #8650762 -
Attachment is obsolete: true
Updated•9 years ago
|
Assignee: nobody → tushar.saini1285
Keywords: checkin-needed
Comment 14•9 years ago
|
||
Keywords: checkin-needed
Comment 15•9 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 48
Updated•4 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•