browser.tabs.query() expects a callback instead of returning a promise

By design Issue #9421085

Details

Author
Wladimir P.
Created
Oct 19, 2016
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
14.14393
Reports
Reported by 7 people

Sign in to watch or report this issue.

Steps to reproduce

In an extension, use the following code:

browser.tabs.query({}).then(result => console.log(result));

This throws an exception:

Invocation of form tabs.query(object) doesn’t match definition tabs.query(object queryInfo, function callback).

This API is supposed to be supported and links to https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/query. There it says: “This API is also available as browser.tabs.query() in a version that returns a promise.” So it is supposed to return a promise, just like all the other APIs - yet currently it expects a callback, just like chrome.tabs.query(). All other calls on browser.tabs appear to have the same issue.

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Ibrahim O.”

      Changed Assigned To from “Ibrahim O.” to “Chee C.”

      Changed Status to “Confirmed”

      Changed Assigned To from “Chee C.” to “Brad E.”

      Changed Assigned To from “Brad E.” to “Chee C.”

    • This issue makes using the Edge API extremely confusing for developers accustomed to building extensions for Chrome and Firefox. One purpose of using the browser variable in place of the chrome variable is to signify that the browser supports the newer promise API. This issue therefore voids the use of the browser polyfill that helps with callback-based APIs and requires cross-browser extensions to be hard-coded to use either a Promise or callback in a case-by-case basis each time the API is used.

      If shifting the API to use promises is not possible, then Edge should either use the chrome variable or provide some other Edge-specific method to allow for a polyfill to be implemented. The chrome variable could be added alongside the current browser variable; the polyfill could re-write the browser method to call on the chrome API.

    • How is this issue not resolved yet?

    • Microsoft Edge Team

      Changed Status from “Confirmed” to “By design”

    • @Chee C. May I ask the intention of making this issue “by design?” The current method does not conform to either accepted WebExtension standard.

      I see that the assignment switched four times. The simplest fix is to use the chrome variable either alongside or instead of the browser variable.

    • Hello,

      Thank you for providing this information about the issue. A Microsoft Edge Extension does not support the Promise model; this is a documented difference between Mozilla and Edge’s platform. Currently, we do not plan to release a fix. Please update this case if you can provide new information for us to consider.

      Best Wishes,
      The MS Edge Team

    • This decision means there is no reason to use the browser.* API. You don’t get the benefit of promises, and it behaves differently across Firefox and Edge. With this decision, the only API you can reliably use across platforms is the chrome.* APIs. It seems counter-intuitive to encourage developers to target another browser first.

    • This decision means there is no reason to use the browser.* API. You don’t get the benefit of promises, and it behaves differently across Firefox and Edge. With this decision, the only API you can reliably use across platforms is the chrome.* API. It seems counter-intuitive to encourage developers to target another browser first.

    You need to sign in to your Microsoft account to add a comment.

    Sign in