Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-05-28 01:12:55 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-05-28 01:12:55 +0400
commitb2dc389d4ce722cb499b87f2f607a68342a62e48 (patch)
treeea86c054a5a3d2cad5c78318185ccf7272ade39b /tests
parent17a96e87ddca67fed1c4daafd1bc9aa4c86f24dc (diff)
when detecting the clipRect ignore elements that are not visible and trigger an error if no element is visible
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/screenshot-testing/support/page-renderer.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/lib/screenshot-testing/support/page-renderer.js b/tests/lib/screenshot-testing/support/page-renderer.js
index ab9c0f170e..dd072a47e5 100644
--- a/tests/lib/screenshot-testing/support/page-renderer.js
+++ b/tests/lib/screenshot-testing/support/page-renderer.js
@@ -242,6 +242,11 @@ PageRenderer.prototype.capture = function (outputPath, callback, selector) {
element.each(function (index, node) {
var rect = node.getBoundingClientRect();
+ if (!rect.width || !rect.height) {
+ // element is not visible
+ return;
+ }
+
if (null === clipRect.left || rect.left < clipRect.left) {
clipRect.left = rect.left;
}
@@ -272,6 +277,13 @@ PageRenderer.prototype.capture = function (outputPath, callback, selector) {
throw new Error("Error while detecting element clipRect " + selector + ": " + result.message);
}
+ if (null === result.left
+ || null === result.top
+ || null === result.bottom
+ || null === result.right) {
+ throw new Error("Element(s) " + selector + " found but none is visible");
+ }
+
page.clipRect = result;
}