From c33b50ec251b4b2f5c2c47505df2980162efaa57 Mon Sep 17 00:00:00 2001 From: Raymond Toy Date: Fri, 7 Sep 2018 11:00:44 +0000 Subject: [PATCH] Bug 1488586 [wpt PR 12834] - Throw errors for invalid rolloffFactor and coneOuterGain, a=testonly Automatic update from web-platform-testsThrow errors for invalid rolloffFactor and coneOuterGain The WebAudio spec says we must throw errors for a negative rolloffFactor and for a coneOuterGain outside the interval [0, 1]. Make it so. Also add some additional tests to ctor-panner.html to verify that a rolloffFactor of 0 or 100 do not throw errors and that a coneOuterGain of 0 or 1 do not throw errors. Remove invalid tests from panner-rolloff-clamping.html because negative rolloffFactor now throws an error. Finally remove text expectation for ctor-panner.html test, which passes now. Bug: 879845 Test: the-pannernode-interface/ctor-panner.html, the-pannernode-interface/panner-rolloff-clamping.html Change-Id: Ie90e9fe13e82fd3cc955060dc9e77266ef4ff591 Reviewed-on: https://chromium-review.googlesource.com/1205099 Commit-Queue: Raymond Toy Reviewed-by: Hongchan Choi Reviewed-by: Kent Tamura Cr-Commit-Position: refs/heads/master@{#589045} -- wpt-commits: 7b9c733915fab4723a453e03d692f9c396a8c6fb wpt-pr: 12834 --- testing/web-platform/meta/MANIFEST.json | 4 +- .../the-pannernode-interface/ctor-panner.html | 43 ++++++++++++++++- .../panner-rolloff-clamping.html | 48 +++++-------------- 3 files changed, 56 insertions(+), 39 deletions(-) diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index afe626159505..ab5644b9e89e 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -656136,7 +656136,7 @@ "support" ], "webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html": [ - "cdad5977c70251edc0e8ecfac68c42cc4d2c7e41", + "d330c9c3de4482ee70c036e0ab7ff8feb1fd5a36", "testharness" ], "webaudio/the-audio-api/the-pannernode-interface/distance-exponential.html": [ @@ -656176,7 +656176,7 @@ "testharness" ], "webaudio/the-audio-api/the-pannernode-interface/panner-rolloff-clamping.html": [ - "e1519f8c3027b3e38004e54ba6088ae819bedff1", + "387f87301092ebd725ed240cc70f0df7ec69a5ab", "testharness" ], "webaudio/the-audio-api/the-pannernode-interface/pannernode-basic.html": [ diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html b/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html index cdad5977c702..d330c9c3de44 100644 --- a/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html +++ b/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html @@ -218,6 +218,16 @@ }, 'new PannerNode(c, ' + JSON.stringify(options) + ')') .throw(RangeError); + options = {rolloffFactor: 0}; + should( + () => { + node = new PannerNode(context, options); + }, + 'node8 = new PannerNode(c, ' + JSON.stringify(options) + ')') + .notThrow(); + should(node.rolloffFactor, 'node8.rolloffFactor') + .beEqualTo(options.rolloffFactor); + options = {rolloffFactor: 0.5}; should( () => { @@ -228,6 +238,16 @@ should(node.rolloffFactor, 'node8.rolloffFactor') .beEqualTo(options.rolloffFactor); + options = {rolloffFactor: 100}; + should( + () => { + node = new PannerNode(context, options); + }, + 'node8 = new PannerNode(c, ' + JSON.stringify(options) + ')') + .notThrow(); + should(node.rolloffFactor, 'node8.rolloffFactor') + .beEqualTo(options.rolloffFactor); + // Test coneOuterGain options = {coneOuterGain: -1}; should( @@ -235,14 +255,23 @@ node = new PannerNode(context, options); }, 'new PannerNode(c, ' + JSON.stringify(options) + ')') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); options = {coneOuterGain: 1.1}; should( () => { node = new PannerNode(context, options); }, 'new PannerNode(c, ' + JSON.stringify(options) + ')') - .throw('InvalidStateError'); + .throw(DOMException, 'InvalidStateError'); + options = {coneOuterGain: 0.0}; + should( + () => { + node = new PannerNode(context, options); + }, + 'node9 = new PannerNode(c, ' + JSON.stringify(options) + ')') + .notThrow(); + should(node.coneOuterGain, 'node9.coneOuterGain') + .beEqualTo(options.coneOuterGain); options = {coneOuterGain: 0.5}; should( () => { @@ -253,6 +282,16 @@ should(node.coneOuterGain, 'node9.coneOuterGain') .beEqualTo(options.coneOuterGain); + options = {coneOuterGain: 1.0}; + should( + () => { + node = new PannerNode(context, options); + }, + 'node9 = new PannerNode(c, ' + JSON.stringify(options) + ')') + .notThrow(); + should(node.coneOuterGain, 'node9.coneOuterGain') + .beEqualTo(options.coneOuterGain); + task.done(); }); diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/panner-rolloff-clamping.html b/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/panner-rolloff-clamping.html index e1519f8c3027..387f87301092 100644 --- a/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/panner-rolloff-clamping.html +++ b/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/panner-rolloff-clamping.html @@ -17,41 +17,19 @@ let audit = Audit.createTaskRunner(); - audit.define('linear-clamp-low', (task, should) => { - runTest(should, { - distanceModel: 'linear', - // Fairly arbitrary value outside the nominal range - rolloffFactor: -1, - clampedRolloff: 0 - }).then(() => task.done()); - }); - - audit.define('linear-clamp-high', (task, should) => { - runTest(should, { - distanceModel: 'linear', - // Fairly arbitrary value outside the nominal range - rolloffFactor: 2, - clampedRolloff: 1 - }).then(() => task.done()); - }); - - audit.define('inverse-clamp', (task, should) => { - runTest(should, { - distanceModel: 'inverse', - // Fairly arbitrary value outside the nominal range - rolloffFactor: -1, - clampedRolloff: 0 - }).then(() => task.done()); - }); - - audit.define('exponential-clamp', (task, should) => { - runTest(should, { - distanceModel: 'exponential', - // Fairly arbitrary value outside the nominal range - rolloffFactor: -2, - clampedRolloff: 0 - }).then(() => task.done()); - }); + audit.define( + { + label: 'linear-clamp-high', + description: 'rolloffFactor clamping for linear distance model' + }, + (task, should) => { + runTest(should, { + distanceModel: 'linear', + // Fairly arbitrary value outside the nominal range + rolloffFactor: 2, + clampedRolloff: 1 + }).then(() => task.done()); + }); // Test clamping of the rolloffFactor. The test is done by comparing the // output of a panner with the rolloffFactor set outside the nominal range