| Index: LayoutTests/resources/check-layout.js
 | 
| diff --git a/LayoutTests/resources/check-layout.js b/LayoutTests/resources/check-layout.js
 | 
| index f2029cba1d7070fb5137df60ad6e187a65048ee5..169be31c3bddfee383e4809f0b475652e30853c5 100644
 | 
| --- a/LayoutTests/resources/check-layout.js
 | 
| +++ b/LayoutTests/resources/check-layout.js
 | 
| @@ -18,84 +18,93 @@ function insertAfter(nodeToAdd, referenceNode)
 | 
|  
 | 
|  function checkSubtreeExpectedValues(parent, failures)
 | 
|  {
 | 
| -    checkExpectedValues(parent, failures);
 | 
| +    var checkedLayout = checkExpectedValues(parent, failures);
 | 
|      Array.prototype.forEach.call(parent.childNodes, function(node) {
 | 
| -        checkSubtreeExpectedValues(node, failures);
 | 
| +        checkedLayout |= checkSubtreeExpectedValues(node, failures);
 | 
|      });
 | 
| +    return checkedLayout;
 | 
| +}
 | 
| +
 | 
| +function checkAttribute(output, node, attribute)
 | 
| +{
 | 
| +    var result = node.getAttribute && node.getAttribute(attribute);
 | 
| +    output.checked |= !!result;
 | 
| +    return result;
 | 
|  }
 | 
|  
 | 
|  function checkExpectedValues(node, failures)
 | 
