Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All browserAction / pageAction methods support callbacks in Chrome 67+ #99

Closed
Rob--W opened this issue Mar 26, 2018 · 3 comments
Closed

Comments

@Rob--W
Copy link
Member

Rob--W commented Mar 26, 2018

Chrome 67+ supports callbacks for all pageAction / browserAction methods, since https://bugs.chromium.org/p/chromium/issues/detail?id=451320#c10

The polyfill should pass a callback for these methods, in order to catch any errors. The logic to do so is described at #13 (comment)

@rpl
Copy link
Member

rpl commented Mar 26, 2018

We currently call these API method with the callback first (at least the ones that were already identified when we were working on #59), and then if the call with the callback is raising an error, we retry the API call without the callback:

if (metadata.fallbackToNoCallback) {
// This API method has currently no callback on Chrome, but it return a promise on Firefox,
// and so the polyfill will try to call it with a callback first, and it will fallback
// to not passing the callback if the first call fails.
try {
target[name](...args, makeCallback({resolve, reject}, metadata));
} catch (cbError) {
console.warn(`${name} API method doesn't seem to support the callback parameter, ` +
"falling back to call it without a callback: ", cbError);
target[name](...args);
// Update the API method metadata, so that the next API calls will not try to
// use the unsupported callback anymore.
metadata.fallbackToNoCallback = false;
metadata.noCallback = true;
resolve();
}
} else if (metadata.noCallback) {
target[name](...args);
resolve();

@Rob--W Do you mind to check if this is working as expected in Chrome 67+?
and if there are any other API methods that should be marked with the same metadata property (fallbackToNoCallback).

So that we can detail more clearly what is actually missing so that we can consider this issue as fixed.

@Rob--W
Copy link
Member Author

Rob--W commented Mar 26, 2018

The patch in Chrome 67 has just landed, so it will take a short while until Canary has the patch.

The following pageAction and browserAction methods are missing from api-metadata.json:

  • setBadgeText
  • setBadgeBackgroundColor

The following browserAction methods are missing:

  • enable
  • disable
  • setPopup

@Rob--W
Copy link
Member Author

Rob--W commented Jun 19, 2018

Fixed by #125 .

@Rob--W Rob--W closed this as completed Jun 19, 2018
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

No branches or pull requests

2 participants