Commit 4677903b authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Use parseFloat() to parse CSS pixels values in two WPT

Two WPT use CSSNumericValue.parse() to parse CSS pixel values, which
makes the tests basically Chrome-only. This patch changes them to use
parseFloat() directly so that other browsers can pass.

Bug: 441925
Change-Id: I01d6d2999cf4266bd6d3bda521d2bdfc8732ab7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2031932Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737036}
parent 63239418
...@@ -41,10 +41,10 @@ ...@@ -41,10 +41,10 @@
<script> <script>
function parseFontSizeInPx(element, pseudoElement) { function parseFontSizeInPx(element, pseudoElement) {
const value = CSSNumericValue.parse(getComputedStyle(element, pseudoElement).fontSize); const value = getComputedStyle(element, pseudoElement).fontSize;
if (!value || !(value instanceof CSSUnitValue) || value.unit !== 'px') if (!value.endsWith('px'))
throw 'Cannot parse width in pixels'; return NaN;
return value.value; return parseFloat(value);
} }
const testCases = ['before', 'after', 'first-letter', 'first-line', 'marker']; const testCases = ['before', 'after', 'first-letter', 'first-line', 'marker'];
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
<script> <script>
function parseWidthInPx(element) { function parseWidthInPx(element) {
const value = CSSNumericValue.parse(getComputedStyle(element).width); const value = getComputedStyle(element).width;
if (!value || !(value instanceof CSSUnitValue) || value.unit !== 'px') if (!value.endsWith('px'))
throw 'Cannot parse width in pixels'; return NaN;
return value.value; return parseFloat(value);
} }
const testCases = document.querySelectorAll('.test'); const testCases = document.querySelectorAll('.test');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment