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

Delta Between Two Patch Sets: test/browser/elemHideEmulation.js

Issue 29714601: Issue 6437 - Skip elements not affected by DOM mutations (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Ignore own DOM modifications in debug mode Created May 18, 2018, 3:36 a.m.
Right Patch Set: Rename debug mode to test mode Created May 18, 2018, 3:41 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« lib/content/elemHideEmulation.js ('K') | « lib/content/elemHideEmulation.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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, setDebugMode, 20 const {ElemHideEmulation, setTestMode,
21 getDebugInfo} = require("../../lib/content/elemHideEmulation"); 21 getTestInfo} = require("../../lib/content/elemHideEmulation");
22 22
23 const REFRESH_INTERVAL = 200; 23 const REFRESH_INTERVAL = 200;
24 24
25 let testDocument = null; 25 let testDocument = null;
26 26
27 exports.setUp = function(callback) 27 exports.setUp = function(callback)
28 { 28 {
29 setDebugMode(); 29 setTestMode();
30 30
31 let iframe = document.createElement("iframe"); 31 let iframe = document.createElement("iframe");
32 document.body.appendChild(iframe); 32 document.body.appendChild(iframe);
33 testDocument = iframe.contentDocument; 33 testDocument = iframe.contentDocument;
34 34
35 callback(); 35 callback();
36 }; 36 };
37 37
38 exports.tearDown = function(callback) 38 exports.tearDown = function(callback)
39 { 39 {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 `The element${withId}'s display property should not be set to 'none'`); 80 `The element${withId}'s display property should not be set to 'none'`);
81 } 81 }
82 82
83 function expectProcessed(test, element, id = null) 83 function expectProcessed(test, element, id = null)
84 { 84 {
85 let withId = ""; 85 let withId = "";
86 if (id) 86 if (id)
87 withId = ` with ID '${id}'`; 87 withId = ` with ID '${id}'`;
88 88
89 test.ok( 89 test.ok(
90 getDebugInfo().lastProcessedElements.has(element), 90 getTestInfo().lastProcessedElements.has(element),
91 `The element${withId} should have been processed`); 91 `The element${withId} should have been processed`);
92 } 92 }
93 93
94 function expectNotProcessed(test, element, id = null) 94 function expectNotProcessed(test, element, id = null)
95 { 95 {
96 let withId = ""; 96 let withId = "";
97 if (id) 97 if (id)
98 withId = ` with ID '${id}'`; 98 withId = ` with ID '${id}'`;
99 99
100 test.ok( 100 test.ok(
101 !getDebugInfo().lastProcessedElements.has(element), 101 !getTestInfo().lastProcessedElements.has(element),
102 `The element${withId} should not have been processed`); 102 `The element${withId} should not have been processed`);
103 } 103 }
104 104
105 function findUniqueId() 105 function findUniqueId()
106 { 106 {
107 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000); 107 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000);
108 if (!testDocument.getElementById(id)) 108 if (!testDocument.getElementById(id))
109 return id; 109 return id;
110 return findUniqueId(); 110 return findUniqueId();
111 } 111 }
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 for (let element of [...testDocument.getElementsByTagName("div"), 1015 for (let element of [...testDocument.getElementsByTagName("div"),
1016 ...testDocument.getElementsByTagName("p")]) 1016 ...testDocument.getElementsByTagName("p")])
1017 { 1017 {
1018 if (element.id == "n2" || element.id == "n2_3") 1018 if (element.id == "n2" || element.id == "n2_3")
1019 expectProcessed(test, element, element.id); 1019 expectProcessed(test, element, element.id);
1020 else 1020 else
1021 expectNotProcessed(test, element, element.id); 1021 expectNotProcessed(test, element, element.id);
1022 } 1022 }
1023 }).catch(unexpectedError.bind(test)).then(() => test.done()); 1023 }).catch(unexpectedError.bind(test)).then(() => test.done());
1024 }; 1024 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld