Mark WebCodecs width/height properties with [EnforceRange]
We expect these values to be within valid range.
Bug: 1189576
Change-Id: I3f592983a3d665b16f632fdf2cb6dbdedf3734ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2792742
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Commit-Queue: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#867919}
diff --git a/webcodecs/video-frame.any.js b/webcodecs/video-frame.any.js
index 07ab30c..b720372 100644
--- a/webcodecs/video-frame.any.js
+++ b/webcodecs/video-frame.any.js
@@ -119,8 +119,8 @@
assert_throws_dom(
'ConstraintError', () => {constructFrame({
timestamp: 1234,
- codedWidth: 1 << 32 - 1,
- codedHeight: 1 << 32 - 1
+ codedWidth: Math.pow(2, 32) - 1,
+ codedHeight: Math.pow(2, 32) - 1,
})},
'invalid coded size');
assert_throws_dom(
@@ -150,31 +150,31 @@
() => {constructFrame(
{timestamp: 1234, codedWidth: 4, codedHeight: 2, cropHeight: 0})},
'invalid crop height');
- assert_throws_dom(
- 'ConstraintError', () => {constructFrame({
- timestamp: 1234,
- codedWidth: 4,
- codedHeight: 2,
- cropHeight: -1,
- cropWidth: -100
- })},
+ assert_throws_js(
+ TypeError, () => {constructFrame({
+ timestamp: 1234,
+ codedWidth: 4,
+ codedHeight: 2,
+ cropHeight: -1,
+ cropWidth: -100
+ })},
'invalid negative crop');
- assert_throws_dom(
- 'ConstraintError', () => {constructFrame({
- timestamp: 1234,
- codedWidth: 4,
- codedHeight: 2,
- displayWidth: 1 << 32 - 1
- })},
+ assert_throws_js(
+ TypeError, () => {constructFrame({
+ timestamp: 1234,
+ codedWidth: 4,
+ codedHeight: 2,
+ displayWidth: Math.pow(2, 32),
+ })},
'invalid display width');
- assert_throws_dom(
- 'ConstraintError', () => {constructFrame({
- timestamp: 1234,
- codedWidth: 4,
- codedHeight: 2,
- displayWidth: 1 << 32 - 1,
- displayHeight: 1 << 32
- })},
+ assert_throws_js(
+ TypeError, () => {constructFrame({
+ timestamp: 1234,
+ codedWidth: 4,
+ codedHeight: 2,
+ displayWidth: Math.pow(2, 32) - 1,
+ displayHeight: Math.pow(2, 32)
+ })},
'invalid display height');
}, 'Test invalid planar constructed VideoFrames');