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

Side by Side Diff: test/browser/elemHideEmulation.js

Issue 29559743: Issue 5650 - Apply emulation filters to shadow DOMs Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Use pure generator function to extract added subtrees Created Oct. 22, 2017, 7:51 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/content/elemHideEmulation.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 insertStyleRule("#" + element.id + " " + styleBlock); 102 insertStyleRule("#" + element.id + " " + styleBlock);
103 return element; 103 return element;
104 } 104 }
105 105
106 // Create a new ElemHideEmulation instance with @selectors. 106 // Create a new ElemHideEmulation instance with @selectors.
107 function applyElemHideEmulation(selectors) 107 function applyElemHideEmulation(selectors)
108 { 108 {
109 return Promise.resolve().then(() => 109 return Promise.resolve().then(() =>
110 { 110 {
111 let elemHideEmulation = new ElemHideEmulation( 111 let elemHideEmulation = new ElemHideEmulation(
112 testDocument,
113 null,
112 newSelectors => 114 newSelectors =>
113 { 115 {
114 if (!newSelectors.length) 116 if (!newSelectors.length)
115 return; 117 return;
116 let selector = newSelectors.join(", "); 118 let selector = newSelectors.join(", ");
117 insertStyleRule(selector + "{display: none !important;}"); 119 insertStyleRule(selector + "{display: none !important;}");
118 }, 120 },
119 elems => 121 elems =>
120 { 122 {
121 for (let elem of elems) 123 for (let elem of elems)
122 elem.style.display = "none"; 124 elem.style.display = "none";
123 } 125 }
124 ); 126 );
125 127
126 elemHideEmulation.document = testDocument;
127 elemHideEmulation.MIN_INVOCATION_INTERVAL = REFRESH_INTERVAL / 2; 128 elemHideEmulation.MIN_INVOCATION_INTERVAL = REFRESH_INTERVAL / 2;
128 elemHideEmulation.apply(selectors.map(selector => ({selector}))); 129 elemHideEmulation.apply(selectors.map(selector => ({selector})));
129 return elemHideEmulation; 130 return elemHideEmulation;
130 }); 131 });
131 } 132 }
132 133
133 exports.testVerbatimPropertySelector = function(test) 134 exports.testVerbatimPropertySelector = function(test)
134 { 135 {
135 let toHide = createElementWithStyle("{background-color: #000}"); 136 let toHide = createElementWithStyle("{background-color: #000}");
136 applyElemHideEmulation( 137 applyElemHideEmulation(
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 expectVisible(test, child2); 581 expectVisible(test, child2);
581 return timeout(REFRESH_INTERVAL); 582 return timeout(REFRESH_INTERVAL);
582 }).then(() => 583 }).then(() =>
583 { 584 {
584 expectHidden(test, parent); 585 expectHidden(test, parent);
585 expectVisible(test, child); 586 expectVisible(test, child);
586 expectHidden(test, sibling); 587 expectHidden(test, sibling);
587 expectVisible(test, child2); 588 expectVisible(test, child2);
588 }).catch(unexpectedError.bind(test)).then(() => test.done()); 589 }).catch(unexpectedError.bind(test)).then(() => test.done());
589 }; 590 };
OLDNEW
« no previous file with comments | « lib/content/elemHideEmulation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld