Skip to content

feat: Added devtools.panels.elements.createSidebarPane to metadata#247

Merged
rpl merged 2 commits intomozilla:masterfrom
akhilpanchal:add-chrome-devtools-createSideBarPane-api
Oct 29, 2020
Merged

feat: Added devtools.panels.elements.createSidebarPane to metadata#247
rpl merged 2 commits intomozilla:masterfrom
akhilpanchal:add-chrome-devtools-createSideBarPane-api

Conversation

@akhilpanchal
Copy link
Contributor

Fixes #246

"elements": {
"createSidebarPane": {
"minArgs": 1,
"maxArgs": 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks that "maxArgs" should be set to 1 for devtools.elements.createSidebarPane:

and so maxArgs should be set to the maximum number of parameters that the API method does expect without counting the optional callback.

The reason for that is that the corresponding promised-based API method signature shouldn't expect a callback parameter (and the polyfill will pass a callback internally to the wrapped chrome callback-based API method), e.g.:

chrome.devtools.panels.elements.createSidebarPane("my sidebar", (sidebarPanel) => ...);

translates into:

const sidebarPanel = await browser.devtools.panels.elements.createSidebarPane("my sidebar");
...
// or
devtools.panels.elements.createSidebarPane("my sidebar").then(sidebarPanel => ...);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for the explanation. That makes a lot of sense.
Could you also explain what the role of singleCallbackArg property is?
I looked at the following lines and I am a little unsure about when to use this property.

} else if (metadata.singleCallbackArg ||
(callbackArgs.length <= 1 && metadata.singleCallbackArg !== false)) {
promise.resolve(callbackArgs[0]);
} else {
promise.resolve(callbackArgs);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, see #168 (comment)

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Thanks @akhilpanchal

@rpl rpl merged commit a0cd3fd into mozilla:master Oct 29, 2020
@caitmuenster
Copy link

Thanks so much, @akhilpanchal! Your contribution has been added to our recognition wiki. 🎉

Welcome onboard! We look forward to seeing you around.

@akhilpanchal akhilpanchal deleted the add-chrome-devtools-createSideBarPane-api branch October 30, 2020 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

browser.devtools.panels.elements.createSidebarPane('Gem') return undefined on Chrome

4 participants