(object, object_name, attributes)
| 23 | } |
| 24 | |
| 25 | function test_attributes(object, object_name, attributes) { |
| 26 | for (const [name, mutable] of attributes) { |
| 27 | test(() => { |
| 28 | const propdesc = Object.getOwnPropertyDescriptor(object, name); |
| 29 | assert_equals(typeof propdesc, "object"); |
| 30 | assert_true(propdesc.enumerable, "enumerable"); |
| 31 | assert_true(propdesc.configurable, "configurable"); |
| 32 | }, `${object_name}.${name}`); |
| 33 | |
| 34 | test(() => { |
| 35 | const propdesc = Object.getOwnPropertyDescriptor(object, name); |
| 36 | assert_equals(typeof propdesc, "object"); |
| 37 | assert_equals(typeof propdesc.get, "function"); |
| 38 | assert_function_name(propdesc.get, "get " + name, `getter for "${name}"`); |
| 39 | assert_function_length(propdesc.get, 0, `getter for "${name}"`); |
| 40 | }, `${object_name}.${name}: getter`); |
| 41 | |
| 42 | test(() => { |
| 43 | const propdesc = Object.getOwnPropertyDescriptor(object, name); |
| 44 | assert_equals(typeof propdesc, "object"); |
| 45 | if (mutable) { |
| 46 | assert_equals(typeof propdesc.set, "function"); |
| 47 | assert_function_name(propdesc.set, "set " + name, `setter for "${name}"`); |
| 48 | assert_function_length(propdesc.set, 1, `setter for "${name}"`); |
| 49 | } else { |
| 50 | assert_equals(typeof propdesc.set, "undefined"); |
| 51 | } |
| 52 | }, `${object_name}.${name}: setter`); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | test(() => { |
| 57 | const propdesc = Object.getOwnPropertyDescriptor(this, "WebAssembly"); |
no test coverage detected