Merge pull request #10038 from brave/cosmeticfix

Fix cosmetic filters first party machinery #10035
This commit is contained in:
Mikhail
2021-09-13 22:41:58 +07:00
committed by GitHub
8 changed files with 65 additions and 57 deletions
+24 -1
View File
@@ -23,6 +23,8 @@ let didWait = false;
function checkSelector(selector, property, expected) {
const checkSelectorInner = () => {
let elements = [].slice.call(document.querySelectorAll(selector));
if (elements.length === 0)
return false
let result = elements.every(e => {
let style = window.getComputedStyle(e);
return style[property] === expected;
@@ -47,12 +49,33 @@ function checkSelector(selector, property, expected) {
</script>
</head>
<body>
<div class="fpsponsored"><img src="b.com/sponsored/640x820.png"></div>
<div id="ad-banner"><img src="https://example.com/logo.png" alt=""></div>
<div class="ad-banner">
<div class="ad" style="background: url(example.com)"><img src="https://example.com/logo.png" alt=""></div>
</div>
<div class="ad" style="background: url(example.com)"><img src="https://example.com/logo.png" alt=""></div>
<div class="ad" style="background: url(example.com)"><img src="https://example.com/logo.png" alt=""></div>
<!-- Assume that the document host is test.lion.appspot.com (see AdBlockServiceTest.*) -->
<div id="relative-url-div" class="fpsponsored">
A text of 30 chars and 5 words is needed here to consider element significant.
<img src="/sponsored/640x820.png">
</div>
<div id="same-origin-div" class="fpsponsored1">
A text of 30 chars and 5 words is needed here to consider element significant.
<img src="http://test.lion.appspot.com/sponsored/640x820.png">
</div>
<div id="subdomain-div" class="fpsponsored2">
A text of 30 chars and 5 words is needed here to consider element significant.
<img src="http://sub.test.lion.appspot.com/sponsored/640x820.png">
</div>
<div id="same-etld" class="fpsponsored3">
A text of 30 chars and 5 words is needed here to consider element significant.
<img src="http://another.lion.appspot.com/sponsored/640x820.png">
</div>
<div id="another-etld" class="fpsponsored4">
A text of 30 chars and 5 words is needed here to consider element significant.
<img src="http://chrome.appspot.com/sponsored/640x820.png">
</div>
</body>
</html>