mirror of https://github.com/gorhill/uBlock.git
Add test pages for procedural filters
Procedural cosmetic filters: https://gorhill.github.io/uBlock/tests/procedural-cosmetic-filters.html Procedural HTML filters: https://gorhill.github.io/uBlock/tests/procedural-html-filters.html
This commit is contained in:
parent
d1a08af3ab
commit
10236552ca
|
@ -12,6 +12,8 @@
|
|||
<li><a href="https://raw.githack.com/gorhill/uBlock/master/docs/tests/hntrie-test.html">HNTrie: tests</a>
|
||||
<li><a href="https://raw.githack.com/gorhill/uBlock/master/docs/tests/hnset-benchmark.html">HNTrie, small (2) to medium (~1000) set: benchmarks</a>
|
||||
<li><a href="https://raw.githack.com/gorhill/uBlock/master/docs/tests/hnbigset-benchmark.html">HNTrie, small (2) to large (40,000+) set: benchmarks</a>
|
||||
<li><a href="procedural-cosmetic-filters.html">Procedural cosmetic filters</a>
|
||||
<li><a href="procedural-html-filters.html">Procedural HTML filters</a>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Procedural cosmetic filters</title>
|
||||
<style>
|
||||
.filters {
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
.tests {
|
||||
align-items: flex-start;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.tile {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
margin: 0 20px 10px 0;
|
||||
min-width: 200px;
|
||||
}
|
||||
.tile div {
|
||||
align-items: center;
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.tile > div {
|
||||
height: 100px;
|
||||
position: relative;
|
||||
}
|
||||
.tile > div > div {
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.pass {
|
||||
background-color: green;
|
||||
}
|
||||
.pass::before {
|
||||
content: 'pass';
|
||||
}
|
||||
.fail {
|
||||
background-color: red;
|
||||
}
|
||||
.fail::before {
|
||||
content: 'fail';
|
||||
}
|
||||
a, b {
|
||||
display: none;
|
||||
}
|
||||
a::before {
|
||||
opacity: 0;
|
||||
}
|
||||
b::after {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Procedural cosmetic filters</h1>
|
||||
<h3>Filters</h3>
|
||||
<div class="filters"><noscript>Enable JavaScript to see needed filters</noscript></div>
|
||||
|
||||
<h3>Tests</h3>
|
||||
<div id="pcf" class="tests">
|
||||
|
||||
<div id="a1" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>#pcf #a1 .fail:has(b)</code>
|
||||
</div>
|
||||
|
||||
<div id="a2" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>#pcf #a2 .fail:has(> a > b)</code>
|
||||
</div>
|
||||
|
||||
<div id="a3" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>#pcf #a3 .fail:not(:has(c))</code>
|
||||
</div>
|
||||
|
||||
<div id="a4" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b>I am a needle!!!</b></a></div></div>
|
||||
<code>#pcf #a4 .fail:has-text(needle)</code>
|
||||
</div>
|
||||
|
||||
<div id="a5" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b>I am a needle!!!</b></a></div></div>
|
||||
<code>#pcf #a5 .fail:has-text(/NEEDLE/i)</code>
|
||||
</div>
|
||||
|
||||
<div id="a6" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b>I am a needle!!!</b></a></div></div>
|
||||
<code>#pcf #a6 .fail:not(:has-text(haystack))</code>
|
||||
</div>
|
||||
|
||||
<div id="a7" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>#pcf #a7 .fail:matches-css(position: absolute)</code>
|
||||
</div>
|
||||
|
||||
<div id="a8" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>#pcf #a8 .fail:has(a:matches-css-before(opacity: 0))</code>
|
||||
</div>
|
||||
|
||||
<div id="a9" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>#pcf #a9 .fail:has(b:matches-css-after(opacity: 0))</code>
|
||||
</div>
|
||||
|
||||
<div id="a10" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>#pcf #a10 .fail > a > b:nth-ancestor(2)</code>
|
||||
</div>
|
||||
|
||||
<div id="a11" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>#pcf #a11:xpath(.//b/../..)</code>
|
||||
</div>
|
||||
|
||||
<div id="a12" class="tile">
|
||||
<div class="pass"><div class="fail"><a>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna<b>aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</b>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</a></div></div>
|
||||
<code>#pcf #a12 .fail:min-text-length(300)</code>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const hostname = self.location.hostname;
|
||||
const filters = [];
|
||||
const fragment = document.createDocumentFragment();
|
||||
for ( const node of document.querySelectorAll('code') ) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = `${hostname}##${node.textContent}`;
|
||||
fragment.appendChild(div);
|
||||
}
|
||||
const parent = document.querySelector('.filters');
|
||||
while ( parent.lastElementChild !== null ) {
|
||||
parent.removeChild(parent.lastElementChild);
|
||||
}
|
||||
parent.appendChild(fragment);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,132 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Procedural HTML filters</title>
|
||||
<style>
|
||||
.filters {
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
.tests {
|
||||
align-items: flex-start;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.tile {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
margin: 0 20px 10px 0;
|
||||
min-width: 200px;
|
||||
}
|
||||
.tile div {
|
||||
align-items: center;
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.tile > div {
|
||||
height: 100px;
|
||||
position: relative;
|
||||
}
|
||||
.tile > div > div {
|
||||
height: 100%;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.pass {
|
||||
background-color: green;
|
||||
}
|
||||
.pass::before {
|
||||
content: 'pass';
|
||||
}
|
||||
.fail {
|
||||
background-color: red;
|
||||
}
|
||||
.fail::before {
|
||||
content: 'fail';
|
||||
}
|
||||
a, b {
|
||||
display: none;
|
||||
}
|
||||
a::before {
|
||||
opacity: 0;
|
||||
}
|
||||
b::after {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Procedural HTML filters</h1>
|
||||
<h3>Filters</h3>
|
||||
<div class="filters"><noscript>Enable JavaScript to see needed filters</noscript></div>
|
||||
|
||||
<h3>Tests</h3>
|
||||
<div id="phf" class="tests">
|
||||
|
||||
<div id="a1" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>^#phf #a1 .fail:has(b)</code>
|
||||
</div>
|
||||
|
||||
<div id="a2" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>^#phf #a2 .fail:has(> a > b)</code>
|
||||
</div>
|
||||
|
||||
<div id="a3" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>^#phf #a3 .fail:not(:has(c))</code>
|
||||
</div>
|
||||
|
||||
<div id="a4" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b>I am a needle!!!</b></a></div></div>
|
||||
<code>^#phf #a4 .fail:has-text(needle)</code>
|
||||
</div>
|
||||
|
||||
<div id="a5" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b>I am a needle!!!</b></a></div></div>
|
||||
<code>^#phf #a5 .fail:has-text(/NEEDLE/i)</code>
|
||||
</div>
|
||||
|
||||
<div id="a6" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b>I am a needle!!!</b></a></div></div>
|
||||
<code>^#phf #a6 .fail:not(:has-text(haystack))</code>
|
||||
</div>
|
||||
|
||||
<div id="a7" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>^#phf #a7 .fail > a > b:nth-ancestor(2)</code>
|
||||
</div>
|
||||
|
||||
<div id="a8" class="tile">
|
||||
<div class="pass"><div class="fail"><a><b></b></a></div></div>
|
||||
<code>^#phf #a8:xpath(.//b/../..)</code>
|
||||
</div>
|
||||
|
||||
<div id="a9" class="tile">
|
||||
<div class="pass"><div class="fail"><a>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna<b>aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</b>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</a></div></div>
|
||||
<code>^#phf #a9 .fail:min-text-length(300)</code>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const hostname = self.location.hostname;
|
||||
const filters = [];
|
||||
const fragment = document.createDocumentFragment();
|
||||
for ( const node of document.querySelectorAll('code') ) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = `${hostname}##${node.textContent}`;
|
||||
fragment.appendChild(div);
|
||||
}
|
||||
const parent = document.querySelector('.filters');
|
||||
while ( parent.lastElementChild !== null ) {
|
||||
parent.removeChild(parent.lastElementChild);
|
||||
}
|
||||
parent.appendChild(fragment);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue