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

Delta Between Two Patch Sets: 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/
Left Patch Set: Created March 13, 2018, 2:44 p.m.
Right Patch Set: Review feeedback Created March 21, 2018, 7:05 p.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
« no previous file with change/comment | « no previous file | 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
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, id) 58 function expectHidden(test, element, id)
59 { 59 {
60 let elementId = id ? `: ${id}` : ""; 60 let withId = "";
61 if (typeof id != "undefined")
62 withId = ` with ID '${id}'`;
63
61 test.equal( 64 test.equal(
62 window.getComputedStyle(element).display, "none", 65 window.getComputedStyle(element).display, "none",
63 `The element's display property should be set to 'none' ${elementId}`); 66 `The element${withId}'s display property should be set to 'none'`);
kzar 2018/03/19 16:55:20 Please can you improve the message, like "The elem
hub 2018/03/20 14:40:26 Done.
64 } 67 }
65 68
66 function expectVisible(test, element, id) 69 function expectVisible(test, element, id)
67 { 70 {
68 let elementId = id ? `: ${id}` : ""; 71 let withId = "";
72 if (typeof id != "undefined")
73 withId = ` with ID '${id}'`;
74
69 test.notEqual( 75 test.notEqual(
70 window.getComputedStyle(element).display, "none", 76 window.getComputedStyle(element).display, "none",
71 `The element's display property should not be set to 'none' ${elementId}`); 77 `The element${withId}'s display property should not be set to 'none'`);
72 } 78 }
73 79
74 function findUniqueId() 80 function findUniqueId()
75 { 81 {
76 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000); 82 let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000);
77 if (!testDocument.getElementById(id)) 83 if (!testDocument.getElementById(id))
78 return id; 84 return id;
79 return findUniqueId(); 85 return findUniqueId();
80 } 86 }
81 87
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 expectVisible(test, child2); 692 expectVisible(test, child2);
687 return timeout(REFRESH_INTERVAL); 693 return timeout(REFRESH_INTERVAL);
688 }).then(() => 694 }).then(() =>
689 { 695 {
690 expectHidden(test, parent); 696 expectHidden(test, parent);
691 expectVisible(test, child); 697 expectVisible(test, child);
692 expectHidden(test, sibling); 698 expectHidden(test, sibling);
693 expectVisible(test, child2); 699 expectVisible(test, child2);
694 }).catch(unexpectedError.bind(test)).then(() => test.done()); 700 }).catch(unexpectedError.bind(test)).then(() => test.done());
695 }; 701 };
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld