From 016db522017bfa268f26c4d4c0e9ae2050e74f80 Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Wed, 27 Apr 2022 09:20:26 +0200 Subject: [PATCH] DOM: Test document.createEvent('touchevent') See https://github.com/whatwg/dom/pull/1071 Co-authored-by: Anne van Kesteren --- .../Document-createEvent-touchevent.window.js | 12 ++++++++++++ dom/nodes/Document-createEvent.https.html | 17 +++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 dom/nodes/Document-createEvent-touchevent.window.js diff --git a/dom/nodes/Document-createEvent-touchevent.window.js b/dom/nodes/Document-createEvent-touchevent.window.js new file mode 100644 index 000000000000000..6523ac5a023fc46 --- /dev/null +++ b/dom/nodes/Document-createEvent-touchevent.window.js @@ -0,0 +1,12 @@ +for (const variant of ['TouchEvent', 'touchevent', 'TOUCHEVENT']) { + test(() => { + if (!('ontouchstart' in document)) { + assert_throws_dom("NOT_SUPPORTED_ERR", () => { + document.createEvent(variant); + }); + } else { + document.createEvent(variant); + // The interface and other details of the event is tested in Document-createEvent.https.html + } + }, `document.createEvent('${variant}') should throw if 'expose legacy touch event APIs' is false`); +} diff --git a/dom/nodes/Document-createEvent.https.html b/dom/nodes/Document-createEvent.https.html index 8e948a37e68630e..f80c1c3672225da 100644 --- a/dom/nodes/Document-createEvent.https.html +++ b/dom/nodes/Document-createEvent.https.html @@ -7,13 +7,20 @@