Closed Bug 920497 Opened 12 years ago Closed 12 years ago

Update closeTab method in tabs.js to prevent wrong index values

Categories

(Mozilla QA Graveyard :: Mozmill Tests, defect)

defect
Not set
normal

Tracking

(firefox24 wontfix, firefox25 fixed, firefox26 fixed, firefox27 fixed, firefox28 fixed, firefox-esr17 wontfix, firefox-esr24 fixed)

RESOLVED FIXED
Tracking Status
firefox24 --- wontfix
firefox25 --- fixed
firefox26 --- fixed
firefox27 --- fixed
firefox28 --- fixed
firefox-esr17 --- wontfix
firefox-esr24 --- fixed

People

(Reporter: mario.garbi, Assigned: mario.garbi)

Details

Attachments

(2 files, 2 obsolete files)

Attached file minimized.js
While working on other issues I have noticed that closeTab() method doesn't work right when we set the aIndex parameter to 0. This happens because 0 can have boolean value when used with || and as such we get the default value as can be seen in the minimized testcase attached. Dump log shows: aIndex parameter: 0 Final value: defaultValue aIndex parameter: 1 Final value: 1
Attached patch indexToString.patch (obsolete) — Splinter Review
We can handle this issue by casting the parameter as a string so we won't have any confusions when combined with ||.
Assignee: nobody → mario.garbi
Status: NEW → ASSIGNED
Attachment #809832 - Flags: review?(andrei.eftimie)
Attachment #809832 - Flags: review?(andreea.matei)
Comment on attachment 809832 [details] [diff] [review] indexToString.patch Review of attachment 809832 [details] [diff] [review]: ----------------------------------------------------------------- Sorry for highjacking... ::: lib/tabs.js @@ +189,5 @@ > * Index of the tab to close (only used for middleClick) > */ > closeTab : function tabBrowser_closeTab(aEventType, aIndex) { > var type = aEventType || "menu"; > + var index = aIndex.toString() || this.selectedIndex; No, don't change the datatype of the parameter. Use a check for undefined instead.
Attachment #809832 - Flags: review?(andrei.eftimie)
Attachment #809832 - Flags: review?(andreea.matei)
Attachment #809832 - Flags: review-
Attached patch indexToString_v2.patch (obsolete) — Splinter Review
Updated the patch to check for 0 value. If the parameter is undefined it will be assigned a default value correctly.
Attachment #809832 - Attachment is obsolete: true
Attachment #809861 - Flags: review?(hskupin)
Attachment #809861 - Flags: review?(andrei.eftimie)
Attachment #809861 - Flags: review?(andreea.matei)
Comment on attachment 809861 [details] [diff] [review] indexToString_v2.patch Review of attachment 809861 [details] [diff] [review]: ----------------------------------------------------------------- ::: lib/tabs.js @@ +189,5 @@ > * Index of the tab to close (only used for middleClick) > */ > closeTab : function tabBrowser_closeTab(aEventType, aIndex) { > var type = aEventType || "menu"; > + var index = (aIndex === 0) ? aIndex : In my last review I said that you should check for undefined and not 0. So please do so.
Attachment #809861 - Flags: review?(hskupin)
Attachment #809861 - Flags: review?(andrei.eftimie)
Attachment #809861 - Flags: review?(andreea.matei)
Attachment #809861 - Flags: review-
Updated the patch to check if the parameter is undefined and only then set a default value for it. Seems to work fine now with aIndex = 0 and undefined values.
Attachment #809861 - Attachment is obsolete: true
Attachment #810564 - Flags: review?(hskupin)
Attachment #810564 - Flags: review?(andrei.eftimie)
Attachment #810564 - Flags: review?(andreea.matei)
Comment on attachment 810564 [details] [diff] [review] indexToString_v3.patch Review of attachment 810564 [details] [diff] [review]: ----------------------------------------------------------------- http://hg.mozilla.org/qa/mozmill-tests/rev/a8bb09dbda2a (default) This needs backporting, please check that.
Attachment #810564 - Flags: review?(hskupin)
Attachment #810564 - Flags: review?(andrei.eftimie)
Attachment #810564 - Flags: review?(andreea.matei)
Attachment #810564 - Flags: review+
It applies cleanly on all branches as the part of the code that this changes is the same on all branches.
I have tested this again on a fresh repository and it applies cleanly up to esr17 with the exception of Aurora branch where it got merged already.
Backported: http://hg.mozilla.org/qa/mozmill-tests/rev/c09701875ffd (mozilla-beta) http://hg.mozilla.org/qa/mozmill-tests/rev/6b490a93fbca (mozilla-release) http://hg.mozilla.org/qa/mozmill-tests/rev/51353c26ed05 (mozilla-esr24) Nothing critical here, we can safely skip it for ESR17.
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Product: Mozilla QA → Mozilla QA Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: