Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw errors for invalid values in panner node constructor #21555

Merged
merged 2 commits into from Aug 31, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Add tests for options bounds in PannerNode's constructor

  • Loading branch information
Manishearth committed Aug 31, 2018
commit e1131b474c7d162ec791c10f0bc21ecca56100d7
"support"
],
"webaudio/the-audio-api/the-pannernode-interface/ctor-panner.html": [
"5475a6210b724ab2d6a0cefedee9c5432953c61f",
"95e914a75f6784a76af79fcfce2e372ddb865814",
"testharness"
],
"webaudio/the-audio-api/the-pannernode-interface/distance-exponential.html": [
@@ -192,6 +192,67 @@
'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw(TypeError);

// Test maxDistance
options = {maxDistance: -1};
should(
() => {
node = new PannerNode(context, options);
},
'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw(RangeError);
options = {maxDistance: 100};
should(
() => {
node = new PannerNode(context, options);
},
'node7 = new PannerNode(c, ' + JSON.stringify(options) + ')')
.notThrow();
should(node.maxDistance, 'node7.maxDistance')
.beEqualTo(options.maxDistance);

// Test rolloffFactor
options = {rolloffFactor: -1};
should(
() => {
node = new PannerNode(context, options);
},
'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw(RangeError);
options = {rolloffFactor: 0.5};
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(
() => {
node = new PannerNode(context, options);
},
'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw('InvalidStateError');
options = {coneOuterGain: 1.1};
should(
() => {
node = new PannerNode(context, options);
},
'new PannerNode(c, ' + JSON.stringify(options) + ')')
.throw('InvalidStateError');
options = {coneOuterGain: 0.5};
should(
() => {
node = new PannerNode(context, options);
},
'node9 = new PannerNode(c, ' + JSON.stringify(options) + ')')
.notThrow();
should(node.coneOuterGain, 'node9.coneOuterGain')
.beEqualTo(options.coneOuterGain);

task.done();
});

@@ -218,7 +279,7 @@
rolloffFactor: 3 * Math.PI,
coneInnerAngle: 4 * Math.PI,
coneOuterAngle: 5 * Math.PI,
coneOuterGain: 6 * Math.PI
coneOuterGain: 0.1 * Math.PI
};

should(
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.