|  {
 | 
| -    var expectedWidth = node.getAttribute && node.getAttribute("data-expected-width");
 | 
| +    var output = { checked: false };
 | 
| +    var expectedWidth = checkAttribute(output, node, "data-expected-width");
 | 
|      if (expectedWidth) {
 | 
|          if (node.offsetWidth != parseInt(expectedWidth))
 | 
|              failures.push("Expected " + expectedWidth + " for width, but got " + node.offsetWidth + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedHeight = node.getAttribute && node.getAttribute("data-expected-height");
 | 
| +    var expectedHeight = checkAttribute(output, node, "data-expected-height");
 | 
|      if (expectedHeight) {
 | 
|          if (node.offsetHeight != parseInt(expectedHeight))
 | 
|              failures.push("Expected " + expectedHeight + " for height, but got " + node.offsetHeight + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedOffset = node.getAttribute && node.getAttribute("data-offset-x");
 | 
| +    var expectedOffset = checkAttribute(output, node, "data-offset-x");
 | 
|      if (expectedOffset) {
 | 
|          if (node.offsetLeft != parseInt(expectedOffset))
 | 
|              failures.push("Expected " + expectedOffset + " for offsetLeft, but got " + node.offsetLeft + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedOffset = node.getAttribute && node.getAttribute("data-offset-y");
 | 
| +    var expectedOffset = checkAttribute(output, node, "data-offset-y");
 | 
|      if (expectedOffset) {
 | 
|          if (node.offsetTop != parseInt(expectedOffset))
 | 
|              failures.push("Expected " + expectedOffset + " for offsetTop, but got " + node.offsetTop + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedWidth = node.getAttribute && node.getAttribute("data-expected-client-width");
 | 
| +    var expectedWidth = checkAttribute(output, node, "data-expected-client-width");
 | 
|      if (expectedWidth) {
 | 
|          if (node.clientWidth != parseInt(expectedWidth))
 | 
|              failures.push("Expected " + expectedWidth + " for clientWidth, but got " + node.clientWidth + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedHeight = node.getAttribute && node.getAttribute("data-expected-client-height");
 | 
| +    var expectedHeight = checkAttribute(output, node, "data-expected-client-height");
 | 
|      if (expectedHeight) {
 | 
|          if (node.clientHeight != parseInt(expectedHeight))
 | 
|              failures.push("Expected " + expectedHeight + " for clientHeight, but got " + node.clientHeight + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedWidth = node.getAttribute && node.getAttribute("data-expected-scroll-width");
 | 
| +    var expectedWidth = checkAttribute(output, node, "data-expected-scroll-width");
 | 
|      if (expectedWidth) {
 | 
|          if (node.scrollWidth != parseInt(expectedWidth))
 | 
|              failures.push("Expected " + expectedWidth + " for scrollWidth, but got " + node.scrollWidth + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedHeight = node.getAttribute && node.getAttribute("data-expected-scroll-height");
 | 
| +    var expectedHeight = checkAttribute(output, node, "data-expected-scroll-height");
 | 
|      if (expectedHeight) {
 | 
|          if (node.scrollHeight != parseInt(expectedHeight))
 | 
|              failures.push("Expected " + expectedHeight + " for scrollHeight, but got " + node.scrollHeight + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedOffset = node.getAttribute && node.getAttribute("data-total-x");
 | 
| +    var expectedOffset = checkAttribute(output, node, "data-total-x");
 | 
|      if (expectedOffset) {
 | 
|          var totalLeft = node.clientLeft + node.offsetLeft;
 | 
|          if (totalLeft != parseInt(expectedOffset))
 | 
|              failures.push("Expected " + expectedOffset + " for clientLeft+offsetLeft, but got " + totalLeft + ", clientLeft: " + node.clientLeft + ", offsetLeft: " + node.offsetLeft + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedOffset = node.getAttribute && node.getAttribute("data-total-y");
 | 
| +    var expectedOffset = checkAttribute(output, node, "data-total-y");
 | 
|      if (expectedOffset) {
 | 
|          var totalTop = node.clientTop + node.offsetTop;
 | 
|          if (totalTop != parseInt(expectedOffset))
 | 
|              failures.push("Expected " + expectedOffset + " for clientTop+offsetTop, but got " + totalTop + ", clientTop: " + node.clientTop + ", + offsetTop: " + node.offsetTop + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedDisplay = node.getAttribute && node.getAttribute("data-expected-display");
 | 
| +    var expectedDisplay = checkAttribute(output, node, "data-expected-display");
 | 
|      if (expectedDisplay) {
 | 
|          var actualDisplay = getComputedStyle(node).display;
 | 
|          if (actualDisplay != expectedDisplay)
 | 
|              failures.push("Expected " + expectedDisplay + " for display, but got " + actualDisplay + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedPaddingTop = node.getAttribute && node.getAttribute("data-expected-padding-top");
 | 
| +    var expectedPaddingTop = checkAttribute(output, node, "data-expected-padding-top");
 | 
|      if (expectedPaddingTop) {
 | 
|          var actualPaddingTop = getComputedStyle(node).paddingTop;
 | 
|          // Trim the unit "px" from the output.
 | 
| @@ -104,7 +113,7 @@ function checkExpectedValues(node, failures)
 | 
|              failures.push("Expected " + expectedPaddingTop + " for padding-top, but got " + actualPaddingTop + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedPaddingBottom = node.getAttribute && node.getAttribute("data-expected-padding-bottom");
 | 
| +    var expectedPaddingBottom = checkAttribute(output, node, "data-expected-padding-bottom");
 | 
|      if (expectedPaddingBottom) {
 | 
|          var actualPaddingBottom = getComputedStyle(node).paddingBottom;
 | 
|          // Trim the unit "px" from the output.
 | 
| @@ -113,7 +122,7 @@ function checkExpectedValues(node, failures)
 | 
|              failures.push("Expected " + expectedPaddingBottom + " for padding-bottom, but got " + actualPaddingBottom + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedPaddingLeft = node.getAttribute && node.getAttribute("data-expected-padding-left");
 | 
| +    var expectedPaddingLeft = checkAttribute(output, node, "data-expected-padding-left");
 | 
|      if (expectedPaddingLeft) {
 | 
|          var actualPaddingLeft = getComputedStyle(node).paddingLeft;
 | 
|          // Trim the unit "px" from the output.
 | 
| @@ -122,7 +131,7 @@ function checkExpectedValues(node, failures)
 | 
|              failures.push("Expected " + expectedPaddingLeft + " for padding-left, but got " + actualPaddingLeft + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedPaddingRight = node.getAttribute && node.getAttribute("data-expected-padding-right");
 | 
| +    var expectedPaddingRight = checkAttribute(output, node, "data-expected-padding-right");
 | 
|      if (expectedPaddingRight) {
 | 
|          var actualPaddingRight = getComputedStyle(node).paddingRight;
 | 
|          // Trim the unit "px" from the output.
 | 
| @@ -131,7 +140,7 @@ function checkExpectedValues(node, failures)
 | 
|              failures.push("Expected " + expectedPaddingRight + " for padding-right, but got " + actualPaddingRight + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedMarginTop = node.getAttribute && node.getAttribute("data-expected-margin-top");
 | 
| +    var expectedMarginTop = checkAttribute(output, node, "data-expected-margin-top");
 | 
|      if (expectedMarginTop) {
 | 
|          var actualMarginTop = getComputedStyle(node).marginTop;
 | 
|          // Trim the unit "px" from the output.
 | 
| @@ -140,7 +149,7 @@ function checkExpectedValues(node, failures)
 | 
|              failures.push("Expected " + expectedMarginTop + " for margin-top, but got " + actualMarginTop + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedMarginBottom = node.getAttribute && node.getAttribute("data-expected-margin-bottom");
 | 
| +    var expectedMarginBottom = checkAttribute(output, node, "data-expected-margin-bottom");
 | 
|      if (expectedMarginBottom) {
 | 
|          var actualMarginBottom = getComputedStyle(node).marginBottom;
 | 
|          // Trim the unit "px" from the output.
 | 
| @@ -149,7 +158,7 @@ function checkExpectedValues(node, failures)
 | 
|              failures.push("Expected " + expectedMarginBottom + " for margin-bottom, but got " + actualMarginBottom + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedMarginLeft = node.getAttribute && node.getAttribute("data-expected-margin-left");
 | 
| +    var expectedMarginLeft = checkAttribute(output, node, "data-expected-margin-left");
 | 
|      if (expectedMarginLeft) {
 | 
|          var actualMarginLeft = getComputedStyle(node).marginLeft;
 | 
|          // Trim the unit "px" from the output.
 | 
| @@ -158,7 +167,7 @@ function checkExpectedValues(node, failures)
 | 
|              failures.push("Expected " + expectedMarginLeft + " for margin-left, but got " + actualMarginLeft + ". ");
 | 
|      }
 | 
|  
 | 
| -    var expectedMarginRight = node.getAttribute && node.getAttribute("data-expected-margin-right");
 | 
| +    var expectedMarginRight = checkAttribute(output, node, "data-expected-margin-right");
 | 
|      if (expectedMarginRight) {
 | 
|          var actualMarginRight = getComputedStyle(node).marginRight;
 | 
|          // Trim the unit "px" from the output.
 | 
| @@ -166,6 +175,8 @@ function checkExpectedValues(node, failures)
 | 
|          if (actualMarginRight != expectedMarginRight)
 | 
|              failures.push("Expected " + expectedMarginRight + " for margin-right, but got " + actualMarginRight + ". ");
 | 
|      }
 | 
| +
 | 
| +    return output.checked;
 | 
|  }
 | 
|  
 | 
|  window.checkLayout = function(selectorList)
 | 
| @@ -177,10 +188,11 @@ window.checkLayout = function(selectorList)
 | 
|      var nodes = document.querySelectorAll(selectorList);
 | 
|      nodes = Array.prototype.slice.call(nodes);
 | 
|      nodes.reverse();
 | 
| +    var checkedLayout = false;
 | 
|      Array.prototype.forEach.call(nodes, function(node) {
 | 
|          var failures = [];
 | 
| -        checkExpectedValues(node.parentNode, failures);
 | 
| -        checkSubtreeExpectedValues(node, failures);
 | 
| +        checkedLayout |= checkExpectedValues(node.parentNode, failures);
 | 
| +        checkedLayout |= checkSubtreeExpectedValues(node, failures);
 | 
|  
 | 
|          var container = node.parentNode.className == 'container' ? node.parentNode : node;
 | 
|  
 | 
| @@ -190,6 +202,12 @@ window.checkLayout = function(selectorList)
 | 
|          pre.appendChild(document.createTextNode(failures.length ? "FAIL:\n" + failures.join('\n') + '\n\n' + container.outerHTML : "PASS"));
 | 
|          insertAfter(pre, container);
 | 
|      });
 | 
| +
 | 
| +    if (!checkedLayout) {
 | 
| +        document.body.innerHTML = "FAIL: No valid data-* attributes found in selector list : " + selectorList;
 | 
| +        return;
 | 
| +    }
 | 
| +
 | 
|      var pre = document.querySelector('.FAIL');
 | 
|      if (pre)
 | 
|          setTimeout(function() { pre.previousSibling.scrollIntoView(); }, 0);
 | 
| 
 |