Closed Bug 1273146 Opened 10 years ago Closed 9 years ago

WebExtensions: chrome.windows.create - callback parameter (window) does not have window.tabs property

Categories

(WebExtensions :: Untriaged, defect, P2)

46 Branch
defect

Tracking

(firefox52 fixed)

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: dw-dev, Assigned: zombie, Mentored)

References

Details

(Keywords: dev-doc-complete, Whiteboard: [windows]triaged)

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0 Build ID: 20160502172042 Steps to reproduce: I tried to execute the following code: chrome.windows.create({ type: "normal", tabId: tabId }, function(newwin) { var win_id, tab_id; win_id = newwin.id; tab_id = newwin.tabs[0].id; }); Actual results: The code fails with the following error message: "newwin.tabs is undefined". Expected results: tab_id should be assigned the id of the first tab in the new window.
Component: Untriaged → WebExtensions
Product: Firefox → Toolkit
need to check Chrome code to see what should happen / when. normally there with query with populate.
Assignee: nobody → bob.silverberg
Whiteboard: [investigate] triaged
I have confirmed that Chrome does return an array of tabs for the window when calling `windows.create()`. The docs [1] are non-specific about this. We should fix this, and this bug can be used to track that. We should also update our docs for the API [2] to indicate that tabs can be expected for a window that was just created. [1] https://developer.chrome.com/extensions/windows#method-create [2] https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/windows/create
Status: UNCONFIRMED → ASSIGNED
Iteration: --- → 49.2 - May 23
Ever confirmed: true
Keywords: dev-doc-needed
Assignee: bob.silverberg → nobody
Mentor: bob.silverberg
Status: ASSIGNED → NEW
Iteration: 49.2 - May 23 → ---
Priority: -- → P2
Whiteboard: [investigate] triaged → [good first bug][windows] triaged
Assignee: nobody → amckay
Attached patch second-patch.txtSplinter Review
Attachment #8754497 - Flags: feedback?(bob.silverberg)
Comment on attachment 8754497 [details] [diff] [review] second-patch.txt Review of attachment 8754497 [details] [diff] [review]: ----------------------------------------------------------------- This looks good Andy, nice work! I'm wondering if we should also add some checks into the tests in `browser_ext_windows_create.js` which create windows that do not inherit tabs? Looking at the code change there is no reason to expect that call to `windows.create()` to behave any differently from the one being tested here, but we might want that extra coverage just in case.
Attachment #8754497 - Flags: feedback?(bob.silverberg) → feedback+
That seems like a good idea, I'll look into it.
Turns out, if you send multiple tabs to create, it loops through each tab creating a tab in order. But you only get one tab in the window.tabs response. I think this is because it creates the tab in order and sends a document-shown event when that first tab has loaded. As soon as the first document-shown is completed it sends the callback, and then the next tab loads. I'm assuming we should wait for all the documents to be shown for each tab before sending the callback.
Minor correction, its just listening for load on the window and then returning once that has happened.
Other methods have the same issue. For example, chrome.windows.get gives a windows.Window object without a tabs property.
(In reply to Brian Kieffer from comment #10) > Other methods have the same issue. For example, chrome.windows.get gives a > windows.Window object without a tabs property. Oops. I am stupid. I need to specify populate.
(In reply to Brian Kieffer from comment #11) If you think there's a problem there, could you file a separate bug please?
Attached file second-patch.txt
Unassigning and throwing back into the pool, I'm unlikely to get any further on this for a while. This is the last patch I had, it uses the browser-delayed-startup-finished event to catch the scenario when you create multiple tabs in a window. Got stuck on the Linux test failures on the try server which I haven't had time to look at.
Assignee: amckay → nobody
Keywords: good-first-bug
Whiteboard: [good first bug][windows] triaged → [windows]triaged
Attachment #8799189 - Flags: review?(kmaglione+bmo)
Assignee: nobody → tomica
Status: NEW → ASSIGNED
Comment on attachment 8799189 [details] bug 1273146 - populate tabs in windows.create() return value https://reviewboard.mozilla.org/r/84488/#review83030 ::: browser/components/extensions/ext-windows.js (Diff revision 2) > - window.addEventListener("load", function listener() { > - window.removeEventListener("load", listener); > + .then(() => { > + if (createData.state !== null) { > - > - if (createData.state == "maximized" || createData.state == "normal" || > - (createData.state == "fullscreen" && AppConstants.platform != "macosx")) { > - window.document.documentElement.setAttribute("sizemode", createData.state); Most states don't work here, and setting `fullscreen` before `delayed-startup-finished` even breaks browser's `delayedStartup` (it throws, never sends the notification), so I simplified and used `setState()` for everything. Since we now always need to wait for `delayed-startup-finished`, I don't think there is any benefit in trying to set some states earlier.
Blocks: 1281354
Comment on attachment 8799189 [details] bug 1273146 - populate tabs in windows.create() return value https://reviewboard.mozilla.org/r/84488/#review83030 > Most states don't work here, and setting `fullscreen` before `delayed-startup-finished` even breaks browser's `delayedStartup` (it throws, never sends the notification), so I simplified and used `setState()` for everything. Since we now always need to wait for `delayed-startup-finished`, I don't think there is any benefit in trying to set some states earlier. reverted per irc conversation with Kris.
Comment on attachment 8799189 [details] bug 1273146 - populate tabs in windows.create() return value https://reviewboard.mozilla.org/r/84488/#review84272 ::: browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js:118 (Diff revision 3) > + browser.test.assertEq(2, window.tabs.length, "2 tabs were opened in new window"); > + browser.test.assertEq("about:blank", window.tabs[0].url, "about:blank, page not loaded yet"); > + browser.test.assertEq("about:blank", window.tabs[1].url, "about:blank, page not loaded yet"); > + > return Promise.all([ > promiseTabUpdated("http://example.com/"), > promiseTabUpdated("http://example.org/"), > Promise.resolve(window), > ]); Hm. This all seems a bit racy, but I guess it's not really a new race, at least...
Attachment #8799189 - Flags: review?(kmaglione+bmo) → review+
Pushed by cbook@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d8aafc5269fb populate tabs in windows.create() return value r=kmag
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
I've updated https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/windows/create to clarify that the returned Window always contains tabs, and to note that Firefox only supports this from version 52. Please let me know if this covers it.
Flags: needinfo?(tomica)
Looks good, thanks.
Flags: needinfo?(tomica)
Keywords: dev-doc-needed
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: