Opened 11 months ago

Last modified 6 months ago

#6446 reviewing change

Avoid injecting same style sheet twice

Reported by: mjethani Assignee: mjethani
Priority: P3 Milestone:
Module: Core Keywords: circumvention
Cc: kzar, sebastian, amrmak Blocked By:
Blocking: #6422 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29714638/
https://codereview.adblockplus.org/29728690/

Description (last modified by mjethani)

Background

Consider this document:

<style>
div {
  color: red;
}
</style>
<div id="price">0.9109041176174169</div>
<script>
setInterval(() =>
{         
  document.getElementById("price").textContent = Math.random();
},
1000);
</script>

And this filter: 127.0.0.1#?#:-abp-properties(color: red)

On Firefox this causes the same style sheet to be injected every one second. Since this is not allowed on Firefox, tabs.insertCSS throws. It is allowed on Chrome though (I implemented it), and Chrome will just insert a duplicate style sheet. Subsequent calls to tabs.removeCSS will then only remove the last matching style sheet.

The correct thing to do here is to make sure we don't inject the same style sheet twice.

Also see #6458.

What to change

In lib/content/elemHideEmulation.js, do not add the exact same list of selectors twice.

Change History (6)

comment:1 Changed 11 months ago by mjethani

  • Cc kzar sebastian added
  • Owner set to mjethani

comment:2 Changed 11 months ago by mjethani

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

comment:3 Changed 11 months ago by sebastian

  • Priority changed from Unknown to P3
  • Ready set

comment:4 Changed 11 months ago by amrmak

  • Cc amrmak added

comment:5 Changed 7 months ago by mjethani

  • Review URL(s) modified (diff)

Second attempt at fixing this: patch #29728690

comment:6 Changed 6 months ago by mjethani

  • Component changed from Platform to Core
  • Description modified (diff)

This should be fixed in core.

Note: See TracTickets for help on using tickets.