Skip to content

Commit

Permalink
Add a temporary workaround for a Node 18 bug
Browse files Browse the repository at this point in the history
Also fix the overwritten-customElements-global.html test some of which fails in browsers and should not have been committed.
  • Loading branch information
domenic committed May 1, 2023
1 parent 7512ce9 commit 2167822
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 30 deletions.
5 changes: 4 additions & 1 deletion test/web-platform-tests/run-wpts.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const validReasons = new Set([
"fail-with-canvas",
"timeout",
"flaky",
"needs-canvas"
"needs-canvas",
// Node 18 has a bug in its vm module that causes certain property redefinition tests to fail.
// They start passing again on Node 19.
"fail-node18"
]);

const manifestFilename = path.resolve(__dirname, "wpt-manifest.json");
Expand Down
1 change: 1 addition & 0 deletions test/web-platform-tests/to-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ event-handler-all-global-events.html: [fail, Depends on fetch]
event-handler-attributes-body-window.html: [fail, Depends on fetch]
event-handler-attributes-frameset-window.html: [fail, Depends on fetch]
event-handler-attributes-windowless-body.html: [fail, Depends on fetch]
event-handler-handleEvent-ignored.html: [fail-node18]
event-handler-processing-algorithm-error/document-synthetic-errorevent.html: [fail, ErrorEvent.error can't be set to undefined]
event-handler-processing-algorithm-error/script-element.html: [timeout, Unknown]
event-handler-processing-algorithm-error/synthetic-errorevent-click.html: [fail, Needs Worker implementation]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,6 @@
<body>
<script>
"use strict";

test(() => {
class SomeElement1 extends HTMLElement {}
customElements.define("some-element-1", SomeElement1);

const savedCustomElements = Object.getOwnPropertyDescriptor(window, "customElements");
window.customElements = {};

const element = document.createElement("some-element-1");
assert_true(element instanceof SomeElement1);

Object.defineProperty(window, "customElements", savedCustomElements);
}, "Custom elements can still be created after `window.customElements` is overwritten.");

test(() => {
class SomeElement2 extends HTMLElement {}
customElements.define("some-element-2", SomeElement2);

const savedCustomElements = Object.getOwnPropertyDescriptor(window, "customElements");
window.customElements = {};

const element = new SomeElement2();
assert_true(element instanceof SomeElement2);

Object.defineProperty(window, "customElements", savedCustomElements);
}, "Custom elements can still be constructed after `window.customElements` is overwritten.");

test(() => {
class SomeElement3 extends HTMLElement {}
customElements.define("some-element-3", SomeElement3);
Expand Down
13 changes: 11 additions & 2 deletions test/web-platform-tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ const { Canvas } = require("../../lib/jsdom/utils.js");

const hasCanvas = Boolean(Canvas);

const nodeMajorVersion = process.versions.node.split(".")[0];

exports.resolveReason = reason => {
if (["fail-slow", "timeout", "flaky"].includes(reason) ||
(["fail-with-canvas", "needs-canvas"].includes(reason) && !hasCanvas)) {
if (["fail-slow", "timeout", "flaky"].includes(reason)) {
return "skip";
}

if (["fail-with-canvas", "needs-canvas"].includes(reason) && !hasCanvas) {
return "skip";
}

if (reason === "fail-node18" && nodeMajorVersion === "18") {
return "skip";
}

Expand Down

0 comments on commit 2167822

Please sign in to comment.