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

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

Issue 29721681: Noissue - Allow identifying the element in case of error in test (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Review feedback Created March 20, 2018, 2:39 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 | « no previous file | 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 window.setTimeout(resolve, delay); 48 window.setTimeout(resolve, delay);
49 }); 49 });
50 } 50 }
51 51
52 function unexpectedError(error) 52 function unexpectedError(error)
53 { 53 {
54 console.error(error); 54 console.error(error);
55 this.ok(false, "Unexpected error: " + error); 55 this.ok(false, "Unexpected error: " + error);
56 } 56 }
57 57
58 function expectHidden(test, element) 58 function expectHidden(test, element, id)
59 { 59 {
60 test.equal(window.getComputedStyle(element).display, "none", 60 let message = id ?
kzar 2018/03/21 18:11:59 This seems kind of messy, also I guess the ID migh
hub 2018/03/21 19:05:04 Done.
hub 2018/03/21 19:05:04 Hence my original approach, since these are just t
kzar 2018/03/22 09:40:04 Sorry I was talking nonsense here, the ID is a str
kzar 2018/03/22 09:40:04 Yea fair enough.
61 "The element's display property should be set to 'none'"); 61 `The element with ID '${id}' display property should be set to 'none'` :
62 "The element's display property should be set to 'none'";
63 test.equal(
64 window.getComputedStyle(element).display, "none", message);
62 } 65 }
63 66
64 function expectVisible(test, element) 67 function expectVisible(test, element, id)
65 { 68 {
66 test.notEqual(window.getComputedStyle(element).display, "none", 69 let message = id ?
67 "The element's display property should not be set to 'none'"); 70 `The element with ID '${id}' display property should not be set to 'none'` :
71 "The element's display property should not be set to 'none'";
72 test.notEqual(
73 window.getComputedStyle(element).display, "none", message);
68 } 74 }
69 75
70 function findUniqueId() 76 function findUniqueId()
71 { 77 {
72 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000); 78 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000);
73 if (!testDocument.getElementById(id)) 79 if (!testDocument.getElementById(id))
74 return id; 80 return id;
75 return findUniqueId(); 81 return findUniqueId();
76 } 82 }
77 83
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 }).catch(unexpectedError.bind(test)).then(() => test.done()); 359 }).catch(unexpectedError.bind(test)).then(() => test.done());
354 }; 360 };
355 361
356 function compareExpectations(test, elems, expectations) 362 function compareExpectations(test, elems, expectations)
357 { 363 {
358 for (let elem in expectations) 364 for (let elem in expectations)
359 { 365 {
360 if (elems[elem]) 366 if (elems[elem])
361 { 367 {
362 if (expectations[elem]) 368 if (expectations[elem])
363 expectVisible(test, elems[elem]); 369 expectVisible(test, elems[elem], elem);
364 else 370 else
365 expectHidden(test, elems[elem]); 371 expectHidden(test, elems[elem], elem);
366 } 372 }
367 } 373 }
368 } 374 }
369 375
370 function runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(test, selector , expectations) 376 function runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(test, selector , expectations)
371 { 377 {
372 testDocument.body.innerHTML = `<div id="parent"> 378 testDocument.body.innerHTML = `<div id="parent">
373 <div id="middle"> 379 <div id="middle">
374 <div id="middle1"><div id="inside" class="inside"></div></div> 380 <div id="middle1"><div id="inside" class="inside"></div></div>
375 </div> 381 </div>
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 expectVisible(test, child2); 688 expectVisible(test, child2);
683 return timeout(REFRESH_INTERVAL); 689 return timeout(REFRESH_INTERVAL);
684 }).then(() => 690 }).then(() =>
685 { 691 {
686 expectHidden(test, parent); 692 expectHidden(test, parent);
687 expectVisible(test, child); 693 expectVisible(test, child);
688 expectHidden(test, sibling); 694 expectHidden(test, sibling);
689 expectVisible(test, child2); 695 expectVisible(test, child2);
690 }).catch(unexpectedError.bind(test)).then(() => test.done()); 696 }).catch(unexpectedError.bind(test)).then(() => test.done());
691 }; 697 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld