Closed Bug 1281354 Opened 8 years ago Closed 8 years ago

Add test that current window is correct after tab is detached

Categories

(WebExtensions :: Untriaged, defect, P3)

50 Branch
defect

Tracking

(firefox52 fixed)

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: chef, Assigned: zombie, Mentored)

References

Details

(Whiteboard: [tabs]triaged)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36

Steps to reproduce:

1) Add this code to an extension's options.html:

setInterval(function() {
    browser.windows.getCurrent(function(win) {
        console.log('current window id: ', win.id);
    });
}, 1000);

2) Ensure manifest includes:

"options_ui": {
    "page": "options.html",
    "open_in_tab": true
  }

3) Load extension and open Browser Toolbox

4) Open extension's options page from about:addons by clicking on extension's Options button

5) Observe "current window id" logs in Browser Toolbox console

6) Detach options page tab into a new or alternate window

7) Observe "current window id" logs in Browser Toolbox console for changes...


Actual results:

In step 7 above, the logged "current window id" DOES NOT CHANGE


Expected results:

In step 7 above, the logged "current window id" should have updated to reflect the window id of the new/alternate window the tab was attached to.

The reported current window should be the window that contains the code that is currently executing. See: https://developer.chrome.com/extensions/windows#current-window

See also related Issue 1202479

Note that this affects the browser.tabs API as well. Eg, browser.tabs.query({ currentWindow: true }, function(tabs) {})
This should be pretty easy to fix. We just need to look up the current parent window directly here[1], rather than caching it here[2]. We should also add some tests for this to the existing browser_tabs_move_window*.js tests.

[1]: https://dxr.mozilla.org/mozilla-central/source/browser/components/extensions/ext-tabs.js#98
[2]: https://dxr.mozilla.org/mozilla-central/source/browser/components/extensions/ext-tabs.js#66
Mentor: kmaglione+bmo
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [tabs][good first bug]
Priority: -- → P3
Whiteboard: [tabs][good first bug] → [tabs][good first bug] triaged
Hello,

can I work on this bug?
Yes, absolutely! You can learn how to get set up to to work on it here:

https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Firefox_build

and please let us know in this bug (or you can email me directly) if you've got any questions.
Hi ,
Is the bug is still unresolved if yes can i work on this bug ?
I think that Atique might be working on this one already. Atique, is that the case? 

Anagh, if you'd like to email me - mhoye at mozilla.com - I can help you find a bug to work on.
Flags: needinfo?(softfilebd)
(In reply to Anagh from comment #4)
> Hi ,
> Is the bug is still unresolved if yes can i work on this bug ?

It might be a good idea to start with the instructions that Mike left in comment 3, anyway. If Atique is indeed still working on this, I'm sure we can find something else for you to work on once you're up and running.
Thanks Mike for the instructions.
Yes, I am trying to build firefox locally. I will update you within next week.
Flags: needinfo?(softfilebd)
Keywords: good-first-bug
Whiteboard: [tabs][good first bug] triaged → [tabs]triaged
(In reply to Atique Ahmed Ziad [:atiqueahmedziad] from comment #7)
> Yes, I am trying to build firefox locally. I will update you within next
> week.

Hey Atique, are you still planning to work on this? Do you need some help?
Flags: needinfo?(softfilebd)
It looks like this got fixed by bug 1285493, but a test could still be useful here.
Assignee: nobody → tomica
Status: NEW → ASSIGNED
Flags: needinfo?(softfilebd)
Summary: reported current window is incorrect after tab is detached → Add test that current window is correct after tab is detached
note that this test depends on windows.create() waiting for browser-delayed-startup-finished before resolving, which is fixed by my patch in bug 1273146.
Depends on: 1273146
Comment on attachment 8799526 [details]
bug 1281354 - test current window correct after moving tab,

https://reviewboard.mozilla.org/r/84670/#review83818

looks good, with a couple little nitpicks.  thanks!

::: browser/components/extensions/test/browser/browser_ext_tabs_move_window.js:66
(Diff revision 1)
> +    const url = browser.extension.getURL("current.html");
> +    browser.tabs.create({url}).then(tab => {
> +      tabId = tab.id;
> +    });
> +    browser.test.onMessage.addListener(msg => {
> +      if (msg === "create") {

can you call this "move" just to be more clear

::: browser/components/extensions/test/browser/browser_ext_tabs_move_window.js:92
(Diff revision 1)
> +  yield extension.awaitMessage("moved");
> +
> +  extension.sendMessage("current");
> +  const second = yield extension.awaitMessage("id");
> +
> +  ok(first !== second, "current window id is different after moving the tab");

you can just do `isnot(first, second, "...")`
Attachment #8799526 - Flags: review?(aswan) → review+
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/db47a06d14eb
test current window correct after moving tab, r=aswan
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/db47a06d14eb
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: