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

Unified 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 feeedback Created March 21, 2018, 7:05 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/browser/elemHideEmulation.js
===================================================================
--- a/test/browser/elemHideEmulation.js
+++ b/test/browser/elemHideEmulation.js
@@ -50,26 +50,36 @@
}
function unexpectedError(error)
{
console.error(error);
this.ok(false, "Unexpected error: " + error);
}
-function expectHidden(test, element)
+function expectHidden(test, element, id)
{
- test.equal(window.getComputedStyle(element).display, "none",
- "The element's display property should be set to 'none'");
+ let withId = "";
+ if (typeof id != "undefined")
+ withId = ` with ID '${id}'`;
+
+ test.equal(
+ window.getComputedStyle(element).display, "none",
+ `The element${withId}'s display property should be set to 'none'`);
}
-function expectVisible(test, element)
+function expectVisible(test, element, id)
{
- test.notEqual(window.getComputedStyle(element).display, "none",
- "The element's display property should not be set to 'none'");
+ let withId = "";
+ if (typeof id != "undefined")
+ withId = ` with ID '${id}'`;
+
+ test.notEqual(
+ window.getComputedStyle(element).display, "none",
+ `The element${withId}'s display property should not be set to 'none'`);
}
function findUniqueId()
{
let id = "elemHideEmulationTest-" + Math.floor(Math.random() * 10000);
if (!testDocument.getElementById(id))
return id;
return findUniqueId();
@@ -355,19 +365,19 @@
function compareExpectations(test, elems, expectations)
{
for (let elem in expectations)
{
if (elems[elem])
{
if (expectations[elem])
- expectVisible(test, elems[elem]);
+ expectVisible(test, elems[elem], elem);
else
- expectHidden(test, elems[elem]);
+ expectHidden(test, elems[elem], elem);
}
}
}
function runTestPseudoClassHasSelectorWithHasAndWithSuffixSibling(test, selector, expectations)
{
testDocument.body.innerHTML = `<div id="parent">
<div id="middle">
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld