Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Remove some unnecessary dependencies"
This reverts commit 05706e5. Browserify does not include util.promisify, breaking the browser build: https://travis-ci.org/jsdom/jsdom/jobs/438454473. We can re-do this when browserify/browserify#1869 is fixed.
- Loading branch information
Showing
6 changed files
with
107 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,53 @@ | ||
"use strict"; | ||
const http = require("http"); | ||
|
||
const { assert } = require("chai"); | ||
const { describe, specify } = require("mocha-sugar-free"); | ||
const { createServer } = require("../util.js"); | ||
const { beforeEach, describe, specify } = require("mocha-sugar-free"); | ||
const portfinder = require("portfinder"); | ||
|
||
const { JSDOM } = require("../.."); | ||
|
||
describe("xhr-requires-server", { skipIfBrowser: true }, () => { | ||
specify("Getting a non-file URL should not fail for getAllResponseHeaders", () => { | ||
return createServer((req, res) => { | ||
res.writeHead(200, [["date", "0"]]); | ||
res.end("<body></body>"); | ||
}).then(s => { | ||
const testHost = `http://127.0.0.1:${s.address().port}`; | ||
|
||
// From https://github.com/tmpvar/jsdom/pull/1183 | ||
const { window } = new JSDOM(``, { url: testHost + "/TestPath/get-headers" }); | ||
|
||
const xhr = new window.XMLHttpRequest(); | ||
const promise = new Promise(resolve => { | ||
xhr.onload = () => { | ||
assert.strictEqual( | ||
xhr.getAllResponseHeaders(), | ||
"date: 0\r\nconnection: keep-alive\r\ntransfer-encoding: chunked" | ||
); | ||
resolve(); | ||
}; | ||
}); | ||
let testHost = null; | ||
|
||
xhr.open("GET", testHost + "/TestPath/get-headers", true); | ||
xhr.send(); | ||
return promise; | ||
beforeEach(() => { | ||
return new Promise((resolve, reject) => { | ||
portfinder.getPort((err, port) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
|
||
http.createServer((req, res) => { | ||
res.writeHead(200, [["date", "0"]]); | ||
res.end("<body></body>"); | ||
}) | ||
.listen(port); | ||
|
||
testHost = "http://127.0.0.1:" + port; | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
|
||
specify("Getting a non-file URL should not fail for getAllResponseHeaders", t => { | ||
// From https://github.com/tmpvar/jsdom/pull/1183 | ||
const { window } = new JSDOM(``, { url: testHost + "/TestPath/get-headers" }); | ||
|
||
const xhr = new window.XMLHttpRequest(); | ||
xhr.onload = () => { | ||
assert.doesNotThrow(() => { | ||
assert.strictEqual( | ||
xhr.getAllResponseHeaders(), | ||
"date: 0\r\nconnection: keep-alive\r\ntransfer-encoding: chunked" | ||
); | ||
}); | ||
t.done(); | ||
}; | ||
|
||
xhr.open("GET", testHost + "/TestPath/get-headers", true); | ||
xhr.send(); | ||
}, { | ||
async: true | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters