mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-24 10:18:59 +00:00
UI/AppKit: Port --allow-popups option from Qt chrome
WebDriver requires this option to be present in order to run the WPT tests.
This commit is contained in:
parent
2539fd6a5c
commit
946ccfc108
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/SebastianZaha
Commit: 946ccfc108
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/536
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/trflynn89
5 changed files with 15 additions and 6 deletions
|
@ -28,7 +28,8 @@
|
|||
newTabPageURL:(URL::URL)new_tab_page_url
|
||||
withCookieJar:(NonnullOwnPtr<WebView::CookieJar>)cookie_jar
|
||||
webContentOptions:(Ladybird::WebContentOptions const&)web_content_options
|
||||
webdriverContentIPCPath:(StringView)webdriver_content_ipc_path;
|
||||
webdriverContentIPCPath:(StringView)webdriver_content_ipc_path
|
||||
allowPopups:(BOOL)allow_popups;
|
||||
|
||||
- (nonnull TabController*)createNewTab:(Optional<URL::URL> const&)url
|
||||
fromTab:(nullable Tab*)tab
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
ByteString m_navigator_compatibility_mode;
|
||||
|
||||
WebView::SearchEngine m_search_engine;
|
||||
|
||||
BOOL m_allow_popups;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) NSMutableArray<TabController*>* managed_tabs;
|
||||
|
@ -62,6 +64,7 @@
|
|||
withCookieJar:(NonnullOwnPtr<WebView::CookieJar>)cookie_jar
|
||||
webContentOptions:(Ladybird::WebContentOptions const&)web_content_options
|
||||
webdriverContentIPCPath:(StringView)webdriver_content_ipc_path
|
||||
allowPopups:(BOOL)allow_popups
|
||||
{
|
||||
if (self = [super init]) {
|
||||
[NSApp setMainMenu:[[NSMenu alloc] init]];
|
||||
|
@ -96,6 +99,8 @@
|
|||
m_navigator_compatibility_mode = "chrome";
|
||||
m_search_engine = WebView::default_search_engine();
|
||||
|
||||
m_allow_popups = allow_popups;
|
||||
|
||||
// Reduce the tooltip delay, as the default delay feels quite long.
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@100 forKey:@"NSInitialToolTipDelay"];
|
||||
}
|
||||
|
@ -199,7 +204,7 @@
|
|||
- (nonnull TabController*)createNewTab:(Web::HTML::ActivateTab)activate_tab
|
||||
fromTab:(nullable Tab*)tab
|
||||
{
|
||||
auto* controller = [[TabController alloc] init];
|
||||
auto* controller = [[TabController alloc] init:!m_allow_popups];
|
||||
[controller showWindow:nil];
|
||||
|
||||
if (tab) {
|
||||
|
|
|
@ -22,7 +22,7 @@ struct TabSettings {
|
|||
|
||||
@interface TabController : NSWindowController <NSWindowDelegate>
|
||||
|
||||
- (instancetype)init;
|
||||
- (instancetype)init:(BOOL)block_popups;
|
||||
|
||||
- (void)loadURL:(URL::URL const&)url;
|
||||
- (void)loadHTML:(StringView)html url:(URL::URL const&)url;
|
||||
|
|
|
@ -82,7 +82,7 @@ static NSString* const TOOLBAR_TAB_OVERVIEW_IDENTIFIER = @"ToolbarTabOverviewIde
|
|||
@synthesize new_tab_toolbar_item = _new_tab_toolbar_item;
|
||||
@synthesize tab_overview_toolbar_item = _tab_overview_toolbar_item;
|
||||
|
||||
- (instancetype)init
|
||||
- (instancetype)init:(BOOL)block_popups
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.toolbar = [[NSToolbar alloc] initWithIdentifier:TOOLBAR_IDENTIFIER];
|
||||
|
@ -91,7 +91,7 @@ static NSString* const TOOLBAR_TAB_OVERVIEW_IDENTIFIER = @"ToolbarTabOverviewIde
|
|||
[self.toolbar setAllowsUserCustomization:NO];
|
||||
[self.toolbar setSizeMode:NSToolbarSizeModeRegular];
|
||||
|
||||
m_settings = {};
|
||||
m_settings = { .block_popups = block_popups };
|
||||
m_can_navigate_back = false;
|
||||
m_can_navigate_forward = false;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
bool log_all_js_exceptions = false;
|
||||
bool enable_http_cache = false;
|
||||
bool new_window = false;
|
||||
bool allow_popups = false;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.set_general_help("The Ladybird web browser");
|
||||
|
@ -99,6 +100,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(log_all_js_exceptions, "Log all JavaScript exceptions", "log-all-js-exceptions");
|
||||
args_parser.add_option(enable_http_cache, "Enable HTTP cache", "enable-http-cache");
|
||||
args_parser.add_option(new_window, "Force opening in a new window", "new-window", 'n');
|
||||
args_parser.add_option(allow_popups, "Disable popup blocking by default", "allow-popups");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
WebView::ChromeProcess chrome_process;
|
||||
|
@ -148,7 +150,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
newTabPageURL:URL::URL { Browser::default_new_tab_url }
|
||||
withCookieJar:move(cookie_jar)
|
||||
webContentOptions:web_content_options
|
||||
webdriverContentIPCPath:webdriver_content_ipc_path];
|
||||
webdriverContentIPCPath:webdriver_content_ipc_path
|
||||
allowPopups:allow_popups];
|
||||
|
||||
[NSApp setDelegate:delegate];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue