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

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

Issue 30024560: Issue 7450 - Implement hide-if-contains-visible-text snippet (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rework snippet Created April 17, 2019, 5:11 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 | « test/browser/_utils.js ('k') | test/browser/snippets.js » ('j') | 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 const {ElemHideEmulation, setTestMode, 20 const {ElemHideEmulation, setTestMode,
21 getTestInfo} = require("../../lib/content/elemHideEmulation"); 21 getTestInfo} = require("../../lib/content/elemHideEmulation");
22 const {timeout} = require("./_utils"); 22 const {timeout, expectHidden, expectVisible} = require("./_utils");
23 23
24 const REFRESH_INTERVAL = 200; 24 const REFRESH_INTERVAL = 200;
25 25
26 let testDocument = null; 26 let testDocument = null;
27 27
28 exports.setUp = function(callback) 28 exports.setUp = function(callback)
29 { 29 {
30 setTestMode(); 30 setTestMode();
31 31
32 let iframe = document.createElement("iframe"); 32 let iframe = document.createElement("iframe");
(...skipping 11 matching lines...) Expand all
44 44
45 callback(); 45 callback();
46 }; 46 };
47 47
48 function unexpectedError(test, error) 48 function unexpectedError(test, error)
49 { 49 {
50 console.error(error); 50 console.error(error);
51 test.ok(false, "Unexpected error: " + error); 51 test.ok(false, "Unexpected error: " + error);
52 } 52 }
53 53
54 function expectHidden(test, element, id)
55 {
56 let withId = "";
57 if (typeof id != "undefined")
58 withId = ` with ID '${id}'`;
59
60 test.equal(
61 window.getComputedStyle(element).display, "none",
62 `The element${withId}'s display property should be set to 'none'`);
63 }
64
65 function expectVisible(test, element, id)
66 {
67 let withId = "";
68 if (typeof id != "undefined")
69 withId = ` with ID '${id}'`;
70
71 test.notEqual(
72 window.getComputedStyle(element).display, "none",
73 `The element${withId}'s display property should not be set to 'none'`);
74 }
75
76 function expectProcessed(test, element, id = null) 54 function expectProcessed(test, element, id = null)
77 { 55 {
78 let withId = ""; 56 let withId = "";
79 if (id) 57 if (id)
80 withId = ` with ID '${id}'`; 58 withId = ` with ID '${id}'`;
81 59
82 test.ok( 60 test.ok(
83 getTestInfo().lastProcessedElements.has(element), 61 getTestInfo().lastProcessedElements.has(element),
84 `The element${withId} should have been processed`); 62 `The element${withId} should have been processed`);
85 } 63 }
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 { 1182 {
1205 if (element.id == "n2" || element.id == "n2_3") 1183 if (element.id == "n2" || element.id == "n2_3")
1206 expectProcessed(test, element, element.id); 1184 expectProcessed(test, element, element.id);
1207 else 1185 else
1208 expectNotProcessed(test, element, element.id); 1186 expectNotProcessed(test, element, element.id);
1209 } 1187 }
1210 } 1188 }
1211 1189
1212 test.done(); 1190 test.done();
1213 }; 1191 };
OLDNEW
« no previous file with comments | « test/browser/_utils.js ('k') | test/browser/snippets.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld