Skip to content

Commit

Permalink
VTTRegion::setScroll should ignore assignment of an invalid string in…
Browse files Browse the repository at this point in the history
…stead of throwing SyntaxError

https://bugs.webkit.org/show_bug.cgi?id=261310

Reviewed by Eric Carlson.

The spec that VTTRegion::setScroll throws a SyntaxError in dead code
has been removed at w3c/webvtt#28,
and now it should ignore assignment of an invalid string.

WebKit is failing the corresponding WPT:
https://wpt.fyi/results/webvtt/api/VTTRegion/scroll.html?label=experimental&label=master&aligned&q=webvtt

* LayoutTests/imported/w3c/web-platform-tests/webvtt/api/VTTRegion/constructor-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/webvtt/api/VTTRegion/scroll-expected.txt:
* LayoutTests/media/track/regions-webvtt/vtt-region-constructor-expected.txt:
* Source/WebCore/html/track/VTTRegion.cpp:
(WebCore::VTTRegion::setScroll):
* Source/WebCore/html/track/VTTRegion.h:

Canonical link: https://commits.webkit.org/267828@main
  • Loading branch information
cola119 authored and Ahmad Saleem committed Sep 9, 2023
1 parent dc25ee4 commit 8de0edf
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

PASS VTTRegion() initial values
FAIL VTTRegion() mutations The string did not match the expected pattern.
PASS VTTRegion() mutations

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL VTTRegion.scroll script-created region The string did not match the expected pattern.
PASS VTTRegion.scroll script-created region

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ EXPECTED (region.width == '100') OK

** Test that incorrect mutation keeps previous valid values. **
RUN(region.scroll = 'invalid-scroll-value')
SyntaxError: The string did not match the expected pattern.
EXPECTED (region.scroll == '') OK

Invalid percentage value: -1
Expand Down
5 changes: 1 addition & 4 deletions Source/WebCore/html/track/VTTRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,14 @@ const AtomString& VTTRegion::scroll() const
return m_scroll ? upKeyword() : emptyAtom();
}

ExceptionOr<void> VTTRegion::setScroll(const AtomString& value)
void VTTRegion::setScroll(const AtomString& value)
{
if (value.isEmpty()) {
m_scroll = false;
return { };
}
if (value == upKeyword()) {
m_scroll = true;
return { };
}
return Exception { SyntaxError };
}

void VTTRegion::updateParametersFromRegion(const VTTRegion& other)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/track/VTTRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class VTTRegion final : public RefCounted<VTTRegion>, public ContextDestructionO
ExceptionOr<void> setViewportAnchorY(double);

const AtomString& scroll() const;
ExceptionOr<void> setScroll(const AtomString&);
void setScroll(const AtomString&);

void updateParametersFromRegion(const VTTRegion&);

Expand Down

0 comments on commit 8de0edf

Please sign in to comment.