Repository: denoland/deno
Pull request: fix(ext/web): fix property configuration of event phase fields

The properties like `Event.NONE` should have property configuration of `writable: false, enumerable: true, configurable: false`, but they currently have `enumerable: false, configurable: true, getter, setter: undefined`.

This PR fixes it. This enables `parallel/test-event-target.js` node compat test case.

Changed files:
filename: ext/web/02_event.js
patch: @@ -308,22 +308,6 @@ class Event {
     return Event.BUBBLING_PHASE;
   }
 
-  static get NONE() {
-    return 0;
-  }
-
-  static get CAPTURING_PHASE() {
-    return 1;
-  }
-
-  static get AT_TARGET() {
-    return 2;
-  }
-
-  static get BUBBLING_PHASE() {
-    return 3;
-  }
-
   get eventPhase() {
     return this[_attributes].eventPhase;
   }
@@ -386,6 +370,38 @@ class Event {
   }
 }
 
+ObjectDefineProperty(Event, "NONE", {
+  __proto__: null,
+  value: 0,
+  writable: false,
+  enumerable: true,
+  configurable: false,
+});
+
+ObjectDefineProperty(Event, "CAPTURING_PHASE", {
+  __proto__: null,
+  value: 1,
+  writable: false,
+  enumerable: true,
+  configurable: false,
+});
+
+ObjectDefineProperty(Event, "AT_TARGET", {
+  __proto__: null,
+  value: 2,
+  writable: false,
+  enumerable: true,
+  configurable: false,
+});
+
+ObjectDefineProperty(Event, "BUBBLING_PHASE", {
+  __proto__: null,
+  value: 3,
+  writable: false,
+  enumerable: true,
+  configurable: false,
+});
+
 const EventPrototype = Event.prototype;
 
 // Not spec compliant. The spec defines it as [LegacyUnforgeable]

filename: tests/node_compat/config.jsonc
patch: @@ -534,6 +534,7 @@
       "test-event-emitter-special-event-names.js",
       "test-event-emitter-subclass.js",
       "test-event-emitter-symbols.js",
+      "test-event-target.js",
       "test-events-add-abort-listener.mjs",
       "test-events-getmaxlisteners.js",
       "test-events-list.js",

filename: tests/node_compat/runner/TODO.md
patch: @@ -1,7 +1,7 @@
 <!-- deno-fmt-ignore-file -->
 # Remaining Node Tests
 
-1196 tests out of 3993 have been ported from Node 23.9.0 (29.95% ported, 70.65% remaining).
+1200 tests out of 3993 have been ported from Node 23.9.0 (30.05% ported, 70.55% remaining).
 
 NOTE: This file should not be manually edited. Please edit `tests/node_compat/config.json` and run `deno task setup` in `tests/node_compat/runner` dir instead.
 
@@ -742,7 +742,6 @@ NOTE: This file should not be manually edited. Please edit `tests/node_compat/co
 - [parallel/test-esm-loader-hooks-inspect-brk.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-esm-loader-hooks-inspect-brk.js)
 - [parallel/test-esm-loader-hooks-inspect-wait.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-esm-loader-hooks-inspect-wait.js)
 - [parallel/test-eval-disallow-code-generation-from-strings.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-eval-disallow-code-generation-from-strings.js)
-- [parallel/test-event-target.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-event-target.js)
 - [parallel/test-eventemitter-asyncresource.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-eventemitter-asyncresource.js)
 - [parallel/test-events-customevent.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-events-customevent.js)
 - [parallel/test-events-listener-count-with-listener.js](https://github.com/nodejs/node/tree/v23.9.0/test/parallel/test-events-listener-count-with-listener.js)

filename: tests/node_compat/test/parallel/test-event-target.js
patch: @@ -0,0 +1,28 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 23.9.0
+// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
+
+'use strict';
+
+require('../common');
+const assert = require('assert');
+
+const eventPhases = {
+  'NONE': 0,
+  'CAPTURING_PHASE': 1,
+  'AT_TARGET': 2,
+  'BUBBLING_PHASE': 3
+};
+
+for (const [prop, value] of Object.entries(eventPhases)) {
+  // Check if the value of the property matches the expected value
+  assert.strictEqual(Event[prop], value, `Expected Event.${prop} to be ${value}, but got ${Event[prop]}`);
+
+  const desc = Object.getOwnPropertyDescriptor(Event, prop);
+  assert.strictEqual(desc.writable, false, `${prop} should not be writable`);
+  assert.strictEqual(desc.configurable, false, `${prop} should not be configurable`);
+  assert.strictEqual(desc.enumerable, true, `${prop} should be enumerable`);
+}

filename: tests/wpt/runner/expectation.json
patch: @@ -2572,14 +2572,6 @@
     "idlharness.window.html?exclude=Node": [
       "Event interface: attribute srcElement",
       "Event interface: operation composedPath()",
-      "Event interface: constant NONE on interface object",
-      "Event interface: constant NONE on interface prototype object",
-      "Event interface: constant CAPTURING_PHASE on interface object",
-      "Event interface: constant CAPTURING_PHASE on interface prototype object",
-      "Event interface: constant AT_TARGET on interface object",
-      "Event interface: constant AT_TARGET on interface prototype object",
-      "Event interface: constant BUBBLING_PHASE on interface object",
-      "Event interface: constant BUBBLING_PHASE on interface prototype object",
       "Event interface: operation stopPropagation()",
       "Event interface: attribute cancelBubble",
       "Event interface: operation stopImmediatePropagation()",
@@ -3225,14 +3217,6 @@
     "idlharness.any.worker.html": [
       "Event interface: attribute srcElement",
       "Event interface: operation composedPath()",
-      "Event interface: constant NONE on interface object",
-      "Event interface: constant NONE on interface prototype object",
-      "Event interface: constant CAPTURING_PHASE on interface object",
-      "Event interface: constant CAPTURING_PHASE on interface prototype object",
-      "Event interface: constant AT_TARGET on interface object",
-      "Event interface: constant AT_TARGET on interface prototype object",
-      "Event interface: constant BUBBLING_PHASE on interface object",
-      "Event interface: constant BUBBLING_PHASE on interface prototype object",
       "Event interface: operation stopPropagation()",
       "Event interface: attribute cancelBubble",
       "Event interface: operation stopImmediatePropagation()",