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

style(page): Refactored code to remove redundancy #5121

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/Page.js
Expand Up @@ -892,10 +892,8 @@ class Page extends EventEmitter {
screenshotType = options.type;
} else if (options.path) {
const mimeType = mime.getType(options.path);
if (mimeType === 'image/png')
screenshotType = 'png';
else if (mimeType === 'image/jpeg')
screenshotType = 'jpeg';
const mimeMatch = mimeType.match(/^image\/(png|jpeg)$/);
screenshotType = Array.isArray(mimeMatch) ? mimeMatch[1] || null : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is less readable than the original code.

assert(screenshotType, 'Unsupported screenshot mime type: ' + mimeType);
}

Expand Down
2 changes: 2 additions & 0 deletions test/accessibility.spec.js
Expand Up @@ -42,6 +42,7 @@ module.exports.addTests = function({testRunner, expect, FFOX}) {
</select>
</body>`);

await page.focus('[placeholder="Empty input"]');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these unrelated changes from this patch

const golden = FFOX ? {
role: 'document',
name: 'Accessibility Test',
Expand Down Expand Up @@ -81,6 +82,7 @@ module.exports.addTests = function({testRunner, expect, FFOX}) {
});
it('should report uninteresting nodes', async function({page}) {
await page.setContent(`<textarea autofocus>hi</textarea>`);
await page.focus('textarea');
const golden = FFOX ? {
role: 'entry',
name: '',
Expand Down