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 @@
<script>
function parseFontSizeInPx(element, pseudoElement) {
const value = CSSNumericValue.parse(getComputedStyle(element, pseudoElement).fontSize);
if (!value || !(value instanceof CSSUnitValue) || value.unit !== 'px')
throw 'Cannot parse width in pixels';
return value.value;
const value = getComputedStyle(element, pseudoElement).fontSize;
if (!value.endsWith('px'))
return NaN;
return parseFloat(value);
}
const testCases = ['before', 'after', 'first-letter', 'first-line', 'marker'];
......
......@@ -28,10 +28,10 @@
<script>
function parseWidthInPx(element) {
const value = CSSNumericValue.parse(getComputedStyle(element).width);
if (!value || !(value instanceof CSSUnitValue) || value.unit !== 'px')
throw 'Cannot parse width in pixels';
return value.value;
const value = getComputedStyle(element).width;
if (!value.endsWith('px'))
return NaN;
return parseFloat(value);
}
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