Add dom.allow_scripts_to_close_windows pref. (#33187)

It's also present in firefox: https://searchfox.org/mozilla-central/search?q=allow_scripts_to_close_windows

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-08-26 13:44:47 +02:00 committed by GitHub
parent 0e6b55c71d
commit 4397d8a021
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 1 deletions

View file

@ -238,6 +238,7 @@ mod gen {
enabled: bool,
}
},
allow_scripts_to_close_windows: bool,
canvas_capture: {
enabled: bool,
},

View file

@ -60,6 +60,7 @@ use script_traits::{
use selectors::attr::CaseSensitivity;
use servo_arc::Arc as ServoArc;
use servo_atoms::Atom;
use servo_config::pref;
use servo_geometry::{f32_rect_to_au_rect, MaxRect};
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
use style::dom::OpaqueNode;
@ -757,7 +758,9 @@ impl WindowMethods for Window {
let is_auxiliary = window_proxy.is_auxiliary();
// https://html.spec.whatwg.org/multipage/#script-closable
let is_script_closable = (self.is_top_level() && history_length == 1) || is_auxiliary;
let is_script_closable = (self.is_top_level() && history_length == 1) ||
is_auxiliary ||
pref!(dom.allow_scripts_to_close_windows);
// TODO: rest of Step 3:
// Is the incumbent settings object's responsible browsing context familiar with current?

View file

@ -1,6 +1,7 @@
{
"devtools.server.enabled": false,
"devtools.server.port": 0,
"dom.allow_scripts_to_close_windows": false,
"dom.bluetooth.enabled": false,
"dom.bluetooth.testing.enabled": false,
"dom.canvas_capture.enabled": false,