Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Always use no-quirks mode for CSS.supports()
https://bugs.webkit.org/show_bug.cgi?id=257643
rdar://110162243

Reviewed by Tim Nguyen.

Align with the standard and other browsers. In particular

  https://drafts.csswg.org/css-color-4/#quirky-color
  https://drafts.csswg.org/css-values-4/#deprecated-quirky-length

mandate this and those are the only quirks applying to CSS.supports().
As stated there this is not applicable to @supports.

* LayoutTests/css3/css-supports-document-parser-context-expected.txt:
* LayoutTests/css3/css-supports-document-parser-context.html:
* LayoutTests/css3/resources/css-supports-document-parser-context-nonstrict.html:
* LayoutTests/imported/w3c/resources/import-expectations.json:
* LayoutTests/imported/w3c/web-platform-tests/quirks/classname-query-after-sibling-adoption.html:
* LayoutTests/imported/w3c/web-platform-tests/quirks/supports-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/quirks/text-decoration-doesnt-propagate-into-tables/standards-expected.html:
* LayoutTests/imported/w3c/web-platform-tests/quirks/text-decoration-doesnt-propagate-into-tables/standards-ref.html:
* LayoutTests/imported/w3c/web-platform-tests/quirks/text-decoration-doesnt-propagate-into-tables/standards.html:
* LayoutTests/tests-options.json:
* Source/WebCore/css/DOMCSSNamespace.cpp:
(WebCore::DOMCSSNamespace::supports):

Canonical link: https://commits.webkit.org/264835@main
  • Loading branch information
annevk committed Jun 2, 2023
1 parent ff223cf commit a21e36a
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 12 deletions.
@@ -1,10 +1,10 @@
Makes sure that CSS.supports() is parsed within the context of the owning document.
Makes sure that CSS.supports() uses no-quirks mode.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS document.test1 is false
PASS document.test2 is true
PASS document.test2 is false
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
4 changes: 2 additions & 2 deletions LayoutTests/css3/css-supports-document-parser-context.html
Expand Up @@ -5,7 +5,7 @@
</head>
<body>
<script>
description("Makes sure that CSS.supports() is parsed within the context of the owning document.")
description("Makes sure that CSS.supports() uses no-quirks mode.")

document.test1 = undefined;
document.test2 = undefined;
Expand All @@ -23,7 +23,7 @@
++counter;
if (counter == 2) {
shouldBeFalse("document.test1");
shouldBeTrue("document.test2");
shouldBeFalse("document.test2");
finishJSTest();
}
}
Expand Down
Expand Up @@ -4,7 +4,7 @@
</head>
<body>
<script>
shouldBeTrue("CSS.supports('color', '-webkit-focus-ring-color')");
shouldBeFalse("CSS.supports('color', '-webkit-focus-ring-color')");
window.parent.document.test2 = CSS.supports('color', '-webkit-focus-ring-color');
</script>
<script src="../../resources/js-test-post.js"></script>
Expand Down
3 changes: 1 addition & 2 deletions LayoutTests/imported/w3c/resources/import-expectations.json
Expand Up @@ -422,8 +422,7 @@
"web-platform-tests/progress-events": "skip",
"web-platform-tests/proximity": "skip",
"web-platform-tests/push-api": "import",
"web-platform-tests/quirks-mode": "skip",
"web-platform-tests/quirks/unitless-length": "import",
"web-platform-tests/quirks": "import",
"web-platform-tests/referrer-policy": "import",
"web-platform-tests/remote-playback": "import",
"web-platform-tests/reporting": "import",
Expand Down
Expand Up @@ -2,8 +2,8 @@
<html>
<head>
<title>Quirks mode elements with class names should remain queriable regardless of sibling adoption into standards mode documents</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div>
Expand Down
@@ -1,8 +1,8 @@

PASS Sanity check @supports color
PASS @supports quirky color
FAIL CSS.supports() quirky color assert_false: expected false got true
PASS CSS.supports() quirky color
PASS Sanity check @supports length
PASS @supports quirky length
FAIL CSS.supports() quirky length assert_false: expected false got true
PASS CSS.supports() quirky length

Expand Up @@ -7,6 +7,7 @@
.tbody { display: table-row-group }
.tr { display: table-row }
.td { display: table-cell }
tbody { vertical-align: initial; }
</style>
<div><table><tr><td><u>this should be underlined</u></table></div>
<div><table class=inline-table><tr><td>this should not be underlined</table></div>
Expand Down
Expand Up @@ -7,6 +7,7 @@
.tbody { display: table-row-group }
.tr { display: table-row }
.td { display: table-cell }
tbody { vertical-align: initial; }
</style>
<div><table><tr><td><u>this should be underlined</u></table></div>
<div><table class=inline-table><tr><td>this should not be underlined</table></div>
Expand Down
Expand Up @@ -8,6 +8,7 @@
.tbody { display: table-row-group }
.tr { display: table-row }
.td { display: table-cell }
tbody { vertical-align: initial; }
</style>
<div><u><table><tr><td>this should be underlined</table></u></div>
<div><u><table class=inline-table><tr><td>this should not be underlined</table></u></div>
Expand Down
11 changes: 10 additions & 1 deletion LayoutTests/tests-options.json
Expand Up @@ -5255,7 +5255,16 @@
"imported/w3c/web-platform-tests/pointerevents/pointerlock/pointerevent_movementxy.html": [
"slow"
],
"imported/w3c/web-platform-tests/quirks/hashless-hex-color.html": [
"imported/w3c/web-platform-tests/quirks/hashless-hex-color/limited-quirks.html": [
"slow"
],
"imported/w3c/web-platform-tests/quirks/hashless-hex-color/no-quirks.html": [
"slow"
],
"imported/w3c/web-platform-tests/quirks/hashless-hex-color/quirks.html": [
"slow"
],
"imported/w3c/web-platform-tests/quirks/unitless-length/no-quirks.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/callback-iframe.html": [
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/css/DOMCSSNamespace.cpp
Expand Up @@ -47,6 +47,7 @@ namespace WebCore {
bool DOMCSSNamespace::supports(Document& document, const String& property, const String& value)
{
CSSParserContext parserContext(document);
parserContext.mode = HTMLStandardMode;

auto propertyNameWithoutWhitespace = property;
CSSPropertyID propertyID = cssPropertyID(propertyNameWithoutWhitespace);
Expand Down Expand Up @@ -75,6 +76,7 @@ bool DOMCSSNamespace::supports(Document& document, const String& property, const
bool DOMCSSNamespace::supports(Document& document, const String& conditionText)
{
CSSParserContext context(document);
context.mode = HTMLStandardMode;
CSSParser parser(context);
return parser.parseSupportsCondition(conditionText);
}
Expand Down

0 comments on commit a21e36a

Please sign in to comment.