Closed
Bug 1234308
Opened 9 years ago
Closed 8 years ago
tabs.onCreated callback should receive a bare tab object as its argument
Categories
(WebExtensions :: Untriaged, defect, P4)
Tracking
(firefox47 fixed)
RESOLVED
FIXED
mozilla47
Tracking | Status | |
---|---|---|
firefox47 | --- | fixed |
People
(Reporter: general, Assigned: mattw, Mentored)
Details
(Whiteboard: [tabs][good first bug] triaged)
Attachments
(2 files, 4 obsolete files)
74.55 KB,
image/png
|
Details | |
2.89 KB,
patch
|
kmag
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 Build ID: 20151210112434 Steps to reproduce: chrome.tabs.onCreated.addListener(function onCreated(tab) { console.log(tab); // { tab: { tab: ... } } }); Actual results: The tab paremeter is an nested object Expected results: The tab paremeter should be a plain object Firefox dev-edition 45.0a2 (2015-12-21) Linux x64
Updated•8 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: blocking-webextensions+
Summary: chrome.tabs.onCreated callback parameter is nested object → tabs.onCreated callback should receive a bare tab object as its argument
Updated•8 years ago
|
Mentor: kmaglione+bmo
Whiteboard: [tabs][good first bug]
Updated•8 years ago
|
Assignee: nobody → mwein
Assignee | ||
Comment 1•8 years ago
|
||
Attachment #8712803 -
Flags: review?(kmaglione+bmo)
Comment 2•8 years ago
|
||
Comment on attachment 8712803 [details] [diff] [review] Fixes the tabs.onCreated callback to receive a bare tabs object Review of attachment 8712803 [details] [diff] [review]: ----------------------------------------------------------------- This is very close. We just need to be a little stricter. ::: browser/components/extensions/test/browser/browser_ext_tabs_create.js @@ +123,5 @@ > browser.tabs.onUpdated.addListener(onUpdated); > }); > > + browser.tabs.onCreated.addListener(tab => { > + browser.test.assertTrue("id" in tab, `Expected tabs.onCreated callback to receive tab object`); We need to test that this is actually called. The easiest way would be to add a |createdPromise| to match the |updatedPromise| above.
Attachment #8712803 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 4•8 years ago
|
||
Attachment #8712803 -
Attachment is obsolete: true
Attachment #8712886 -
Flags: review?(kmaglione+bmo)
Comment 5•8 years ago
|
||
Comment on attachment 8712886 [details] [diff] [review] Fixes the tabs.onCreated callback to receive a bare tabs object (patch v2) Review of attachment 8712886 [details] [diff] [review]: ----------------------------------------------------------------- ::: browser/components/extensions/test/browser/browser_ext_tabs_create.js @@ +132,3 @@ > }); > > + promiseTabs.create(test.create).then(createdPromise).then(tab => { The argument to .then() should be a function, not a promise, so this should look something like the other handlers: promiseTabs.create(test.create).then(() => { return createdPromise; }).then(tab => { It would be better to use the tab returned by .create(), though, so something like this would work: Promise.all([ promiseTabs.create(test.create), createdPromise, }).then(([tab]) => { The Promise.all returns a new promise which resolves when all of the promises in the array you pass it resolves. The ([tab]) in the callback destructures the array of results that that promise returns, and gives you the tab returned by promiseTabs.create.
Attachment #8712886 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 6•8 years ago
|
||
I also have createdPromise resolve with a tab, so I think the array passed into the .then() call will be [tab, tab]. If that's true then the destructuring would seem a bit confusing. Should I go ahead and make createdPromise resolve with nothing to ensure that .then() gets the tab returned by promiseTabs.create?
Comment 7•8 years ago
|
||
You should probably change it to resolve with nothing, yes, but it doesn't really matter. You'll still get a two-element array as the result, and the first element will still be the tab from .create(). I wouldn't worry too much about it being confusing. Our code does this all over the place.
Assignee | ||
Comment 8•8 years ago
|
||
Attachment #8712886 -
Attachment is obsolete: true
Attachment #8712940 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 9•8 years ago
|
||
Sounds good.
Assignee | ||
Comment 10•8 years ago
|
||
Attachment #8712948 -
Flags: review?(kmaglione+bmo)
Comment 11•8 years ago
|
||
Comment on attachment 8712948 [details] [diff] [review] Fix tabs.onCreated callback to receive bare tabs object () Review of attachment 8712948 [details] [diff] [review]: ----------------------------------------------------------------- https://treeherder.mozilla.org/#/jobs?repo=try&revision=1625b9c71bd4 ::: browser/components/extensions/test/browser/browser_ext_tabs_create.js @@ +126,5 @@ > + let createdPromise = new Promise(resolve => { > + let onCreated = tab => { > + browser.test.assertTrue("id" in tab, `Expected tabs.onCreated callback to receive tab object`); > + resolve(); > + } You're missing a semicolon.
Attachment #8712948 -
Flags: review?(kmaglione+bmo) → review+
Assignee | ||
Comment 12•8 years ago
|
||
Attachment #8712956 -
Flags: review?(kmaglione+bmo)
Comment 13•8 years ago
|
||
Comment on attachment 8712956 [details] [diff] [review] Fix tabs.onCreated callback to receive bare tabs object () In the future, you can just set r+ when you update a patch that already has r+
Attachment #8712956 -
Flags: review?(kmaglione+bmo) → review+
Updated•8 years ago
|
Attachment #8712948 -
Attachment is obsolete: true
Updated•8 years ago
|
Attachment #8712940 -
Attachment is obsolete: true
Attachment #8712940 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 14•8 years ago
|
||
Okay cool, will do.
Updated•8 years ago
|
Priority: -- → P4
Whiteboard: [tabs][good first bug] → [tabs][good first bug] triaged
Assignee | ||
Updated•8 years ago
|
Keywords: checkin-needed
Assignee | ||
Comment 15•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=8aee6a96f113
Comment 16•8 years ago
|
||
https://hg.mozilla.org/integration/fx-team/rev/1b4278d9c84c
Keywords: checkin-needed
Comment 17•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/1b4278d9c84c
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox47:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Updated•6 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•