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

fix: introduce ignoreDefaultArgs into launchParams #246

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions lib/grover/js/processor.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ const _processPage = (async (convertAction, uriOrHtml, options) => {
launchParams.executablePath = executablePath;
}

// ignoreDefaultArgs
if (options.ignoreDefaultArgs) {
launchParams.ignoreDefaultArgs = options.ignoreDefaultArgs;
}
Comment on lines +78 to +80
Copy link
Contributor

Choose a reason for hiding this comment

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

The options parameter is eventually passed through to the conversion method. To avoid these sorts of other options bleeding through we need to follow the pattern seen elsewhere to store the option in a variable and then delete it (from options) before using it.

Suggested change
if (options.ignoreDefaultArgs) {
launchParams.ignoreDefaultArgs = options.ignoreDefaultArgs;
}
const ignoreDefaultArgs = options.ignoreDefaultArgs; delete options.ignoreDefaultArgs;
if (ignoreDefaultArgs) {
launchParams.ignoreDefaultArgs = ignoreDefaultArgs;
}


// Launch the browser and create a page
browser = await puppeteer.launch(launchParams);
}
Expand Down
21 changes: 21 additions & 0 deletions spec/grover/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,27 @@
end
end

context 'when options include ignoreDefaultArgs' do
context 'when --disable-component-update is provided' do
let(:options) { { 'ignoreDefaultArgs' => ['--disable-component-update'] } }
let(:url_or_html) do
<<-HTML
<html>
<body lang="de" style="font-family: 'DejaVu Sans'; font-size: 10px; width: 100px; hyphens: auto;">
<p>
Testgetriebene Entwicklung ist eine Methode.
</p>
</body>
</html>
HTML
end

it do
expect(pdf_text_content).to eq 'Testgetriebene Ent‐ wicklung ist eine Methode.'
end
Comment on lines +446 to +448
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer the inline form where possible

Suggested change
it do
expect(pdf_text_content).to eq 'Testgetriebene Ent‐ wicklung ist eine Methode.'
end
it { expect(pdf_text_content).to eq 'Testgetriebene Ent‐ wicklung ist eine Methode.' }

end
end

context 'when requesting a URI requiring basic authentication' do
let(:url_or_html) { 'http://localhost:4567/auth' }

Expand Down