Bug 1565464 - Add a WPT to check that having two parameters with the same name in parameterDescriptors throws. r=karlt

Differential Revision: https://phabricator.services.mozilla.com/D66383

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Paul Adenot 2020-03-27 10:51:55 +00:00
Родитель ca03abade2
Коммит 8810f387d8
1 изменённых файлов: 43 добавлений и 9 удалений

Просмотреть файл

@ -79,15 +79,15 @@
// Test a processor that has a get parameterDescriptors, but it returns
// something that is not iterable.
try {
registerProcessor("invalid",
class InvalidParamProcessor extends AudioWorkletProcessor {
static get parameterDescriptors() {
return 4;
}
constructor() { super(); }
process() { }
});
throw "This should not have been reached.";
registerProcessor("invalid",
class InvalidParamProcessor extends AudioWorkletProcessor {
static get parameterDescriptors() {
return 4;
}
constructor() { super(); }
process() { }
});
throw "This should not have been reached.";
} catch (e) {
// unclear how to signal success here, but we can signal failure in the
// developer console
@ -95,6 +95,32 @@
throw "This should be TypeError";
}
}
// Test a processor that has a get parameterDescriptors, with a duplicate
// param name something that is not iterable.
try {
registerProcessor("duplicate-param-name",
class DuplicateParamProcessor extends AudioWorkletProcessor {
static get parameterDescriptors() {
var p = {
name: "a",
defaultValue: 1,
minValue: 0,
maxValue: 1,
automationRate: "k-rate",
};
return [p,p];
}
constructor() { super(); }
process() { }
});
throw "This should not have been reached.";
} catch (e) {
// unclear how to signal success here, but we can signal failure in the
// developer console
if (e.name != "NotSupportedError") {
throw "This should be NotSupportedError";
}
}
// Test a processor that has a no get parameterDescriptors.
try {
registerProcessor("no-params",
@ -163,6 +189,14 @@
new AudioWorkletNode(ac, "no-params");
}, `Attempting to create an AudioWorkletNode from a processor
that does not have a parameterDescriptors getter should work`);
})
.then(function() {
test(function() {
assert_throws_dom("InvalidStateError", function() {
new AudioWorkletNode(ac, "duplicate-param-name");
});
}, `Attempting to create an AudioWorkletNode with two parameter
descriptor with the same name should not work`);
}).then(function() {
done();
});