Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove unnecessary dependencies
Removes pn and array-equals, as well as the q dev dependency, as we can easily do without them.
  • Loading branch information
pmdartus authored and domenic committed Jan 12, 2020
1 parent 902b69e commit d240291
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 34 deletions.
13 changes: 5 additions & 8 deletions lib/api.js
@@ -1,6 +1,6 @@
"use strict";
const path = require("path");
const fs = require("pn/fs");
const fs = require("fs").promises;
const vm = require("vm");
const toughCookie = require("tough-cookie");
const sniffHTMLEncoding = require("html-encoding-sniffer");
Expand Down Expand Up @@ -144,14 +144,11 @@ class JSDOM {
});
}

static fromFile(filename, options = {}) {
return Promise.resolve().then(() => {
options = normalizeFromFileOptions(filename, options);
static async fromFile(filename, options = {}) {
options = normalizeFromFileOptions(filename, options);
const buffer = await fs.readFile(filename);

return fs.readFile(filename).then(buffer => {
return new JSDOM(buffer, options);
});
});
return new JSDOM(buffer, options);
}
}

Expand Down
17 changes: 4 additions & 13 deletions lib/jsdom/living/window/navigation.js
@@ -1,6 +1,5 @@
"use strict";
const whatwgURL = require("whatwg-url");
const arrayEqual = require("array-equal");
const notImplemented = require("../../browser/not-implemented.js");
const reportException = require("../helpers/runtime-script-errors.js");
const idlUtils = require("../generated/utils.js");
Expand Down Expand Up @@ -77,17 +76,9 @@ function navigateFetch(window) {
notImplemented("navigation (except hash changes)", window);
}

// https://url.spec.whatwg.org/#concept-url-equals
function urlEquals(a, b, flags) {
if (a.scheme !== b.scheme ||
a.username !== b.username ||
a.password !== b.password ||
a.host !== b.host ||
a.port !== b.port ||
!arrayEqual(a.path, b.path) ||
a.query !== b.query ||
// Omitted per spec: url.fragment !== this._url.fragment ||
a.cannotBeABaseURL !== b.cannotBeABaseURL) {
return false;
}
return flags.excludeFragments || a.fragment === b.fragment;
const serializedA = whatwgURL.serializeURL(a, flags.excludeFragments);
const serializedB = whatwgURL.serializeURL(b, flags.excludeFragments);
return serializedA === serializedB;
}
3 changes: 0 additions & 3 deletions package.json
Expand Up @@ -23,7 +23,6 @@
"abab": "^2.0.3",
"acorn": "^7.1.0",
"acorn-globals": "^4.3.2",
"array-equal": "^1.0.0",
"cssom": "^0.4.4",
"cssstyle": "^2.0.0",
"data-urls": "^2.0.0",
Expand All @@ -33,7 +32,6 @@
"html-encoding-sniffer": "^2.0.0",
"nwsapi": "^2.2.0",
"parse5": "5.1.1",
"pn": "^1.1.0",
"request": "^2.88.0",
"request-promise-native": "^1.0.8",
"saxes": "^4.0.2",
Expand Down Expand Up @@ -78,7 +76,6 @@
"mocha-sugar-free": "^1.4.0",
"optimist": "0.6.1",
"portfinder": "^1.0.25",
"q": "^1.5.1",
"rimraf": "^3.0.0",
"server-destroy": "^1.0.1",
"st": "^2.0.0",
Expand Down
13 changes: 8 additions & 5 deletions test/web-platform-tests/start-wpt-server.js
@@ -1,12 +1,13 @@
"use strict";
/* eslint-disable no-console, global-require */
const path = require("path");
const dns = require("dns");
const path = require("path");
const util = require("util");
const childProcess = require("child_process");
const q = require("q");
const { inBrowserContext } = require("../util.js");
const requestHead = require("request-promise-native").head;
const dnsLookup = q.denodeify(dns.lookup);
const { inBrowserContext } = require("../util.js");

const dnsLookup = util.promisify(dns.lookup);

const wptDir = path.resolve(__dirname, "tests");

Expand Down Expand Up @@ -72,6 +73,8 @@ function pollForServer(url) {
})
.catch(err => {
console.log(`WPT server at ${url} is not up yet (${err.message}); trying again`);
return q.delay(500).then(() => pollForServer(url));
return new Promise(resolve => {
setTimeout(() => resolve(pollForServer(url)), 500);
});
});
}
5 changes: 0 additions & 5 deletions yarn.lock
Expand Up @@ -220,11 +220,6 @@ arr-union@^3.1.0:
resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4"
integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=

array-equal@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
integrity sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=

array-unique@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"
Expand Down

0 comments on commit d240291

Please sign in to comment.