-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 272448.627@safari-7618-branch (51293a5). rdar://115346002
[CSS] Fix bug when using a coalesced CSSValuePair with Typed OM rdar://115346002 Reviewed by Chris Dumez. We use the CSSParser and the serialization of CSSValue to validate the input of Typed OM set(). Unfortunately, sometimes a CSSValuePair serializes to a single value while it actually contains two values: this confuses the StyleBuilder. If the pair has the same values twice "10px 10px", it serializes to only "10px", thus pass our string-based check (inside setProperty), but then crash when the actual value is a pair of length instead of a simple length. The more frequent case when the two values are distincts, such as "10px 30px", is already prevented by the string-based check. A proper fix would be to have validation method which doesn't work on the serialized string value but on the actual typed CSSValue. For the moment, we avoid crashing and warn the user with an error. * LayoutTests/fast/css/css-typed-om-typeerror-coalescing-pair-expected.txt: Added. * LayoutTests/fast/css/css-typed-om-typeerror-coalescing-pair.html: Added. * Source/WebCore/css/CSSValuePair.cpp: (WebCore::CSSValuePair::canBeCoalesced const): * Source/WebCore/css/CSSValuePair.h: * Source/WebCore/css/typedom/StylePropertyMap.cpp: (WebCore::StylePropertyMap::set): * Source/WebCore/style/StyleBuilderConverter.h: (WebCore::Style::BuilderConverter::convertLengthSizing): Canonical link: https://commits.webkit.org/272448.627@safari-7618-branch Canonical link: https://commits.webkit.org/274313.217@webkitglib/2.44
- Loading branch information
Showing
6 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
LayoutTests/fast/css/css-typed-om-typeerror-coalescing-pair-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
This test checks that we throw error when using Typed OM set() with a coalesced pair of values. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS () => { | ||
var element = document.getElementById("element"); | ||
element.attributeStyleMap.set('width', CSSStyleValue.parse('border-bottom-left-radius', '30px')) | ||
} threw exception NotSupportedError: Invalid values. | ||
PASS () => { | ||
var element2 = document.getElementById("element2"); | ||
element2.attributeStyleMap.set('width', CSSStyleValue.parse('border-bottom-left-radius', '30px 10px')) | ||
} threw exception TypeError: Invalid values. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
25 changes: 25 additions & 0 deletions
25
LayoutTests/fast/css/css-typed-om-typeerror-coalescing-pair.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="../../resources/js-test.js"></script> | ||
|
||
<div id="element"> | ||
</div> | ||
<div id="element2"> | ||
</div> | ||
|
||
<script> | ||
description('This test checks that we throw error when using Typed OM set() with a coalesced pair of values.') | ||
shouldThrow( | ||
() => { | ||
var element = document.getElementById("element"); | ||
element.attributeStyleMap.set('width', CSSStyleValue.parse('border-bottom-left-radius', '30px')) | ||
}, "'NotSupportedError: Invalid values'"); | ||
shouldThrow( | ||
() => { | ||
var element2 = document.getElementById("element2"); | ||
element2.attributeStyleMap.set('width', CSSStyleValue.parse('border-bottom-left-radius', '30px 10px')) | ||
}, "'TypeError: Invalid values'"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters