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

Side by Side 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 unified diff | Download patch
OLDNEW
1 if (window.testRunner) 1 if (window.testRunner)
2 testRunner.dumpAsText(); 2 testRunner.dumpAsText();
3 3
4 (function() { 4 (function() {
5 5
6 function insertAfter(nodeToAdd, referenceNode) 6 function insertAfter(nodeToAdd, referenceNode)
7 { 7 {
8 if (referenceNode == document.body) { 8 if (referenceNode == document.body) {
9 document.body.appendChild(nodeToAdd); 9 document.body.appendChild(nodeToAdd);
10 return; 10 return;
11 } 11 }
12 12
13 if (referenceNode.nextSibling) 13 if (referenceNode.nextSibling)
14 referenceNode.parentNode.insertBefore(nodeToAdd, referenceNode.nextSibli ng); 14 referenceNode.parentNode.insertBefore(nodeToAdd, referenceNode.nextSibli ng);
15 else 15 else
16 referenceNode.parentNode.appendChild(nodeToAdd); 16 referenceNode.parentNode.appendChild(nodeToAdd);
17 } 17 }
18 18
19 function positionedAncestor(node)
20 {
21 var ancestor = node.parentNode;
22 while (getComputedStyle(ancestor).position == 'static')
23 ancestor = ancestor.parentNode;
24 return ancestor;
25 }
26
19 function checkSubtreeExpectedValues(parent, failures) 27 function checkSubtreeExpectedValues(parent, failures)
20 { 28 {
21 var checkedLayout = checkExpectedValues(parent, failures); 29 var checkedLayout = checkExpectedValues(parent, failures);
22 Array.prototype.forEach.call(parent.childNodes, function(node) { 30 Array.prototype.forEach.call(parent.childNodes, function(node) {
23 checkedLayout |= checkSubtreeExpectedValues(node, failures); 31 checkedLayout |= checkSubtreeExpectedValues(node, failures);
24 }); 32 });
25 return checkedLayout; 33 return checkedLayout;
26 } 34 }
27 35
28 function checkAttribute(output, node, attribute) 36 function checkAttribute(output, node, attribute)
(...skipping 23 matching lines...) Expand all
52 if (isNaN(expectedOffset) || Math.abs(node.offsetLeft - expectedOffset) >= 1) 60 if (isNaN(expectedOffset) || Math.abs(node.offsetLeft - expectedOffset) >= 1)
53 failures.push("Expected " + expectedOffset + " for offsetLeft, but g ot " + node.offsetLeft + ". "); 61 failures.push("Expected " + expectedOffset + " for offsetLeft, but g ot " + node.offsetLeft + ". ");
54 } 62 }
55 63
56 var expectedOffset = checkAttribute(output, node, "data-offset-y"); 64 var expectedOffset = checkAttribute(output, node, "data-offset-y");
57 if (expectedOffset) { 65 if (expectedOffset) {
58 if (isNaN(expectedOffset) || Math.abs(node.offsetTop - expectedOffset) > = 1) 66 if (isNaN(expectedOffset) || Math.abs(node.offsetTop - expectedOffset) > = 1)
59 failures.push("Expected " + expectedOffset + " for offsetTop, but go t " + node.offsetTop + ". "); 67 failures.push("Expected " + expectedOffset + " for offsetTop, but go t " + node.offsetTop + ". ");
60 } 68 }
61 69
70 var expectedOffset = checkAttribute(output, node, "data-positioned-offset-x" );
71 if (expectedOffset) {
72 var actualOffset = node.getBoundingClientRect().left - positionedAncesto r(node).getBoundingClientRect().left;
73 if (isNaN(expectedOffset) || Math.abs(actualOffset - expectedOffset) >= 1)
74 failures.push("Expected " + expectedOffset + " for getBoundingClient Rect().left offset, but got " + actualOffset + ". ");
75 }
76
77 var expectedOffset = checkAttribute(output, node, "data-positioned-offset-y" );
78 if (expectedOffset) {
79 var actualOffset = node.getBoundingClientRect().top - positionedAncestor (node).getBoundingClientRect().top;
80 if (isNaN(expectedOffset) || Math.abs(actualOffset - expectedOffset) >= 1)
81 failures.push("Expected " + expectedOffset + " for getBoundingClient Rect().top offset, but got " + actualOffset + ". ");
82 }
83
62 var expectedWidth = checkAttribute(output, node, "data-expected-client-width "); 84 var expectedWidth = checkAttribute(output, node, "data-expected-client-width ");
63 if (expectedWidth) { 85 if (expectedWidth) {
64 if (isNaN(expectedWidth) || Math.abs(node.clientWidth - expectedWidth) > = 1) 86 if (isNaN(expectedWidth) || Math.abs(node.clientWidth - expectedWidth) > = 1)
65 failures.push("Expected " + expectedWidth + " for clientWidth, but g ot " + node.clientWidth + ". "); 87 failures.push("Expected " + expectedWidth + " for clientWidth, but g ot " + node.clientWidth + ". ");
66 } 88 }
67 89
68 var expectedHeight = checkAttribute(output, node, "data-expected-client-heig ht"); 90 var expectedHeight = checkAttribute(output, node, "data-expected-client-heig ht");
69 if (expectedHeight) { 91 if (expectedHeight) {
70 if (isNaN(expectedHeight) || Math.abs(node.clientHeight - expectedHeight ) >= 1) 92 if (isNaN(expectedHeight) || Math.abs(node.clientHeight - expectedHeight ) >= 1)
71 failures.push("Expected " + expectedHeight + " for clientHeight, but got " + node.clientHeight + ". "); 93 failures.push("Expected " + expectedHeight + " for clientHeight, but got " + node.clientHeight + ". ");
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return false; 242 return false;
221 } 243 }
222 244
223 var pre = document.querySelector('.FAIL'); 245 var pre = document.querySelector('.FAIL');
224 if (pre) 246 if (pre)
225 setTimeout(function() { pre.previousSibling.scrollIntoView(); }, 0); 247 setTimeout(function() { pre.previousSibling.scrollIntoView(); }, 0);
226 return result; 248 return result;
227 } 249 }
228 250
229 })(); 251 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698