Opened 10 months ago

Last modified 5 months ago

#7271 closed change

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

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: #7334 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

https://gitlab.com/eyeo/adblockplus/adblockpluschrome/merge_requests/42

Description (last modified by kzar)

Background

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.

Tip: Use this patch to find all the calls that need to be fixed.

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. Including focusing the page if it's already open (even if that's in a different window), logic to add dialogues e.g. when clicking on 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.

Notes

  • See #7272 for the equivalent adblockplusui changes.

Change History (11)

comment:1 Changed 10 months ago by kzar

  • Description modified (diff)

comment:2 Changed 10 months ago by greiner

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

comment:3 Changed 10 months ago by kzar

  • Description modified (diff)

comment:4 Changed 10 months ago by kzar

  • Description modified (diff)

comment:5 Changed 9 months ago by kzar

  • Blocked By 7327 added

comment:6 Changed 9 months ago by kzar

  • Description modified (diff)

comment:7 Changed 9 months ago by kzar

  • Description modified (diff)

comment:8 Changed 9 months ago by kzar

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:9 Changed 9 months ago by kzar

  • Blocking 7334 added

comment:10 Changed 9 months ago by mjethani

  • Description modified (diff)

comment:11 Changed 9 months ago by kzar

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