Closed Bug 646740 Opened 13 years ago Closed 13 years ago

worker.tab is incorrect when the given tab is in the background

Categories

(Add-on SDK Graveyard :: General, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bholley, Assigned: bholley)

References

Details

Attachments

(1 file)

The implementation of worker.tab contains a rather bizarre incantation:

>    topContentWindow= win.QueryInterface(Ci.nsIInterfaceRequestor)
>                            .getInterface(Ci.nsIWebNavigation)
>                            .QueryInterface(Ci.nsIDocShellTreeItem)
>                            .treeOwner
>                            .QueryInterface(Ci.nsIInterfaceRequestor)
>                            .getInterface(Ci.nsIDOMWindow);

This QIs its way up to XUL and back down again, always landing us in the active tab. This means that worker.tab is equivalent to require("tabs").activeTab, which is much less useful than the advertised behavior.
Attached patch patch+tests v1Splinter Review
Attached a patch and tests to fix the issue.
Assignee: nobody → bobbyholley+bmo
Status: NEW → ASSIGNED
Blocks: 621903
Attachment #523210 - Flags: review?(myk)
Nice catch!

Unfortunately I think that win.top is going to throw domain access denied exception on iframe with different domain that upper document.
I'm going to take a look at this. Thanks for the patch and this unit test is very usefull.
Priority: -- → P1
Target Milestone: --- → 1.0
Comment on attachment 523210 [details] [diff] [review]
patch+tests v1

Nice catch! r=myk
Attachment #523210 - Flags: review?(myk) → review+
https://github.com/mozilla/addon-sdk/commit/ee2e610a105c6a5bc7bda7f322064798d37016bc
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
(In reply to comment #2)
> Nice catch!
> 
> Unfortunately I think that win.top is going to throw domain access denied
> exception on iframe with different domain that upper document.

I didn't test it, but I'd assumed this wouldn't happen because the script is running with chrome context, not the context of the upper document.

Given that this was pushed, I assume this concern was resolved? I just wanted to make sure.
I verified with differents domains and win.top still works.
So we can consider this as fixed.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: