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

Unified Diff: test/browser/elemHideEmulation.js

Issue 29481700: Issue 5339 - Properly select element for pseudo-element (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created July 6, 2017, 8:16 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 | « chrome/content/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/elemHideEmulation.js
===================================================================
--- a/test/browser/elemHideEmulation.js
+++ b/test/browser/elemHideEmulation.js
@@ -83,16 +83,21 @@
if (!parent)
document.body.appendChild(element);
else
parent.appendChild(element);
insertStyleRule("#" + element.id + " " + styleBlock);
return element;
}
+function createPseudoElementWithStyle(element, pseudo, styleBlock)
+{
+ insertStyleRule(`#${element.id}${pseudo} ${styleBlock}`);
+}
+
// Will ensure the class ElemHideEmulation is loaded.
// NOTE: if it never loads, this will probably hang.
function loadElemHideEmulation()
{
if (typeof ElemHideEmulation == "undefined")
{
return loadScript(myUrl + "/../../../lib/common.js").then(() =>
{
@@ -265,16 +270,40 @@
{
expectHidden(test, toHide);
resolve();
}, 0);
});
}).catch(unexpectedError.bind(test)).then(() => test.done());
};
+exports.testPropertySelectorForPseudoElementBefore = function(test)
+{
+ let toHide = createElementWithStyle("{background-color: #000}");
+ createPseudoElementWithStyle(toHide, "::before", "{content: \"publicite\"}");
+ applyElemHideEmulation(
+ [":-abp-properties-before(content: \"publicite\")"]
+ ).then(() =>
+ {
+ expectHidden(test, toHide);
+ }).catch(unexpectedError.bind(test)).then(() => test.done());
+};
+
+exports.testPropertySelectorForPseudoElementAfter = function(test)
+{
+ let toHide = createElementWithStyle("{background-color: #000}");
+ createPseudoElementWithStyle(toHide, "::after", "{content: \"publicite\"}");
+ applyElemHideEmulation(
+ [":-abp-properties-after(content: \"publicite\")"]
+ ).then(() =>
+ {
+ expectHidden(test, toHide);
+ }).catch(unexpectedError.bind(test)).then(() => test.done());
+};
+
exports.testPseudoClassHasSelector = function(test)
{
let toHide = createElementWithStyle("{}");
applyElemHideEmulation(
["div:-abp-has(div)"]
).then(() =>
{
expectVisible(test, toHide);
@@ -432,8 +461,23 @@
applyElemHideEmulation(
["div:-abp-has(:-abp-properties(background-color: rgb(0, 0, 0)))"]
).then(() =>
{
expectVisible(test, child);
expectHidden(test, parent);
}).catch(unexpectedError.bind(test)).then(() => test.done());
};
+
+exports.testPseudoClassHasSelectorWithPropAfterSelector = function(test)
+{
+ let parent = createElementWithStyle("{}");
+ let child = createElementWithStyle("{background-color: #000}", parent);
+ createPseudoElementWithStyle(child, "::before", "{content: \"publicite\"}");
+
+ applyElemHideEmulation(
+ ["div:-abp-has(:-abp-properties-before(content: \"publicite\"))"]
+ ).then(() =>
+ {
+ expectVisible(test, child);
+ expectHidden(test, parent);
+ }).catch(unexpectedError.bind(test)).then(() => test.done());
+};
« no previous file with comments | « chrome/content/elemHideEmulation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld