"Block element" feature not available for tabs that are still loading after content scripts are ready
Environment
- OS version: Manjaro with Kernel 5.19.17-2
- Browser version: Chromium 107.0.5304.110
- Extension version: ABP 3.15
- Last working version: ABP 3.14.2
Steps to reproduce
There are two options to reproduce this issue:
a) Natural way - not very precise as it all depends on the loading speeds of the page and the extension, as well as cache affecting the results:
- Disable cache through developer tools (Network tab).
- Open a heavy page like
https://www.marca.com
. Recommended a hard refresh (Shift-F5). - Wait until the page finishes loading ("loading" tab icon is removed) and open the ABP popup.
b) (recommended, only Chromium based [1]) Forcing a tab's "loading" event after the extension finishes loading the content scripts:
- Disable cache through developer tools (Network tab).
- Go to
https://example.com/
and wait until page loads. Open ABP popup menu, the block element feature should be available as the page is not heavy. - Append an iframe to the document, e.g.
const iframe = document.createElement("iframe"); document.body.appendChild(iframe); iframe.src = "";
- Change the
src
attribute that will force the tab to change its state to "loading":iframe.src = https://example.com/
[1]: The method (b) doesn't work on Firefox, as the tab's "loading" event doesn't get triggered through iframe loading.
Observed behavior
The "block element" button doesn't appear in the popup
Expected behavior
The "block element" button should appear in the popup
Further information
In ABP 3.15, we shipped (https://gitlab.com/adblockinc/ext/adblockplus/adblockplusui/-/issues/1070) a new tab session state logic as part of MV3 required changes, that logic purges the tab session state on "loading" tab events. As, for the filter composer, we are not reacting to future "complete" tab events, the extension will either forget that the page was ready to use the composer or fail to check again if it's ready. Which means that in cases where the page loads after the composer content script finishes loading, like heavy or complex pages, the extension won't provide the "block element" feature to the user.
Hints for testers
The following state should be as expected while navigating between web pages:
- Icon badge state (i.e. badge text, whether the badge text hidden).
- Icon allowlisted state (i.e. whether tab is allowlisted).
- Blocked counter state (i.e. page-specific blocked counter shown in icon and in icon popup).
- Developer tools reload state (i.e. whether "reload" link is shown in developer tools panel).
- Filter composer active state (i.e. whether the content script is running that causes the Block element button to be shown in the icon popup).