Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upThrow errors for invalid values in panner node constructor #21555
Conversation
highfive
commented
Aug 31, 2018
|
Heads up! This PR modifies the following files:
|
highfive
commented
Aug 31, 2018
|
Thanks! It seems that https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html is not checking these constraints. So it'd be nice to add the additional checks. |
| @@ -60,6 +60,15 @@ impl PannerNode { | |||
| if count > 2 { | |||
| return Err(Error::NotSupported) | |||
| } | |||
| if options.maxDistance < 0. { | |||
| return Err(Error::NotSupported) | |||
This comment has been minimized.
This comment has been minimized.
ferjm
Aug 31, 2018
Member
Should this be a RangeError? https://webaudio.github.io/web-audio-api/#dom-pannernode-maxdistance
| if options.rolloffFactor < 0. { | ||
| return Err(Error::Range("rolloffFactor should be positive".into())) | ||
| } | ||
| if options.coneOuterGain < 0. || options.coneOuterGain > 360. { |
This comment has been minimized.
This comment has been minimized.
ferjm
Aug 31, 2018
Member
And this one InvalidStateError? https://webaudio.github.io/web-audio-api/#dom-pannernode-coneoutergain
00468be
to
130ed80
|
Opened new PR for upstreamable changes. Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#80. |
130ed80
to
7d113c3
|
Transplanted upstreamable changes to existing PR. Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#80. |
7d113c3
to
a8eb8fc
|
Transplanted upstreamable changes to existing PR. Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#80. |
|
The WPT manifest needs updating. |
a8eb8fc
to
216544c
|
Transplanted upstreamable changes to existing PR. Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#80. |
216544c
to
e1131b4
|
Transplanted upstreamable changes to existing PR. Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#80. |
|
Added tests. r? @ferjm |
|
r=me. Thanks! |
| if *options.maxDistance <= 0. { | ||
| return Err(Error::Range("maxDistance should be positive".into())) | ||
| } | ||
| if *options.refDistance < 0. { |
This comment has been minimized.
This comment has been minimized.
ferjm
Aug 31, 2018
Member
Perhaps <= 0.. The spec says to throw when it is set to a non-positive value. Same as with maxDistance
| @@ -230,19 +243,23 @@ impl PannerNodeMethods for PannerNode { | |||
| Finite::wrap(self.ref_distance.get()) | |||
| } | |||
| // https://webaudio.github.io/web-audio-api/#dom-pannernode-refdistance | |||
| fn SetRefDistance(&self, val: Finite<f64>) { | |||
| fn SetRefDistance(&self, val: Finite<f64>) -> Fallible<()> { | |||
| if *val < 0. { | |||
This comment has been minimized.
This comment has been minimized.
| @@ -289,7 +306,7 @@ impl PannerNodeMethods for PannerNode { | |||
| } | |||
| // https://webaudio.github.io/web-audio-api/#dom-pannernode-coneoutergain | |||
| fn SetConeOuterGain(&self, val: Finite<f64>) -> Fallible<()> { | |||
| if *val < 0. || *val > 360. { | |||
This comment has been minimized.
This comment has been minimized.
|
So the spec says that both need to be non-positive, but the test indicates that zero is allowed for refDistance (but not maxDistance), and this agrees with Chrome. Firefox doesn't seem to throw errors at all? I'll land this as is until the spec folks can determine what it should be @bors-servo r=ferjm |
|
|
Throw errors for invalid values in panner node constructor This was an oversight in the spec and is being fixed WebAudio/web-audio-api#1728 r? @ferjm <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21555) <!-- Reviewable:end -->
|
|
|
Error syncing changes upstream. Logs saved in error-snapshot-1535735434057. |
|
Spec editor confirmed that a zero value is okay for ref distance, I'll open a PR later. |
Upstreamed from servo/servo#21555 [ci skip]
Manishearth commentedAug 31, 2018
•
edited by SimonSapin
This was an oversight in the spec and is being fixed
WebAudio/web-audio-api#1728
r? @ferjm
This change is