diff options
Diffstat (limited to 'op_crates/web')
-rw-r--r-- | op_crates/web/01_event.js | 8 | ||||
-rw-r--r-- | op_crates/web/event_test.js | 11 |
2 files changed, 16 insertions, 3 deletions
diff --git a/op_crates/web/01_event.js b/op_crates/web/01_event.js index 8a4e79059..ed76a4281 100644 --- a/op_crates/web/01_event.js +++ b/op_crates/web/01_event.js @@ -98,9 +98,11 @@ return "relatedTarget" in event; } - function isTrusted() { - return eventData.get(this).isTrusted; - } + const isTrusted = Object.getOwnPropertyDescriptor({ + get isTrusted() { + return eventData.get(this).isTrusted; + }, + }, "isTrusted").get; class Event { #canceledFlag = false; diff --git a/op_crates/web/event_test.js b/op_crates/web/event_test.js index f533d78fb..8107f3bca 100644 --- a/op_crates/web/event_test.js +++ b/op_crates/web/event_test.js @@ -96,6 +96,16 @@ function eventIsTrusted() { assert(desc1.get === desc2.get); } +function eventIsTrustedGetterName() { + const { get } = Object.getOwnPropertyDescriptor(new Event("x"), "isTrusted"); + assert(get.name === "get isTrusted"); + try { + Reflect.construct(get); + throw new Error("Should not have reached here"); + } catch (e) { + assert(e.message.includes("not a constructor")); + } +} function main() { eventInitializedWithType(); eventInitializedWithTypeAndDict(); @@ -105,6 +115,7 @@ function main() { eventPreventDefaultSuccess(); eventInitializedWithNonStringType(); eventIsTrusted(); + eventIsTrustedGetterName(); } main(); |