Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/browser/snippets.js

Issue 30024560: Issue 7450 - Implement hide-if-contains-visible-text snippet (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: This is now a snippet Created April 5, 2019, 9:04 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/browser/elemHideEmulation.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/browser/snippets.js
===================================================================
--- a/test/browser/snippets.js
+++ b/test/browser/snippets.js
@@ -13,17 +13,17 @@
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
const library = require("../../lib/content/snippets.js");
-const {timeout} = require("./_utils");
+const {timeout, expectHidden, expectVisible} = require("./_utils");
// We need this stub for the injector.
window.browser = {
runtime: {
getURL: () => ""
}
};
@@ -233,8 +233,80 @@
{
test.equals(e.textContent, "", "result element should be empty");
test.equals(msg.textContent, "ReferenceError",
"There should have been an error");
}
test.done();
};
+
+exports.testHideIfContainsVisibleText = async function(test)
+{
+ document.body.innerHTML = ` <style type="text/css">
+ body {
+ margin: 0;
+ padding: 0;
+ }
+ .transparent {
+ opacity: 0;
+ position: absolute;
+ display: block;
+ }
+ .zerosize {
+ font-size: 0;
+ }
+ div {
+ display: block;
+ }
+ .a {
+ display: inline-block;
+ white-space: pre-wrap;
+ }
+ .disp_none {
+ display: none;
+ }
+ .vis_hid {
+ visibility: hidden;
+ }
+ .vis_collapse {
+ visibility: collapse;
+ }
+ .same_colour {
+ color: rgb(255,255,255);
+ background-color: rgb(255,255,255);
+ }
+ #label {
+ overflow-wrap: break-word;
+ }
+ </style>
+ <div id="parent">
+ <div id="middle">
+ <div id="middle1"><div id="inside" class="inside"></div></div>
+ </div>
+ <div id="sibling">
+ <div id="tohide">to hide \ud83d\ude42!</div>
+ </div>
+ <div id="sibling2">
+ <div id="sibling21"><div id="sibling211" class="inside">Ad*</div></div>
+ </div>
+ <div id="label"><div id="content"><div class="a transparent">Sp</div><div class="a">Sp</div><div class="a zerosize">S</div><div class="a transparent">on</div><div class="a">on</div><div class="a zerosize">S</div></div></div>
+ <div id="label2"><div class="a vis_hid">Visibility: hidden</div><div class="a">S</div><div class="a vis_collapse">Visibility: collapse</div><div class="a">p</div><div class="a disp_none">Display: none</div><div class="a">o</div><div class="a same_colour">Same colour</div><div class="a">n</div></div>
+ <article id="article"><div style="display: none"><div>Spon</div></div></article>
+ <article id="article2"><div><div>Spon</div></div></article>
+ </div>`;
+
+ await runSnippet(
+ test, "hide-if-contains-visible-text", "Spon", "#parent > div"
+ );
+
+ let element = document.getElementById("label");
+ expectHidden(test, element, "label");
+ element = document.getElementById("label2");
+ expectHidden(test, element, "label2");
+
+ element = document.getElementById("article");
+ expectVisible(test, element, "article");
+ element = document.getElementById("article2");
+ expectVisible(test, element, "article2");
+
+ test.done();
+};
« no previous file with comments | « test/browser/elemHideEmulation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld