Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#3515 closed change (fixed)

Use ES6 promises

Reported by: sebastian Assignee: sebastian
Priority: P3 Milestone: Adblock-Plus-1.10.1-for-Chrome-Opera-Safari
Module: Platform Keywords:
Cc: kzar Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Scheer Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29333514
https://codereview.adblockplus.org/29333518
https://codereview.adblockplus.org/29333522
https://codereview.adblockplus.org/29333528
https://codereview.adblockplus.org/29333533
https://codereview.adblockplus.org/29333538
https://codereview.adblockplus.org/29333541
https://codereview.adblockplus.org/29333544

Description (last modified by sebastian)

Background

Promises make asynchronous code easier to write and read and therefore contribute to a better code quality and fewer bugs.

ES2015 (aka ES6) introduced promises as part of the JavaScript language. This has been implemented by now in recent versions of Chrome, Opera and Safari. Though we still support older versions of these browsers that lack native support. This however isn't a problem as we can use a polyfill.

The extension API and our abstraction layer shouldn't be considered for now. There is a Chrome bug to support promises in the extension API. Theoretically, we could already support promises in our abstraction layer, but I'm still undecided what the approach should be there.

What to change

  • Add polyfills for the Promise class and fetch() API.
  • Replace usage of XMLHttpRequest with fetch().
  • Replace the Prefs.onLoaded event with a Prefs.isLoadedpromise.

Hints for testers

  • Make sure that extension initialization works
    • so that settings are preserved when restarting the browser or updating the extension.
    • so that default filter lists are configured and that the first run page shows for new installs.
  • Make sure that the options page, and in particular adding new filter lists from the dropdown, works.
  • Also test on older browser versions, in particular Chrome <32 and Safari 6.

Change History (8)

comment:1 Changed 4 years ago by sebastian

  • Review URL(s) modified (diff)

comment:2 Changed 4 years ago by sebastian

  • Description modified (diff)
  • Ready set

comment:3 Changed 4 years ago by kzar

  • Cc kzar added

comment:4 Changed 4 years ago by sebastian

  • Status changed from new to reviewing

comment:6 Changed 4 years ago by sebastian

  • Description modified (diff)

comment:7 Changed 4 years ago by scheer

Done.

  • Extension initialization works.
  • Settings are preserved when restarting the browser or updating the extension.
  • Default lists are configured and first page runs on installation.
  • Options Page and 'add filter subscription' drop down menu functions.

Chrome 30,31,32,44,45,46,48
Safari 6
Adblock Plus 1.10.0.1534

Last edited 4 years ago by scheer (previous) (diff)

comment:8 Changed 4 years ago by scheer

  • Tester changed from Unknown to Scheer
  • Verified working set
Note: See TracTickets for help on using tickets.