diff options
Diffstat (limited to 'tests/wpt/web-platform-tests/css/css-properties-values-api/resources/utils.js')
-rw-r--r-- | tests/wpt/web-platform-tests/css/css-properties-values-api/resources/utils.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/css/css-properties-values-api/resources/utils.js b/tests/wpt/web-platform-tests/css/css-properties-values-api/resources/utils.js index c4dc3fd5a8d..bef59560f68 100644 --- a/tests/wpt/web-platform-tests/css/css-properties-values-api/resources/utils.js +++ b/tests/wpt/web-platform-tests/css/css-properties-values-api/resources/utils.js @@ -50,6 +50,14 @@ function any_initial_value(syntax) { // generated. If a single string is used as the argument, it is assumed to be // the syntax. function generate_property(reg) { + // Verify that only valid keys are specified. This prevents the caller from + // accidentally supplying 'inherited' instead of 'inherits', for example. + if (typeof(reg) === 'object') { + const permitted = new Set(['name', 'syntax', 'initialValue', 'inherits']); + if (!Object.keys(reg).every(k => permitted.has(k))) + throw new Error('generate_property: invalid parameter'); + } + let syntax = typeof(reg) === 'string' ? reg : reg.syntax; let initial = typeof(reg.initialValue) === 'undefined' ? any_initial_value(syntax) : reg.initialValue; |