Skip to content

Fixes #143 - Use updated Chrome scripting API for snippets

Anton Smirnov requested to merge 143_scripting-api into master

The MR updates the way how setLibrary arguments are accepted (now they have to be callbacks, not strings!) for both MV2 and MV3. The reason is that in MV2 Chromium API accepts strings and in MV3 it accepts callbacks. So we had to accept callbacks too in setLibrary and regenerate the snippet code strings for MV2.

It requires changes on caller side (webext) for MV2. The original design idea belongs to @tonimellodic (and the authorship lost due to squashing) and it was chosen by webext guys from different options.

The tests are changed to correspond the requirements: no more setTestSnippet() calls. Now background.js does the init and uses hardcoded snippets names. The tests now test execution in injected and isolated worlds separately and work in both MV2 and MV3. Also the tests now cover proper arguments passing to the snippet - previously true was hardcoded in the snippet body, now it'a accepted as argument and set to some flag that is asserted later.

Edited by Anton Smirnov

Merge request reports