| 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()); |
| +}; |