Opened on 03/08/2018 at 10:41:42 PM
Closed on 08/04/2018 at 12:13:19 PM
#6458 closed defect (worksforme)
Element hiding emulation breaks when a new style sheet is loaded
Reported by: | mjethani | Assignee: | |
---|---|---|---|
Priority: | Unknown | Milestone: | |
Module: | Core | Keywords: | circumvention |
Cc: | hfiguiere, sebastian | Blocked By: | |
Blocking: | #6422 | Platform: | Unknown / Cross platform |
Ready: | no | Confidential: | no |
Tester: | Unknown | Verified working: | no |
Review URL(s): |
Description (last modified by mjethani)
Environment
A recent version of Adblock Plus with no filter lists
How to reproduce
- Add the filter 127.0.0.1#?#:-abp-properties(color: red)
- Load the following HTML off 127.0.0.1
<style> div { color: red; } </style> <div id="price">0.9109041176174169</div> <script> setTimeout(() => { let link = document.createElement("link"); link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"); document.head.appendChild(link); }, 5000); </script>
- Wait for 5 seconds
Observed behaviour
Initially the div#price element is hidden, but after 5 second it appears again once the remote style sheet has finished loading
Expected behaviour
The div#price element should remain hidden
Notes
This occurs because we only parse the newly added style sheet, so we end up overwriting the previous style sheet that had selectors relevant to the original style sheet.
Resolution
This bug seems to have been fixed by recent changes and is no longer reproducible as of changeset 64e29bc1a787.
Attachments (0)
Change History (5)
comment:1 Changed on 03/08/2018 at 10:43:03 PM by mjethani
- Cc hfiguiere sebastian added
comment:2 Changed on 03/08/2018 at 10:49:00 PM by mjethani
comment:3 Changed on 03/08/2018 at 10:50:25 PM by mjethani
- Keywords circumvention added
comment:4 Changed on 03/08/2018 at 10:55:05 PM by mjethani
Oh, we could consider this a Platform regression because of adblockpluschrome rev:8399e34fff05, but I think we have to fix the underlying issue in both Core and Platform.
To fix this we should implement an append-only mode, similar to what I proposed for the collapsing selectors in patch 29670575. When only a new style sheet has been added to the document (so _addSelectors gets the stylesheets argument), we should collect any new selectors and pass the new appendOnly flag to addSelectorsFunc, which will only add the new selectors without removing any old selectors from the document.