Truly independent web browser
LibWeb: Throw for out-of-range VTTCue position and size values
Shannon Boothf51852e0e6ca
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_vtt/vtt_cue.rs b/Libraries/LibWeb/Bindings/Rust/src/web_vtt/vtt_cue.rsindex 8d71bc25148..7d24f987f57 100644--- a/Libraries/LibWeb/Bindings/Rust/src/web_vtt/vtt_cue.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/web_vtt/vtt_cue.rs@@ -278,6 +278,17 @@ impl VTTCue {// https://w3c.github.io/webvtt/#dom-vttcue-positionpub(crate) fn set_position(&self, _: &mut CallContext, value: LineAndPositionSetting) -> WebIdlResult<()> {+ // On setting, if the new value is negative or greater than 100, then an IndexSizeError exception must be thrown.+ if let LineAndPositionSetting::Double(position) = value+ && !(0.0..=100.0).contains(&position)+ {+ return Err(Exception::index_size_error(Utf16String::from_utf8(+ "Value is negative or greater than 100",+ )));+ }++ // Otherwise, the WebVTT cue position must be set to the new value; if the new value is the string "auto", then+ // it must be interpreted as the special value auto.self.position.set(value);Ok(())}@@ -300,6 +311,14 @@ impl VTTCue {// https://w3c.github.io/webvtt/#dom-vttcue-sizepub(crate) fn set_size(&self, _: &mut CallContext, value: f64) -> WebIdlResult<()> {+ // On setting, if the new value is negative or greater than 100, then an IndexSizeError exception must be thrown.+ if !(0.0..=100.0).contains(&value) {+ return Err(Exception::index_size_error(Utf16String::from_utf8(+ "Value is negative or greater than 100",+ )));+ }++ // Otherwise, the WebVTT cue size must be set to the new value.self.size.set(value);Ok(())}diff --git a/Tests/LibWeb/Text/expected/wpt-import/webvtt/api/VTTCue/position.txt b/Tests/LibWeb/Text/expected/wpt-import/webvtt/api/VTTCue/position.txtindex 0a80f278bc1..18fa8c75262 100644--- a/Tests/LibWeb/Text/expected/wpt-import/webvtt/api/VTTCue/position.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/webvtt/api/VTTCue/position.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail VTTCue.position, script-created cue\ No newline at end of file+1 Pass+Pass VTTCue.position, script-created cue\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/webvtt/api/VTTCue/size.txt b/Tests/LibWeb/Text/expected/wpt-import/webvtt/api/VTTCue/size.txtindex 1bd5940794f..b39d1d9bd65 100644--- a/Tests/LibWeb/Text/expected/wpt-import/webvtt/api/VTTCue/size.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/webvtt/api/VTTCue/size.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail VTTCue.size, script-created cue\ No newline at end of file+1 Pass+Pass VTTCue.size, script-created cue\ No newline at end of file