Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: third_party/WebKit/LayoutTests/resources/check-layout.js

Issue 1729073002: Update SVG tests ahead of offset* removal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update flexitem.html and grid-item-display.html too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/resources/check-layout.js
diff --git a/third_party/WebKit/LayoutTests/resources/check-layout.js b/third_party/WebKit/LayoutTests/resources/check-layout.js
index 0d617bea3be71dc00385db92ab27b0a8ab6d493d..3c701c92e109455f9e154a444a7b28475337aac2 100644
--- a/third_party/WebKit/LayoutTests/resources/check-layout.js
+++ b/third_party/WebKit/LayoutTests/resources/check-layout.js
@@ -16,6 +16,14 @@ function insertAfter(nodeToAdd, referenceNode)
referenceNode.parentNode.appendChild(nodeToAdd);
}
+function positionedAncestor(node)
+{
+ var ancestor = node.parentNode;
+ while (getComputedStyle(ancestor).position == 'static')
+ ancestor = ancestor.parentNode;
+ return ancestor;
+}
+
function checkSubtreeExpectedValues(parent, failures)
{
var checkedLayout = checkExpectedValues(parent, failures);
@@ -59,6 +67,20 @@ function checkExpectedValues(node, failures)
failures.push("Expected " + expectedOffset + " for offsetTop, but got " + node.offsetTop + ". ");
}
+ var expectedOffset = checkAttribute(output, node, "data-positioned-offset-x");
+ if (expectedOffset) {
+ var actualOffset = node.getBoundingClientRect().left - positionedAncestor(node).getBoundingClientRect().left;
+ if (isNaN(expectedOffset) || Math.abs(actualOffset - expectedOffset) >= 1)
+ failures.push("Expected " + expectedOffset + " for getBoundingClientRect().left offset, but got " + actualOffset + ". ");
+ }
+
+ var expectedOffset = checkAttribute(output, node, "data-positioned-offset-y");
+ if (expectedOffset) {
+ var actualOffset = node.getBoundingClientRect().top - positionedAncestor(node).getBoundingClientRect().top;
+ if (isNaN(expectedOffset) || Math.abs(actualOffset - expectedOffset) >= 1)
+ failures.push("Expected " + expectedOffset + " for getBoundingClientRect().top offset, but got " + actualOffset + ". ");
+ }
+
var expectedWidth = checkAttribute(output, node, "data-expected-client-width");
if (expectedWidth) {
if (isNaN(expectedWidth) || Math.abs(node.clientWidth - expectedWidth) >= 1)

Powered by Google App Engine
This is Rietveld 408576698