fune/testing/web-platform/tests/css/css-variables/variable-cssText.html
Steinar H. Gunderson 3c7e4e1cec Bug 1821354 [wpt PR 38905] - Trim whitespace around CSS custom declarations., a=testonly
Automatic update from web-platform-tests
Trim whitespace around CSS custom declarations.

There was a spec change a few years back, requiring us to
strip spaces and comments from the beginning and end of CSS
custom property declarations.

We take a slight performance hit:

Initial style (µs)     Before     After    Perf      95% CI (BCa)
=================== ========= ========= ======= =================
ECommerce               10041      9994   +0.5%  [ +0.1%,  +0.9%]
Encyclopedia           106735    106744   -0.0%  [ -0.6%,  +0.4%]
Extension              132830    133009   -0.1%  [ -0.6%,  +0.2%]
News                    42534     42653   -0.3%  [ -1.0%,  +0.1%]
Search                   2636      2662   -1.0%  [ -1.4%,  -0.6%]
Social1                 23298     23312   -0.1%  [ -0.3%,  +0.2%]
Social2                  1039      1042   -0.3%  [ -1.0%,  +0.4%]
Sports                  42680     42985   -0.7%  [ -1.0%,  -0.5%]
Video                   41971     42134   -0.4%  [ -0.6%,  -0.1%]
Geometric mean                            -0.3%  [ -0.5%,  -0.1%]

Parse (µs)             Before     After    Perf      95% CI (BCa)
=================== ========= ========= ======= =================
ECommerce                1360      1372   -0.9%  [ -1.2%,  -0.4%]
Encyclopedia             7349      7384   -0.5%  [ -0.7%,  -0.2%]
Extension                1349      1352   -0.2%  [ -1.2%,  +0.2%]
News                     7929      7982   -0.7%  [ -1.0%,  -0.3%]
Search                   4965      4997   -0.6%  [ -0.9%,  -0.4%]
Social1                 14752     14837   -0.6%  [ -0.8%,  -0.3%]
Social2                   617       620   -0.4%  [ -1.4%,  +0.7%]
Sports                  56182     56318   -0.2%  [ -0.6%,  +0.0%]
Video                   34720     35091   -1.1%  [ -1.3%,  -0.8%]
Geometric mean                            -0.6%  [ -0.9%,  -0.4%]

Recalc style (µs)      Before     After    Perf      95% CI (BCa)
=================== ========= ========= ======= =================
ECommerce               11417     11378   +0.3%  [ -0.2%,  +0.8%]
Encyclopedia            83808     84066   -0.3%  [ -1.4%,  +0.1%]
Extension              120362    120394   -0.0%  [ -0.7%,  +0.3%]
News                    31566     31549   +0.1%  [ -1.2%,  +0.5%]
Search                    242       242   -0.0%  [ -1.5%,  +0.7%]
Social1                 17242     17203   +0.2%  [ -0.1%,  +0.4%]
Social2                   602       593   +1.4%  [ +0.7%,  +2.1%]
Sports                  22817     22874   -0.3%  [ -0.5%,  +0.0%]
Video                   25931     25969   -0.1%  [ -0.4%,  +0.1%]
Geometric mean                            +0.1%  [ -0.5%,  +0.5%]

We save a little bit of RAM, obviously, but not much.

Fixed: 1211112
Fixed: 1220144
Change-Id: Ib7656de36d6a94d85ba25ecf60e9879b21c36468
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3341633
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Steinar H Gunderson <sesse@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1116326}

--

wpt-commits: c3ab769723cb249535a8845cc35af80975b8926d
wpt-pr: 38905
2023-03-29 12:51:13 +00:00

55 lines
2.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Parse, store, and serialize CSS variable (thorugh css Text)</title>
<meta rel="author" title="Kevin Babbitt">
<meta rel="author" title="Greg Whitworth">
<link rel="author" title="Microsoft Corporation" href="http://microsoft.com" />
<link rel="help" href="http://www.w3.org/TR/css-variables-1/#serializing-custom-props">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="target1" style="--var: var1;"></div>
<div id="target2" style="margin: var(--prop);"></div>
<div id="target3" style="background: var(--prop);"></div>
<div id="target4" style="margin: var(--prop) !important;"></div>
<div id="target5" style="background: var(--prop) !important;"></div>
<div id="target6" style="background: var(--prop); background: green;"></div>
<div id="target7" style="background: green; background: var(--prop);"></div>
<div id="target8" style="color: green; color: var(--prop);"></div>
<div id="target9" style="margin: var(--prop); margin-top: 10px"></div>
<div id="target10"style="expando: var(--prop);"></div>
<div id="target11"style="color: /* comment that must not be preserved */ var(--prop) /* kept comment */ var(--prop); /* another stripped comment */ /* indeed */ "></div>
<script type="text/javascript">
"use strict";
var testcases = [
{ element: "target1", expectedCssText: "--var: var1;" },
{ element: "target2", expectedCssText: "margin: var(--prop);" },
{ element: "target3", expectedCssText: "background: var(--prop);" },
{ element: "target4", expectedCssText: "margin: var(--prop) !important;" },
{ element: "target5", expectedCssText: "background: var(--prop) !important;" },
{ element: "target6", expectedCssText: "background: green;" },
{ element: "target7", expectedCssText: "background: var(--prop);" },
{ element: "target8", expectedCssText: "color: var(--prop);" },
{ element: "target9", expectedCssText: "margin-right: ; margin-bottom: ; margin-left: ; margin-top: 10px;" },
{ element: "target10", expectedCssText: "" },
{ element: "target11", expectedCssText: "color: var(--prop) /* kept comment */ var(--prop);" }
];
testcases.forEach(function (testcase) {
test( function () {
var div = document.getElementById(testcase.element);
var actualCssText = div.style.cssText;
assert_equals(actualCssText, testcase.expectedCssText);
}, testcase.element);
});
</script>
</body>
</html>