user_pref('dom.allow_scripts_to_close_windows', true) doesn't work to close headless instance from with script
Categories
(Firefox :: Headless, defect)
Tracking
()
People
(Reporter: guest271314, Unassigned)
Details
Steps to reproduce:
Create profile specifcally for headless testing
$HOME/firefox/firefox-bin -CreateProfile wt
write some user preferences to the created profile
printf "user_pref('network.http.speculative-parallel-limit', 0);\n\
user_pref('devtools.console.stdout.content', true);\n\
user_pref('dom.allow_scripts_to_close_windows', true);" > "$HOME/.mozilla/firefox/$(ls $HOME/.mozilla/firefox | grep '\.wt')/user.js"
Launch headless instance, target Firefox headless, close headless instance when done using window.close() from within script
MOZ_HEADLESS_WIDTH=999 $HOME/firefox/firefox-bin -headless -P wt wt-client.html | grep WEBTRANSPORT_CLIENT
Inside of the script
<script type="module">
await (async () => {
// ...
})()
()
.catch((e) => {
console.log(`${WT_CLIENT}${e.message}`);
});
if (screen.width === 999) {
globalThis.window.close();
}
Actual results:
Even when the if condition is removed, and close() is called directly after awaited async function, close() doesn't close the window and exit the headless Firefox instance launched on commad line.
Expected results:
Headless window closes, headless instance exits when close() is executed from within a script in headless mode.
Comment 1•4 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
| Reporter | ||
Comment 2•4 months ago
|
||
When Firefox headless hangs, doesn't close when user_pref('dom.allow_scripts_to_close_windows', true); is set in user.js, then I have to do CTRL+C to exit I get these messages
^CExiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
which I suspect are prompts sent by the browser for something that the user can't confirm or deny because there's no GUI.
So I think I need the exact preferences to be set to disable first-run, default-browser, whatever prompts the browser is trying to send to the user.
Apparently user_pref('dom.allow_scripts_to_close_windows', true); alone is not sufficient to close the headless browser from scripts.
Updated•4 months ago
|
Updated•4 months ago
|
Description
•