Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(jsdom): upgrade jsdom to support Element.prototype.closest #6411

Merged
merged 5 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lighthouse-core/test/lib/page-functions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('DetailsRenderer', () => {
let dom;

beforeAll(() => {
const document = jsdom.jsdom();
const {document} = new jsdom.JSDOM().window;
dom = new DOM(document);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('CategoryRenderer', () => {
global.Util = Util;
global.CriticalRequestChainRenderer = CriticalRequestChainRenderer;

const document = jsdom.jsdom(TEMPLATE_FILE);
const {document} = new jsdom.JSDOM(TEMPLATE_FILE).window;
const dom = new DOM(document);
const detailsRenderer = new DetailsRenderer(dom);
renderer = new CategoryRenderer(dom, detailsRenderer);
Expand Down Expand Up @@ -251,7 +251,8 @@ describe('CategoryRenderer', () => {
it('can set a custom templateContext', () => {
assert.equal(renderer.templateContext, renderer.dom.document());

const otherDocument = jsdom.jsdom(TEMPLATE_FILE);
const dom = new jsdom.JSDOM(TEMPLATE_FILE);
const otherDocument = dom.window.document;
renderer.setTemplateContext(otherDocument);
assert.equal(renderer.templateContext, otherDocument);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('DetailsRenderer', () => {
beforeAll(() => {
global.URL = URL;
global.Util = Util;
const document = jsdom.jsdom(TEMPLATE_FILE);
const {document} = new jsdom.JSDOM(TEMPLATE_FILE).window;
dom = new DOM(document);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('DetailsRenderer', () => {
beforeAll(() => {
global.URL = URL;
global.Util = Util;
const document = jsdom.jsdom(TEMPLATE_FILE);
const {document} = new jsdom.JSDOM(TEMPLATE_FILE).window;
const dom = new DOM(document);
renderer = new DetailsRenderer(dom);
});
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/report/html/renderer/dom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('DOM', () => {

beforeAll(() => {
global.URL = URL;
const document = jsdom.jsdom(TEMPLATE_FILE);
const {document} = new jsdom.JSDOM(TEMPLATE_FILE).window;
dom = new DOM(document);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('PerfCategoryRenderer', () => {
const PerformanceCategoryRenderer =
require('../../../../report/html/renderer/performance-category-renderer.js');

const document = jsdom.jsdom(TEMPLATE_FILE);
const {document} = new jsdom.JSDOM(TEMPLATE_FILE).window;
const dom = new DOM(document);
const detailsRenderer = new DetailsRenderer(dom);
renderer = new PerformanceCategoryRenderer(dom, detailsRenderer);
Expand Down
3 changes: 2 additions & 1 deletion lighthouse-core/test/report/html/renderer/psi-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ describe('DOM', () => {
global.PerformanceCategoryRenderer = PerformanceCategoryRenderer;
global.CriticalRequestChainRenderer = CriticalRequestChainRenderer;

document = jsdom.jsdom(TEMPLATE_FILE);
const {window} = new jsdom.JSDOM(TEMPLATE_FILE);
document = window.document;
});

afterAll(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ describe('ReportRenderer', () => {
};
};

const document = jsdom.jsdom(TEMPLATE_FILE);
global.self = document.defaultView;
const {window} = new jsdom.JSDOM(TEMPLATE_FILE);
global.self = window;

const dom = new DOM(document);
const dom = new DOM(window.document);
const detailsRenderer = new DetailsRenderer(dom);
const categoryRenderer = new CategoryRenderer(dom, detailsRenderer);
renderer = new ReportRenderer(dom, categoryRenderer);
Expand Down Expand Up @@ -149,7 +149,8 @@ describe('ReportRenderer', () => {
it('can set a custom templateContext', () => {
assert.equal(renderer._templateContext, renderer._dom.document());

const otherDocument = jsdom.jsdom(TEMPLATE_FILE);
const {window} = new jsdom.JSDOM(TEMPLATE_FILE);
const otherDocument = window.document;
renderer.setTemplateContext(otherDocument);
assert.equal(renderer._templateContext, otherDocument);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ describe('ReportUIFeatures', () => {
};
};

const document = jsdom.jsdom(TEMPLATE_FILE);
const documentReport = jsdom.jsdom(TEMPLATE_FILE_REPORT);
global.self = document.defaultView;
const document = new jsdom.JSDOM(TEMPLATE_FILE);
const documentReport = new jsdom.JSDOM(TEMPLATE_FILE_REPORT);
global.self = document.window;
global.self.matchMedia = function() {
return {
addListener: function() {},
Expand All @@ -70,8 +70,8 @@ describe('ReportUIFeatures', () => {
};
};

const dom = new DOM(document);
const dom2 = new DOM(documentReport);
const dom = new DOM(document.window.document);
const dom2 = new DOM(documentReport.window.document);
const detailsRenderer = new DetailsRenderer(dom);
const categoryRenderer = new CategoryRenderer(dom, detailsRenderer);
renderer = new ReportRenderer(dom, categoryRenderer);
Expand Down
9 changes: 5 additions & 4 deletions lighthouse-core/test/report/report-generator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ describe('ReportGenerator', () => {
});

it('should inject the report templates', () => {
const page = jsdom.jsdom(ReportGenerator.generateReportHtml({}));
const templates = jsdom.jsdom(TEMPLATES_FILE);
assert.equal(page.querySelectorAll('template[id^="tmpl-"]').length,
templates.querySelectorAll('template[id^="tmpl-"]').length, 'all templates injected');
const page = new jsdom.JSDOM(ReportGenerator.generateReportHtml({}));
const templates = new jsdom.JSDOM(TEMPLATES_FILE);
assert.equal(page.window.document.querySelectorAll('template[id^="tmpl-"]').length,
templates.window.document.querySelectorAll('template[id^="tmpl-"]').length,
'all templates injected');
});

it('should inject the report CSS', () => {
Expand Down
1 change: 0 additions & 1 deletion lighthouse-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"gulp-tap": "^0.1.3",
"gulp-uglify": "^3.0.0",
"gulp-util": "^3.0.7",
"jsdom": "^9.9.1",
"run-sequence": "^1.1.5",
"streamqueue": "^1.1.1",
"uglify-es": "^3.0.15",
Expand Down
5 changes: 3 additions & 2 deletions lighthouse-viewer/test/test-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const jsdom = require('jsdom');
const PAGE = fs.readFileSync(path.join(__dirname, '../app/index.html'), 'utf8');

function setupJsDomGlobals() {
global.document = jsdom.jsdom(PAGE);
global.window = global.document.defaultView;
const {window} = new jsdom.JSDOM(PAGE);
wardpeet marked this conversation as resolved.
Show resolved Hide resolved
global.document = window.document;
global.window = window;
global.logger = console;
global.logger.hide = () => {/* noop */};
}
Expand Down
Loading