Index: third_party/WebKit/LayoutTests/fast/sub-pixel/sub-pixel-border.html |
diff --git a/third_party/WebKit/LayoutTests/fast/sub-pixel/sub-pixel-border.html b/third_party/WebKit/LayoutTests/fast/sub-pixel/sub-pixel-border.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d70a4956bf24dd689cc263e8f4b69241b240c55d |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/fast/sub-pixel/sub-pixel-border.html |
@@ -0,0 +1,145 @@ |
+<!DOCTYPE html> |
+<html> |
+ <head> |
+ <meta charset="utf-8"> |
+ <title>Test rendering of sub-pixel borders</title> |
+ <style> |
+ .test { |
+ box-sizing: content-box; |
+ display: inline-block; |
+ margin: 5px; |
+ width: 80px; |
+ height: 80px; |
+ border: 1px solid green; |
+ background: lightgreen; |
+ text-align: center; |
+ line-height: 80px; |
+ } |
+ </style> |
+ <script src="../../resources/testharness.js"></script> |
+ <script src="../../resources/testharnessreport.js"></script> |
+ </head> |
+ <body> |
+ <div class="test" style="border-width: 0.25px">0.25px</div> |
+ <div class="test" style="border-width: 0.5px">0.5px</div> |
+ <div class="test" style="border-width: 0.75px">0.75px</div> |
+ <div class="test" style="border-width: 1px">1px</div> |
+ <div class="test" style="border-width: 1.25px">1.25px</div> |
+ <br> |
+ <div class="test" style="border-width: 1.5px">1.5px</div> |
+ <div class="test" style="border-width: 1.75px">1.75px</div> |
+ <div class="test" id="reference-2" style="border-width: 2px">2px</div> |
+ <div class="test" style="border-width: 2.25px">2.25px</div> |
+ <br> |
+ <div class="test" style="border-width: 2.5px">2.5px</div> |
+ <div class="test" style="border-width: 2.75px">2.75px</div> |
+ <div class="test" id="reference-3" style="border-width: 3px">3px</div> |
+ <div class="test" style="border-width: 3.25px">3.25px</div> |
+ <p> |
+ Border thickness should be rounded, not floored, with the exception of |
+ values below 1px where it should always round up. |
+ </p> |
+ <p> |
+ Thus the boxes on each line should have the same effective size and |
+ border thickness. |
+ </p> |
+ <script> |
+ var testElements = {}; |
+ var elements = document.getElementsByClassName('test'); |
+ for (var element, i = 0; element = elements[i]; i++) { |
+ testElements[element.firstChild.nodeValue] = element; |
+ } |
+ |
+ function sizeAsString(element) { |
+ var rect = element.getBoundingClientRect(); |
+ return rect.width.toFixed(2) + 'x' + rect.height.toFixed(2); |
+ } |
+ |
+ function borderAsString(element) { |
+ var style = window.getComputedStyle(element); |
+ return style.borderTopWidth + ' ' + style.borderRightWidth + ' ' + |
+ style.borderBottomWidth + ' ' + style.borderLeftWidth; |
+ } |
+ |
+ test(function() { |
+ var referenceSize = sizeAsString(testElements['1px']); |
+ assert_equals(sizeAsString(testElements['0.25px']), referenceSize, |
+ 'Size of 0.25px box should match 1px reference.'); |
+ assert_equals(sizeAsString(testElements['0.5px']), referenceSize, |
+ 'Size of 0.5px box should match 1px reference.'); |
+ assert_equals(sizeAsString(testElements['0.75px']), referenceSize, |
+ 'Size of 0.75px box should match 1px reference.'); |
+ assert_equals(sizeAsString(testElements['1.25px']), referenceSize, |
+ 'Size of 1.25px box should match 1px reference.'); |
+ }, 'Size of all elements on the first row should match.'); |
+ |
+ test(function() { |
+ assert_equals(borderAsString(testElements['0.25px']), |
+ '1px 1px 1px 1px', |
+ 'Border thickness of 0.25px box should be 1px.'); |
+ assert_equals(borderAsString(testElements['0.5px']), |
+ '1px 1px 1px 1px', |
+ 'Border thickness of 0.5px box should be 1px.'); |
+ assert_equals(borderAsString(testElements['0.75px']), |
+ '1px 1px 1px 1px', |
+ 'Border thickness of 0.75px box should be 1px.'); |
+ assert_equals(borderAsString(testElements['1px']), |
+ '1px 1px 1px 1px', |
+ 'Border thickness of 1px box should be 1px.'); |
+ assert_equals(borderAsString(testElements['1.25px']), |
+ '1px 1px 1px 1px', |
+ 'Border thickness of 1.25px box should be 1px.'); |
+ }, 'All elements on the first row should have a 1px border.'); |
+ |
+ test(function() { |
+ var referenceSize = sizeAsString(testElements['2px']); |
+ assert_equals(sizeAsString(testElements['1.5px']), referenceSize, |
+ 'Size of 1.5px box should match 2px reference.'); |
+ assert_equals(sizeAsString(testElements['1.75px']), referenceSize, |
+ 'Size of 1.75px box should match 2px reference.'); |
+ assert_equals(sizeAsString(testElements['2.25px']), referenceSize, |
+ 'Size of 2.25px box should match 2px reference.'); |
+ }, 'Size of all elements on the second row should match.'); |
+ |
+ test(function() { |
+ assert_equals(borderAsString(testElements['1.5px']), |
+ '2px 2px 2px 2px', |
+ 'Border thickness of 1.5px box should be 2px.'); |
+ assert_equals(borderAsString(testElements['1.75px']), |
+ '2px 2px 2px 2px', |
+ 'Border thickness of 1.75px box should be 2px.'); |
+ assert_equals(borderAsString(testElements['2px']), |
+ '2px 2px 2px 2px', |
+ 'Border thickness of 2px box should be 2px.'); |
+ assert_equals(borderAsString(testElements['2.25px']), |
+ '2px 2px 2px 2px', |
+ 'Border thickness of 2.25px box should be 2px.'); |
+ }, 'All elements on the first row should have a 2px border.'); |
+ |
+ test(function() { |
+ var referenceSize = sizeAsString(testElements['3px']); |
+ assert_equals(sizeAsString(testElements['2.5px']), referenceSize, |
+ 'Size of 2.5px box should match 3px reference.'); |
+ assert_equals(sizeAsString(testElements['2.75px']), referenceSize, |
+ 'Size of 2.75px box should match 3px reference.'); |
+ assert_equals(sizeAsString(testElements['3.25px']), referenceSize, |
+ 'Size of 3.25px box should match 3px reference.'); |
+ }, 'Size of all elements on the third row should match.'); |
+ |
+ test(function() { |
+ assert_equals(borderAsString(testElements['2.5px']), |
+ '3px 3px 3px 3px', |
+ 'Border thickness of 2.5px box should be 3px.'); |
+ assert_equals(borderAsString(testElements['2.75px']), |
+ '3px 3px 3px 3px', |
+ 'Border thickness of 2.75px box should be 3px.'); |
+ assert_equals(borderAsString(testElements['3px']), |
+ '3px 3px 3px 3px', |
+ 'Border thickness of 3px box should be 3px.'); |
+ assert_equals(borderAsString(testElements['3.25px']), |
+ '3px 3px 3px 3px', |
+ 'Border thickness of 3.25px box should be 3px.'); |
+ }, 'All elements on the third row should have a 3px border.'); |
+ </script> |
+ </body> |
+</html> |