Skip to content

Commit

Permalink
Merge pull request alvarcarto#135 from hooktstudios/bugfix/remove-dep…
Browse files Browse the repository at this point in the history
…recated-options

Remove old goto options, update documentation and default.
  • Loading branch information
kimmobrunfeldt authored Jul 15, 2020
2 parents fabb29a + e57b5ae commit 136d353
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ cookies[0][httpOnly] | boolean | - | Cookie httpOnly
cookies[0][secure] | boolean | - | Cookie secure
cookies[0][sameSite] | string | - | `Strict` or `Lax`
goto.timeout | number | `30000` | Maximum navigation time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout.
goto.waitUntil | string | `networkidle` | When to consider navigation succeeded. Options: `load`, `networkidle`. `load` = consider navigation to be finished when the load event is fired. `networkidle` = consider navigation to be finished when the network activity stays "idle" for at least `goto.networkIdleTimeout` ms.
goto.networkIdleInflight | number | `2` | Maximum amount of inflight requests which are considered "idle". Takes effect only with `goto.waitUntil`: 'networkidle' parameter.
goto.networkIdleTimeout | number | `2000` | A timeout to wait before completing navigation. Takes effect only with waitUntil: 'networkidle' parameter.
goto.waitUntil | string | `networkidle0` | When to consider navigation succeeded. Options: `load`, `domcontentloaded`, `networkidle0`, `networkidle2`. `load` - consider navigation to be finished when the load event is fired. `domcontentloaded` - consider navigation to be finished when the `DOMContentLoaded` event is fired. `networkidle0` - consider navigation to be finished when there are no more than 0 network connections for at least `500` ms. `networkidle2` - consider navigation to be finished when there are no more than 2 network connections for at least `500` ms.
pdf.scale | number | `1` | Scale of the webpage rendering.
pdf.printBackground | boolean | `false`| Print background graphics.
pdf.displayHeaderFooter | boolean | `false` | Display header and footer.
Expand Down
6 changes: 3 additions & 3 deletions src/core/render-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function render(_opts = {}) {
height: 1200,
},
goto: {
waitUntil: 'networkidle2',
waitUntil: 'networkidle0',
},
output: 'pdf',
pdf: {
Expand Down Expand Up @@ -171,7 +171,7 @@ async function render(_opts = {}) {
const selElement = await page.$(opts.screenshot.selector);
if (!_.isNull(selElement)) {
data = await selElement.screenshot();
}
}
}
}
} catch (err) {
Expand All @@ -184,7 +184,7 @@ async function render(_opts = {}) {
await browser.close();
}
}

return data;
}

Expand Down
2 changes: 0 additions & 2 deletions src/http/render-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ function getOptsFromQuery(query) {
goto: {
timeout: query['goto.timeout'],
waitUntil: query['goto.waitUntil'],
networkIdleInflight: query['goto.networkIdleInflight'],
networkIdleTimeout: query['goto.networkIdleTimeout'],
},
pdf: {
scale: query['pdf.scale'],
Expand Down
4 changes: 0 additions & 4 deletions src/util/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const sharedQuerySchema = Joi.object({
'viewport.isLandscape': Joi.boolean(),
'goto.timeout': Joi.number().min(0).max(60000),
'goto.waitUntil': Joi.string().min(1).max(2000),
'goto.networkIdleInflight': Joi.number().min(0).max(1000),
'goto.networkIdleTimeout': Joi.number().min(0).max(1000),
'pdf.scale': Joi.number().min(0).max(1000),
'pdf.displayHeaderFooter': Joi.boolean(),
'pdf.landscape': Joi.boolean(),
Expand Down Expand Up @@ -94,8 +92,6 @@ const renderBodyObject = Joi.object({
goto: Joi.object({
timeout: Joi.number().min(0).max(60000),
waitUntil: Joi.string().min(1).max(2000),
networkIdleInflight: Joi.number().min(0).max(1000),
networkIdleTimeout: Joi.number().min(0).max(1000),
}),
pdf: Joi.object({
scale: Joi.number().min(0).max(1000),
Expand Down

0 comments on commit 136d353

Please sign in to comment.