summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/Document-createEvent.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/dom/nodes/Document-createEvent.https.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/Document-createEvent.https.html')
-rw-r--r--testing/web-platform/tests/dom/nodes/Document-createEvent.https.html170
1 files changed, 170 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/Document-createEvent.https.html b/testing/web-platform/tests/dom/nodes/Document-createEvent.https.html
new file mode 100644
index 0000000000..4781d54e8e
--- /dev/null
+++ b/testing/web-platform/tests/dom/nodes/Document-createEvent.https.html
@@ -0,0 +1,170 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Document.createEvent</title>
+<link rel=help href="https://dom.spec.whatwg.org/#dom-document-createevent">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="Document-createEvent.js"></script>
+<div id="log"></div>
+<script>
+function supportsTouchEvents(isTouchEvent) {
+ if (isTouchEvent) {
+ assert_implements_optional('ontouchstart' in document, "'expose legacy touch event APIs'");
+ }
+}
+function testAlias(arg, iface, isTouchEvent) {
+ var ev;
+ test(function() {
+ supportsTouchEvents(isTouchEvent);
+ ev = document.createEvent(arg);
+ assert_equals(Object.getPrototypeOf(ev), window[iface].prototype);
+ }, arg + " should be an alias for " + iface + ".");
+ test(function() {
+ supportsTouchEvents(isTouchEvent);
+ assert_equals(ev.type, "",
+ "type should be initialized to the empty string");
+ assert_equals(ev.target, null,
+ "target should be initialized to null");
+ assert_equals(ev.currentTarget, null,
+ "currentTarget should be initialized to null");
+ assert_equals(ev.eventPhase, 0,
+ "eventPhase should be initialized to NONE (0)");
+ assert_equals(ev.bubbles, false,
+ "bubbles should be initialized to false");
+ assert_equals(ev.cancelable, false,
+ "cancelable should be initialized to false");
+ assert_equals(ev.defaultPrevented, false,
+ "defaultPrevented should be initialized to false");
+ assert_equals(ev.isTrusted, false,
+ "isTrusted should be initialized to false");
+ }, "createEvent('" + arg + "') should be initialized correctly.");
+}
+aliases.TouchEvent = 'TouchEvent';
+for (var alias in aliases) {
+ var isTouchEvent = alias === 'TouchEvent';
+ var iface = aliases[alias];
+ testAlias(alias, iface, isTouchEvent);
+ testAlias(alias.toLowerCase(), iface, isTouchEvent);
+ testAlias(alias.toUpperCase(), iface, isTouchEvent);
+
+ if (alias[alias.length - 1] != "s") {
+ var plural = alias + "s";
+ if (!(plural in aliases)) {
+ test(function () {
+ assert_throws_dom("NOT_SUPPORTED_ERR", function () {
+ var evt = document.createEvent(plural);
+ });
+ }, 'Should throw NOT_SUPPORTED_ERR for pluralized legacy event interface "' + plural + '"');
+ }
+ }
+}
+
+test(function() {
+ assert_throws_dom("NOT_SUPPORTED_ERR", function() {
+ var evt = document.createEvent("foo");
+ });
+ assert_throws_dom("NOT_SUPPORTED_ERR", function() {
+ // 'LATIN CAPITAL LETTER I WITH DOT ABOVE' (U+0130)
+ var evt = document.createEvent("U\u0130Event");
+ });
+ assert_throws_dom("NOT_SUPPORTED_ERR", function() {
+ // 'LATIN SMALL LETTER DOTLESS I' (U+0131)
+ var evt = document.createEvent("U\u0131Event");
+ });
+}, "Should throw NOT_SUPPORTED_ERR for unrecognized arguments");
+
+/*
+ * The following are event interfaces which do actually exist, but must still
+ * throw since they're absent from the table in the spec for
+ * document.createEvent(). This list is not exhaustive, but includes all
+ * interfaces that it is known some UA does or did not throw for.
+ */
+var someNonCreateableEvents = [
+ "AnimationEvent",
+ "AnimationPlaybackEvent",
+ "AnimationPlayerEvent",
+ "ApplicationCacheErrorEvent",
+ "AudioProcessingEvent",
+ "AutocompleteErrorEvent",
+ "BeforeInstallPromptEvent",
+ "BlobEvent",
+ "ClipboardEvent",
+ "CloseEvent",
+ "CommandEvent",
+ "DataContainerEvent",
+ "ErrorEvent",
+ "ExtendableEvent",
+ "ExtendableMessageEvent",
+ "FetchEvent",
+ "FontFaceSetLoadEvent",
+ "GamepadEvent",
+ "GeofencingEvent",
+ "IDBVersionChangeEvent",
+ "InstallEvent",
+ "KeyEvent",
+ "MIDIConnectionEvent",
+ "MIDIMessageEvent",
+ "MediaEncryptedEvent",
+ "MediaKeyEvent",
+ "MediaKeyMessageEvent",
+ "MediaQueryListEvent",
+ "MediaStreamEvent",
+ "MediaStreamTrackEvent",
+ "MouseScrollEvent",
+ "MutationEvent",
+ "NotificationEvent",
+ "NotifyPaintEvent",
+ "OfflineAudioCompletionEvent",
+ "OrientationEvent",
+ "PageTransition", // Yes, with no "Event"
+ "PageTransitionEvent",
+ "PointerEvent",
+ "PopStateEvent",
+ "PopUpEvent",
+ "PresentationConnectionAvailableEvent",
+ "PresentationConnectionCloseEvent",
+ "ProgressEvent",
+ "PromiseRejectionEvent",
+ "PushEvent",
+ "RTCDTMFToneChangeEvent",
+ "RTCDataChannelEvent",
+ "RTCIceCandidateEvent",
+ "RelatedEvent",
+ "ResourceProgressEvent",
+ "SVGEvent",
+ "SVGZoomEvent",
+ "ScrollAreaEvent",
+ "SecurityPolicyViolationEvent",
+ "ServicePortConnectEvent",
+ "ServiceWorkerMessageEvent",
+ "SimpleGestureEvent",
+ "SpeechRecognitionError",
+ "SpeechRecognitionEvent",
+ "SpeechSynthesisEvent",
+ "SyncEvent",
+ "TimeEvent",
+ "TrackEvent",
+ "TransitionEvent",
+ "WebGLContextEvent",
+ "WebKitAnimationEvent",
+ "WebKitTransitionEvent",
+ "WheelEvent",
+ "XULCommandEvent",
+];
+someNonCreateableEvents.forEach(function (eventInterface) {
+ test(function () {
+ assert_throws_dom("NOT_SUPPORTED_ERR", function () {
+ var evt = document.createEvent(eventInterface);
+ });
+ }, 'Should throw NOT_SUPPORTED_ERR for non-legacy event interface "' + eventInterface + '"');
+
+ // SVGEvents is allowed, other plurals are not
+ if (eventInterface !== "SVGEvent") {
+ test(function () {
+ assert_throws_dom("NOT_SUPPORTED_ERR", function () {
+ var evt = document.createEvent(eventInterface + "s");
+ });
+ }, 'Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "' + eventInterface + 's"');
+ }
+});
+</script>