Opened 18 months ago

Last modified 13 months ago

#7271 closed change

Adjust Chrome API calls to use Promises where possible — at Version 6

Reported by: kzar Assignee: kzar
Priority: P2 Milestone: Adblock-Plus-for-Chrome-Opera-Firefox-next
Module: Platform Keywords: manifestv3
Cc: sebastian, greiner Blocked By: #7327
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

Description (last modified by kzar)


For version 3 of Chrome's extension manifest format, one planned change is to switch from callbacks to Promises for the Chrome APIs. From the draft spec:

Extension APIs will be promise-based. The older callback version will continue to be supported...

In order to maintain backwards compatibility (and not force developers to rewrite their extension
more than they already have to), providing a callback to an API method will continue to work. If
a callback is provided, a promise will not be returned.

What to change

  • Where possible use Promises instead of callbacks when using the browser.* or chrome.* APIs.
  • Rewrite the lib/options.js code around promises.
  • Update the adblockplusui dependency to include the related changes for #7327.


  • See #7272 for the equivalent adblockplusui changes.

Hints for testers

Unfortunately a whole bunch of code paths were touched with these changes. As far as possible please smoke test all functionality with Edge, old version of Chrome, new version of Chrome, Firefox on mobile, old version of Firefox desktop and new version of Firefox desktop.

A (not complete) list of functionality that was touched:

  • Logic to open options page, both from popup, notifications and subscription links.
  • "Block element" tool.
  • Our developer tools panel.
  • Collapsing (hiding) of blocked elements.
  • Element hiding.
  • WebRTC blocking.
  • ABP icon animations (e.g. when a critical notification is received).
  • Block counter, including after the preference to show it is disabled then enabled again.
  • Options page opening correctly on mobile vs desktop.

Change History (6)

comment:1 Changed 18 months ago by kzar

  • Description modified (diff)

comment:2 Changed 18 months ago by greiner

For reference, I've created #7272 for doing the same in adblockplusui.

comment:3 Changed 18 months ago by kzar

  • Description modified (diff)

comment:4 Changed 18 months ago by kzar

  • Description modified (diff)

comment:5 Changed 17 months ago by kzar

  • Blocked By 7327 added

comment:6 Changed 17 months ago by kzar

  • Description modified (diff)
Note: See TracTickets for help on using tickets.