haikuwebkit/LayoutTests/fast/box-shadow/box-shadow-invalid-values.html

50 lines
1.8 KiB
HTML
Raw Permalink Normal View History

Ignore order when parsing inset and color for box-shadow https://bugs.webkit.org/show_bug.cgi?id=182677 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2020-11-03 Reviewed by Simon Fraser. LayoutTests/imported/w3c: Update tests to pass now that we parse `inset`, a color, and the lengths component of <shadow> values in any order. https://drafts.csswg.org/css-backgrounds/#typedef-shadow * web-platform-tests/css/css-backgrounds/parsing/box-shadow-valid-expected.txt: Source/WebCore: According to the spec [1], box-shadow should allow the inset keyword, a color, and the lengths component in any order. Our implementation allowed only 2 out of the 4 possible orders; fix our parsing to match the spec. [1]: https://drafts.csswg.org/css-backgrounds/#typedef-shadow Above description is (almost) a direct quote from <cnardi@chromium.org> who previously submitted a patch for this bug. Change is covered by existing test LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/box-shadow-valid.html and new test LayoutTests/fast/box-shadow/box-shadow-invalid-values.html * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeSingleShadow): Parse inset, color, and lengths component of a single <shadow> in any order. LayoutTests: Add additional test coverage around rejecting invalid box-shadow values (e.g. multiple colors, multiple insets, multiple lengths-components). https://drafts.csswg.org/css-backgrounds/#typedef-shadow * LayoutTests/fast/box-shadow/box-shadow-invalid-values.html: Added. * LayoutTests/fast/box-shadow/box-shadow-invalid-values-expected.txt: Added. Canonical link: https://commits.webkit.org/231198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269354 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-04 04:59:03 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<title>box-shadow parse should reject invalid values</title>
</head>
<body>
<div id="target"></div>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
let target = document.getElementById('target')
let test_invalid_value = (value) => {
test(() => {
target.style['box-shadow'] = ''
target.style['box-shadow'] = value
assert_equals(target.style.getPropertyValue('box-shadow'), '');
}, '#target.style["box-shadow"] = ' + JSON.stringify(value) + ' should not set the property value')
}
// Disallow multiple color components.
test_invalid_value('red green -4px 4px')
test_invalid_value('red -4px 4px green')
test_invalid_value('red inset -4px 4px red')
test_invalid_value('-4px 4px red green')
// Disallow multiple `inset` keyword components.
test_invalid_value('inset inset -4px 4px')
test_invalid_value('inset inset -4px 4px red')
test_invalid_value('inset -4px 4px inset')
test_invalid_value('inset green -4px 4px inset')
test_invalid_value('-4px 4px inset inset')
// Disallow multiple lengths components.
test_invalid_value('-4px 4px inset 8px -8px')
test_invalid_value('-4px 4px 2px inset 8px -8px')
test_invalid_value('-4px 4px 2px 2px inset 8px -8px')
test_invalid_value('-4px 4px 2px 2px inset 8px -8px 2px')
test_invalid_value('-4px 4px 2px 2px inset 8px -8px 2px 2px')
test_invalid_value('-4px 4px red 8px -8px')
test_invalid_value('-4px 4px 2px red 8px -8px')
test_invalid_value('-4px 4px 2px 2px red 8px -8px')
test_invalid_value('-4px 4px 2px 2px red 8px -8px 2px')
test_invalid_value('-4px 4px 2px 2px red 8px -8px 2px 2px')
test_invalid_value('inset -4px 4px 8px 8px 2px 2px')
test_invalid_value('red -4px 4px 8px 8px 2px 2px')
</script>
</body>
</html>