Skip to content

Commit

Permalink
Require Node.js v12 or higher
Browse files Browse the repository at this point in the history
Also stop testing Node.js v15 (since it will EOL soon) and start testing Node.js v16.
  • Loading branch information
domenic committed May 23, 2021
1 parent 74a8d1e commit 4a388c7
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
@@ -1,6 +1,6 @@
### Basic info:

- **Node.js version:** <!-- only v10 and above are supported -->
- **Node.js version:** <!-- only v12 and above are supported -->
- **jsdom version:** <!-- only v16 and above are supported -->

### Minimal reproduction case
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/jsdom-ci.yml
Expand Up @@ -22,9 +22,7 @@ jobs:
- name: Run linter
uses: actions/setup-node@v2
with:
node-version: '15'
- name: Setup HOSTS file for Web Platform Test server
run: ./test/web-platform-tests/tests/wpt make-hosts-file | sudo tee -a /etc/hosts
node-version: '16'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Run syntax rules check with ESLint
Expand All @@ -37,10 +35,10 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Run Canvas tests with Node 10
- name: Run Canvas tests with Node 16
uses: actions/setup-node@v2
with:
node-version: '10'
node-version: '16'
- name: Install required image manipulation packages with APT
run: sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
- name: Setup HOSTS file for Web Platform Test server
Expand All @@ -60,7 +58,7 @@ jobs:
- name: Run web browser tests
uses: actions/setup-node@v2
with:
node-version: '15'
node-version: '16'
- name: Setup HOSTS file for Web Platform Test server
run: ./test/web-platform-tests/tests/wpt make-hosts-file | sudo tee -a /etc/hosts
- name: Install dependencies
Expand All @@ -73,10 +71,9 @@ jobs:
fail-fast: false
matrix:
node-version:
- 10
- 12
- 14
- 15
- 16
architecture:
- x64
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -5,7 +5,7 @@

jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG [DOM](https://dom.spec.whatwg.org/) and [HTML](https://html.spec.whatwg.org/multipage/) Standards, for use with Node.js. In general, the goal of the project is to emulate enough of a subset of a web browser to be useful for testing and scraping real-world web applications.

The latest versions of jsdom require Node.js v10 or newer. (Versions of jsdom below v16 still work with previous Node.js versions, but are unsupported.)
The latest versions of jsdom require Node.js v12 or newer. (Versions of jsdom below v17 still work with previous Node.js versions, but are unsupported.)

## Basic usage

Expand Down
5 changes: 1 addition & 4 deletions lib/jsdom/browser/Window.js
Expand Up @@ -97,9 +97,6 @@ exports.createWindow = function (options) {

const jsGlobalEntriesToInstall = Object.entries(jsGlobals).filter(([name]) => name in global);

// TODO remove when we drop Node v10 support.
const anyNodeVersionQueueMicrotask = typeof queueMicrotask === "function" ? queueMicrotask : process.nextTick;

// https://html.spec.whatwg.org/#the-window-object
function setupWindow(windowInstance, { runScripts }) {
if (runScripts === "outside-only" || runScripts === "dangerously") {
Expand Down Expand Up @@ -545,7 +542,7 @@ function Window(options) {
this.queueMicrotask = function (callback) {
callback = webIDLConversions.Function(callback);

anyNodeVersionQueueMicrotask(() => {
queueMicrotask(() => {
try {
callback();
} catch (e) {
Expand Down
7 changes: 1 addition & 6 deletions test/api/options-run-scripts.js
Expand Up @@ -6,10 +6,6 @@ const { delay } = require("../util.js");
const { JSDOM, VirtualConsole } = require("../..");
const jsGlobals = Object.keys(require("../../lib/jsdom/browser/js-globals.json"));

// Node 10 has a bug with the vm module that causes some global-related tests to fail.
const hasNode10 = process.versions.node && Number(process.versions.node.split(".")[0]) === 10;


describe("API: runScripts constructor option", () => {
describe("<script>s and eval()", () => {
it("should not execute any scripts by default", () => {
Expand Down Expand Up @@ -124,8 +120,7 @@ describe("API: runScripts constructor option", () => {
});
});

const jsSpecGlobalsDescribe = hasNode10 ? describe.skip : describe;
jsSpecGlobalsDescribe("JS spec globals", () => {
describe("JS spec globals", () => {
it("should include aliased globals by default", () => {
// Sanity check that our global-generation process hasn't broken.
assert.include(jsGlobals, "TypeError");
Expand Down
12 changes: 0 additions & 12 deletions test/web-platform-tests/to-run.yaml
Expand Up @@ -264,7 +264,6 @@ header-values-normalize.any.html: [fail, fetch is not defined]
header-values.any.html: [fail, fetch is not defined]
headers-basic.any.html: [fail, iterator prototype is wrong]
headers-no-cors.any.html: [fail, Request is not defined]
headers-record.any.html: [needs-node12, V8 bug fixed in Node 12 onward]

---

Expand Down Expand Up @@ -470,12 +469,6 @@ window-open-invalid-url.html: [fail, Unknown]
window-open-noopener.html**: [fail-slow, Unknown]
window-open-noreferrer.html: [fail, Depends on BroadcastChannel]
window-properties.https.html:
"Value Property: NaN": [needs-node12, Unknown]
"Value Property: Infinity": [needs-node12, Unknown]
"Value Property: undefined": [needs-node12, Unknown]
"EventTarget method: addEventListener": [needs-node12, Unknown]
"EventTarget method: removeEventListener": [needs-node12, Unknown]
"EventTarget method: dispatchEvent": [needs-node12, Unknown]
"Window method: createImageBitmap": [fail, Not implemented]
"Window method: matchMedia": [fail, Not implemented]
"Window readonly attribute: applicationCache": [fail, Not implemented]
Expand Down Expand Up @@ -943,8 +936,6 @@ css-module/**: [fail-slow, CSS modules and Worker not implemented]
data-url.html: [timeout, Unknown]
emptyish-script-elements.html: [fail, Unknown]
evaluation-order-**worker.html: [fail, workers not implemented]
evaluation-order-1-nothrow.html: [needs-node12, Test uses globalThis]
evaluation-order-1.html: [needs-node12, Test uses globalThis]
execution-timing/005.html: [fail, Unknown]
execution-timing/006.html: [fail, Unknown]
execution-timing/009.html: [fail, Unknown]
Expand Down Expand Up @@ -1135,7 +1126,6 @@ DIR: html/webappapis/dynamic-markup-insertion/document-writeln

DIR: html/webappapis/microtask-queuing

queue-microtask.any.html: [needs-node12, Node v10 doesn't have queueMicrotask so we use the nextTick queue there which has the wrong ordering semantics with regard to promises]
queue-microtask.window.html: [fail-slow, Unknown interaction with Mutation Observers]

---
Expand Down Expand Up @@ -1269,11 +1259,9 @@ unload-a-document/*: [timeout, Requires window.open]

DIR: webstorage

event_no_duplicates.html: [needs-node11, Earlier Node.js timers did not match browser behaviour, https://github.com/nodejs/node/pull/22842]
storage_local_window_open.window.html: [timeout, Depends on window.open()]
storage_session_window_noopener.window.html: [fail, Depends on BroadcastChannel]
storage_session_window_open.window.html: [timeout, Depends on window.open()]
storage_string_conversion.window.html: [needs-node10, function.toString() does not use correct formatting in earlier versions, https://github.com/nodejs/node/issues/20459]
symbol-props.window.html: [fail, Unknown]

---
Expand Down
9 changes: 1 addition & 8 deletions test/web-platform-tests/utils.js
@@ -1,10 +1,6 @@
"use strict";
const { Canvas } = require("../../lib/jsdom/utils.js");

const nodeMajor = Number(process.versions.node.split(".", 1)[0]);
const hasNode10 = nodeMajor >= 10;
const hasNode11 = nodeMajor >= 11;
const hasNode12 = nodeMajor >= 12;
const hasCanvas = Boolean(Canvas);

exports.resolveReason = reason => {
Expand All @@ -14,10 +10,7 @@ exports.resolveReason = reason => {
}

if (reason === "fail" ||
(reason === "fail-with-canvas" && hasCanvas) ||
(reason === "needs-node10" && !hasNode10) ||
(reason === "needs-node11" && !hasNode11) ||
(reason === "needs-node12" && !hasNode12)) {
(reason === "fail-with-canvas" && hasCanvas)) {
return "expect-fail";
}

Expand Down

0 comments on commit 4a388c7

Please sign in to comment.