Closed Bug 348369 Opened 18 years ago Closed 18 years ago

Tabbrowser steals focus any time the current browser changes

Categories

(Toolkit :: UI Widgets, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: bzbarsky, Assigned: asaf)

References

()

Details

Attachments

(1 file, 1 obsolete file)

STEPS TO REPRODUCE:

1) Start Firefox.
2) Set browser.tabs.loadDivertedInBackground to false.
3) Set browser.link.open_newwindow to 3.
4) Set browser.link.open_newwindow.restriction to 0.
5) Disable the popup blocker.
6) Run the javascript: URL in this URL field.
7) Focus some other app.
8) Wait 5 seconds.

ACTUAL RESULTS:  Other app loses focus, Firefox gets it

EXPECTED RESULTS:  Do not steal focus!

DETAILS:  The window.focus() call happens from 

2 setFocus(element = [object XPCNativeWrapper [object Window @ 0x8291c40 (native @ 0x94e3f24)]], 98) ["chrome://global/content/bindings/tabbrowser.xml":766]

We should probably just shift focus around without actually calling window.focus if we're not the active window.

NOTE: This makes running automated tests that include window.open() pretty painful.
Attached patch patch (obsolete) — Splinter Review
Stolen from bug 232605.
Assignee: nobody → mano
Status: NEW → ASSIGNED
Attachment #243897 - Flags: first-review?(gavin.sharp)
Comment on attachment 243897 [details] [diff] [review]
patch

>Index: toolkit/content/widgets/tabbrowser.xml

>-            function setFocus(element) {
>-              document.commandDispatcher.suppressFocusScroll = true;
>-              try {
>-                element.focus();
>+ 

nit: remove one of the blank lines here.

>+                if (aElement instanceof Window) {
>+                  cmdDispatcher.focusedWindow = aElement;
>+                  cmdDispatcher.focusedElement = null;
>+                }
>+                else {
>+                  cmdDispatcher.focusedWindow = null;
>+                  cmdDispatcher.focusedElement = aElement;
>+                }

Why did you change it to use null for the focusedWindow in the second case?
Comment on attachment 243897 [details] [diff] [review]
patch

Just moving this out of my queue until comment 2 is answered.
Attachment #243897 - Flags: first-review?(gavin.sharp) → first-review-
I shouldn't have.
Attached patch patchSplinter Review
Attachment #243897 - Attachment is obsolete: true
Attachment #244662 - Flags: first-review?(gavin.sharp)
Comment on attachment 244662 [details] [diff] [review]
patch

I wasn't not able to test this, but r=me assuming you did.
Attachment #244662 - Flags: first-review?(gavin.sharp) → first-review+
mozilla/toolkit/content/widgets/tabbrowser.xml 1.214
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
OS: Linux → All
Priority: -- → P3
Hardware: PC → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9alpha1
Could this bug have caused bug 360714?
(In reply to comment #8)
> Could this bug have caused bug 360714?

Pretty unlikely I think. Bug 130078 is more likely the cause of that regression, in my opinion.
I don't know how we'd unit-test this, but I think we should find a way to do so.
Flags: in-testsuite?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: