Skip to content

Commit

Permalink
WIP Upgrade dependencies for security issues
Browse files Browse the repository at this point in the history
  • Loading branch information
powerivq committed May 29, 2024
1 parent c7d6eae commit 048bab3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
3 changes: 2 additions & 1 deletion packages/optimizer/spec/end-to-end/EndToEndSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const fetch = fetchMock
.sandbox()
.mock('https://cdn.ampproject.org/rtv/123456789000000/v0.css', '/* ampproject.org/rtv v0.css */')
.mock('https://example.com/amp/rtv/123456789000000/v0.css', '/* example.com v0.css */')
.mock('https://cdn.ampproject.org/v0.css', '/* ampproject.org v0.css */');
.mock('https://cdn.ampproject.org/v0.css', '/* ampproject.org v0.css */')
.mock('https://cdn.ampproject.org/v0/validator.json', '{}');

createSpec({
name: 'End-to-End: AMP First',
Expand Down
1 change: 0 additions & 1 deletion packages/optimizer/spec/helpers/validatorInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ let instance = null;
module.exports = {
get: () => {
if (!instance) {
console.error('Validator instance created: ' + path.join(__dirname, 'validator.js'));
instance = validator.getInstance(path.join(__dirname, 'validator.js'));
}
return instance;
Expand Down
3 changes: 2 additions & 1 deletion packages/optimizer/spec/transformers/TransformerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function loadTestConfigs(subDir) {
.mock('https://cdn.ampproject.org/rtv/001515617716922/v0.css', '/* v0-rtv.css */')
.mock('https://cdn.ampproject.org/rtv/012345678900000/v0.css', '/* v0-prod.css */')
.mock('https://cdn.ampproject.org/rtv/012345678911111/v0.css', '/* v0-lts.css */')
.mock('https://example.com/amp/rtv/012345678922222/v0.css', '/* v0-host.css */');
.mock('https://example.com/amp/rtv/012345678922222/v0.css', '/* v0-host.css */')
.mock('https://cdn.ampproject.org/v0/validator.json', '{}');
const Transformer = require(transformerPath);
const config = {
fetch,
Expand Down
21 changes: 9 additions & 12 deletions packages/page-experience/lib/PageDataGatherer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,16 @@ class PageAnalyzer {
throw new Error('Puppeteer not running, please call `start` first.');
}
const {page, remoteStyles, responsePromise} = await this.setupPage();
try {
await page.goto(url, {waitUntil: 'load'});
await page.goto(url, {waitUntil: 'load'});

const response = await responsePromise;
if (!response) {
throw new Error('Failed loading url', url);
}
const {html, headers} = response;
return await this.gatherPageData(page, {remoteStyles, html, headers});
} finally {
if (page) {
page.close();
}
const response = await responsePromise;
if (!response) {
throw new Error('Failed loading url', url);
}
const {html, headers} = response;
const data = await this.gatherPageData(page, {remoteStyles, html, headers});
await page.close();
return data;
}

/**
Expand All @@ -80,6 +76,7 @@ class PageAnalyzer {
async shutdown() {
try {
await this.browser.close();
this.browser = null;
} catch (e) {
console.log(e);
}
Expand Down

0 comments on commit 048bab3

Please sign in to comment.