Closed Bug 715560 Opened 13 years ago Closed 6 years ago

new tabs are moved during the ready event, and should be in the correct location before loading

Categories

(Firefox :: Tabbed Browser, defect, P2)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1449700

People

(Reporter: florian.vichot, Unassigned)

References

Details

Attachments

(1 file)

Attached file my simplified main.js
I'm trying via an addon to control where new tabs open relative to the current active tab. I've thus had a look at the Addon SDK docs, which indicate that by modifying the value of the ".index" property of a "Tab" object, I can control its position in the tab bar. Except, the behaviour is totally inconsistent between opening a new tab by the "New Tab" shortcut Ctrl-T, and by Ctrl-clicking on a link.

If I force "tab.index = 0" for example (so it should always open as the first tab) :

With Ctrl-T :

Before [tab 1][tab 2][tab 3][tab 4]
After  [NEW TAB][tab 1][tab 2][tab 3][tab 4]
Again  [NEW TAB][tab 5][tab 1][tab 2][tab 3][tab 4]

which is the expected behaviour, the new tab is always at index 0.

But with Ctrl-Click on a link (assuming [tab 1] is the active tab) :

Before [tab 1][tab 2][tab 3][tab 4]
After  [tab 1][tab 2][NEW TAB][tab 3][tab 4]
Again  [tab 1][tab 2][NEW TAB][tab 5][tab 3][tab 4]

Which makes no sense.

And that's with "tab.index = 0". With other values such as "tab.index = 2" it gets even weirder : Ctrl-T behaviour is logical (the new tab is at index 2 if it can, and opens as last tab otherwise), but Ctrl-Click behaviour is strange (new tabs open to the immediate right of the current tab if current tab index is < 2, otherwise, open as the current tab index + 2...)

This is with SDK 1.3 and Firefox 9.0.1.
Attachment #586129 - Attachment mime type: application/octet-stream → text/javascript
Assignee: nobody → evold
Hi Florian,

Thanks for the bug report, sorry it took so long to respond.

I tried your example code and confirm the error you mention.  If you listen to the 'ready' event instead of the 'open' event then the desired behavior occurs (ie: the tab is opened at index = 0).

So it appears that Firefox is moving the tab after the 'open' event when the user does a ctrl+click on links, but it does the move before the 'ready' event.

I'm not sure if we should force our 'open' event to occur after this move or not, but I'm thinking we should just leave it as it is, and you can use the 'ready' event.

I'm cc'ing Dave and Irakli for their opinions.
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
OS: Mac OS X → All
Hardware: x86 → All
This should definitely be documented if we preserve the existing behaviour. Cc'ing Will
Flags: needinfo?(rFobic)
Yeah it's feels like Firefox internal implementation details leak through to the SDK users. I don't think we should try and pretend something else happens that's usually makes code very fragile to any future changes.

I think we should:

1. Document current behavior as Jeff suggested.
2. Make this a platform bug, and make FF open tabs at the right index instead.
3. Meanwhile we should expose move events so that tab index can be known before ready event occurs.
Flags: needinfo?(rFobic)
Assignee: evold → nobody
Component: General → Tabbed Browser
Product: Add-on SDK → Firefox
Summary: Tab.index has inconsistent behaviour → new tabs are moved during the ready event, and should be in the correct location before loading
Version: unspecified → Trunk
No assignee, updating the status.
Status: ASSIGNED → NEW
No assignee, updating the status.
No assignee, updating the status.
No assignee, updating the status.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: