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

Unified Diff: LayoutTests/fast/css/large-numbers.html

Issue 1120133004: Serialize <number> to round to at most 6 decimals (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Try to fix win Created 5 years, 7 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: LayoutTests/fast/css/large-numbers.html
diff --git a/LayoutTests/fast/css/large-numbers.html b/LayoutTests/fast/css/large-numbers.html
index a52a7b3f91041e5119dfaeabe4f11ee2c9e59c8c..3fcbe55c7e5eb9f320af355481e1003611f72ed7 100644
--- a/LayoutTests/fast/css/large-numbers.html
+++ b/LayoutTests/fast/css/large-numbers.html
@@ -18,19 +18,32 @@
function testSize(width, opt_expectedWidth)
{
var expectedWidth = typeof opt_expectedWidth == 'number' ? opt_expectedWidth : width;
-
+
el.style.width = width + 'px';
var style = window.getComputedStyle(el, null);
var rect = el.getBoundingClientRect();
+ if (el.offsetWidth == expectedWidth && rect.width == expectedWidth)
+ testPassed('element.width = ' + width + 'px, returns offsetWidth, rect.width expected.');
+ else
+ testFailed('element.width = ' + width + 'px, returns offsetWidth ' + el.offsetWidth + ', rect.width ' + rect.width + ', expected ' + expectedWidth + '.');
+ }
+
+ function testComputedWidth(width, opt_expectedWidth)
+ {
+ var expectedWidth = typeof opt_expectedWidth == 'number' ? opt_expectedWidth : width;
+
+ el.style.width = width + 'px';
+
+ var style = window.getComputedStyle(el, null);
var computedWidth = Number(style.width.replace('px', ''));
- if (el.offsetWidth == expectedWidth && rect.width == expectedWidth && computedWidth == expectedWidth)
- testPassed('element.width = ' + width + 'px, returns offsetWidth, rect.width and computed width as expected.');
+ if (computedWidth == expectedWidth)
+ testPassed('element.width = ' + width + 'px, returns computed width as expected.');
else
- testFailed('element.width = ' + width + 'px, returns offsetWidth ' + el.offsetWidth + ', rect.width ' + rect.width + ' and computed width ' + computedWidth + ', expected ' + expectedWidth + '.');
+ testFailed('element.width = ' + width + 'px, returns computed width ' + computedWidth + ', expected ' + expectedWidth + '.');
}
-
-
+
+
function testLeft(left, opt_expectedLeft)
{
var expectedLeft = typeof opt_expectedLeft == 'number' ? opt_expectedLeft : left;
@@ -39,13 +52,26 @@
var style = window.getComputedStyle(el, null);
var rect = el.getBoundingClientRect();
+ if (el.offsetLeft == expectedLeft && rect.left == expectedLeft)
+ testPassed('element.left = ' + left + 'px, returns offsetLeft, rect.left as expected.');
+ else
+ testFailed('element.left = ' + left + 'px, returns offsetLeft ' + el.offsetLeft + ', rect.left ' + rect.left + ', expected ' + expectedLeft + '.');
+ }
+
+ function testComputedLeft(left, opt_expectedLeft)
+ {
+ var expectedLeft = typeof opt_expectedLeft == 'number' ? opt_expectedLeft : left;
+
+ el.style.left = left + 'px';
+
+ var style = window.getComputedStyle(el, null);
var computedLeft = Number(style.left.replace('px', ''));
- if (el.offsetLeft == expectedLeft && rect.left == expectedLeft && computedLeft == expectedLeft)
- testPassed('element.left = ' + left + 'px, returns offsetLeft, rect.left and computed left as expected.');
+ if (computedLeft == expectedLeft)
+ testPassed('element.left = ' + left + 'px, returns computed left as expected.');
else
- testFailed('element.left = ' + left + 'px, returns offsetLeft ' + el.offsetLeft + ', rect.left ' + rect.left + ' and computed left ' + computedLeft + ', expected ' + expectedLeft + '.');
+ testFailed('element.left = ' + left + 'px, returns computedLeft, expected ' + expectedLeft + '.');
}
-
+
var el = document.createElement('div');
el.className = 'test';
document.body.appendChild(el);
@@ -81,6 +107,39 @@
testSize(-10000000000, 0);
testSize(-100000000000, 0);
+ MAX_VALUE = 33554400;
+ MIN_VALUE = -33554400;
+
+ testComputedWidth(0);
+ testComputedWidth(1);
+ testComputedWidth(10);
+ testComputedWidth(100);
+ testComputedWidth(10000);
+ testComputedWidth(100000);
+ testComputedWidth(1000000);
+ testComputedWidth(10000000);
+ testComputedWidth(100000000, MAX_VALUE);
+ testComputedWidth(1000000000, MAX_VALUE);
+ testComputedWidth(10000000000, MAX_VALUE);
+ testComputedWidth(100000000000, MAX_VALUE);
+ testComputedWidth(1000000000000, MAX_VALUE);
+
+ testSize(0, 0);
+ testSize(-1, 0);
+ testSize(-10, 0);
+ testSize(-100, 0);
+ testSize(-10000, 0);
+ testSize(-100000, 0);
+ testSize(-1000000, 0);
+ testSize(-10000000, 0);
+ testSize(-100000000, 0);
+ testSize(-1000000000, 0);
+ testSize(-10000000000, 0);
+ testSize(-100000000000, 0);
+
+ MAX_VALUE = 33554428;
+ MIN_VALUE = -33554430;
+
// Test setting style.left, negative values are considered valid.
testLeft(0);
testLeft(1);
@@ -109,6 +168,36 @@
testLeft(-100000000000, MIN_VALUE);
testLeft(-1000000000000, MIN_VALUE);
+ MAX_VALUE = 33554400;
+ MIN_VALUE = -33554400;
+
+ testComputedLeft(0);
+ testComputedLeft(1);
+ testComputedLeft(10);
+ testComputedLeft(100);
+ testComputedLeft(10000);
+ testComputedLeft(100000);
+ testComputedLeft(1000000);
+ testComputedLeft(10000000);
+ testComputedLeft(100000000, MAX_VALUE);
+ testComputedLeft(1000000000, MAX_VALUE);
+ testComputedLeft(10000000000, MAX_VALUE);
+ testComputedLeft(100000000000, MAX_VALUE);
+ testComputedLeft(1000000000000, MAX_VALUE);
+
+ testComputedLeft(-1);
+ testComputedLeft(-10);
+ testComputedLeft(-100);
+ testComputedLeft(-10000);
+ testComputedLeft(-100000);
+ testComputedLeft(-1000000);
+ testComputedLeft(-10000000);
+ testComputedLeft(-100000000, MIN_VALUE);
+ testComputedLeft(-1000000000, MIN_VALUE);
+ testComputedLeft(-10000000000, MIN_VALUE);
+ testComputedLeft(-100000000000, MIN_VALUE);
+ testComputedLeft(-1000000000000, MIN_VALUE);
+
document.body.removeChild(el);
</script>
</body>
« no previous file with comments | « LayoutTests/fast/css/large-number-round-trip-expected.txt ('k') | LayoutTests/fast/css/large-numbers-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698