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) |