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

Unified Diff: test/browser/elemHideEmulation.js

Issue 29448560: Issue 5249 - Implement :-abp-contains() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Updated and rebased Created June 8, 2017, 12:19 a.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
@@ -15,17 +15,17 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
/* globals ElemHideEmulation, splitSelector,
parseSelectorContent,
parseSelector, positionInParent, makeSelector,
- PlainSelector, HasSelector, PropsSelector */
+ PlainSelector, HasSelector, PropsSelector, ContainsSelector */
let myUrl = document.currentScript.src;
exports.tearDown = function(callback)
{
let styleElements = document.head.getElementsByTagName("style");
while (styleElements.length)
styleElements[0].parentNode.removeChild(styleElements[0]);
@@ -205,16 +205,28 @@
test.ok(selectors[1] instanceof HasSelector);
test.ok(selectors[2] instanceof PlainSelector);
test.ok(selectors[3] instanceof PropsSelector);
selector = "div > :-abp-has(> div.inside > :-abp-properties(background-color: rgb(0, 0, 0))";
selectors = parseSelector(selector);
test.equal(selectors, null);
+ selector = 'div[arial-label="Story"]:-abp-has(> div > div > span > span:-abp-contains(Suggested Post))';
+ selectors = parseSelector(selector);
+ test.equal(selectors.length, 2);
+ test.ok(selectors[0] instanceof PlainSelector);
+ test.ok(selectors[1] instanceof HasSelector);
+
+ selectors = selectors[1]._innerSelectors;
+ test.equals(selectors.length, 2);
+ test.ok(selectors[0] instanceof PlainSelector);
+ test.ok(selectors[1] instanceof ContainsSelector);
+ test.equals(selectors[1]._text, "Suggested Post");
+
// -abp-has-unsupported() is unknown. Ensure we fail parsing.
selector = 'div[arial-label="Story"]:-abp-has(> div > div > span > span:-abp-unsupported("Suggested Post"))';
selectors = parseSelector(selector);
test.equal(selectors, null);
}).catch(unexpectedError.bind(test)).then(() => test.done());
};
function buildDom(doc)
@@ -305,16 +317,39 @@
test.ok(value.done);
selector = new HasSelector(":-abp-has(> div.inside)");
test.ok(selector._innerSelectors);
}).catch(unexpectedError.bind(test)).then(() => test.done());
};
+exports.testContainsSelector = function(test)
+{
+ let {toHide} = buildDom(document);
+
+ loadElemHideEmulation().then(() =>
+ {
+ let selector = new ContainsSelector("to hide");
+
+ let iter = selector.getSelectors("", document, document.sheet);
+ let value = iter.next();
+ test.ok(!value.done);
+ test.equal(value.value[0],
+ ":root > BODY:nth-child(2) > DIV:nth-child(1) > DIV:nth-child(2) > DIV:nth-child(1)");
+
+ iter = selector.getElements("", document, document.sheet);
+ value = iter.next();
+ test.ok(!value.done);
+ test.equal(value.value, toHide);
+ value = iter.next();
+ test.ok(value.done);
+ }).catch(unexpectedError.bind(test)).then(() => test.done());
+};
+
exports.testSplitStyleRule = function(test)
{
loadElemHideEmulation().then(() =>
{
let selectors = splitSelector("div:-abp-has(div) > [-abp-properties='background-color: rgb(0, 0, 0)'] > span");
test.ok(selectors);
test.equal(selectors.length, 1, "There is only one selector");
« 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