We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b727708 commit cca9a0dCopy full SHA for cca9a0d
CHANGELOG.md
@@ -13,6 +13,7 @@
13
- `Ferrum::Frame#frame_element` returns the element in which the window is embedded [#524]
14
- `Ferrum::Page#start_screencast` starts sending frames to record screencast [#494]
15
- `Ferrum::Page#stop_screencast` stops sending frames [#494]
16
+- `Ferrum::Browser#new(incognito: false)` wether to create an incognito profile for the browser startup window, `true` by default.
17
18
### Changed
19
README.md
@@ -151,7 +151,8 @@ Ferrum::Browser.new(options)
151
```
152
153
* options `Hash`
154
- * `:headless` (String | Boolean) - Set browser as headless or not, `true` by default.
+ * `:headless` (Boolean) - Set browser as headless or not, `true` by default.
155
+ * `:incognito` (Boolean) - Create an incognito profile for the browser startup window, `true` by default.
156
* `:xvfb` (Boolean) - Run browser in a virtual framebuffer, `false` by default.
157
* `:flatten` (Boolean) - Use one websocket connection to the browser and all the pages in flatten mode.
158
* `:window_size` (Array) - The dimensions of the browser window in which to
lib/ferrum/browser.rb
@@ -45,6 +45,9 @@ class Browser
45
# @option options [Boolean] :headless (true)
46
# Set browser as headless or not.
47
#
48
+ # @option options [Boolean] :incognito (true)
49
+ # Create an incognito profile for the browser startup window.
50
+ #
51
# @option options [Boolean] :xvfb (false)
52
# Run browser in a virtual framebuffer.
53
lib/ferrum/browser/options.rb
@@ -14,7 +14,7 @@ class Options
attr_reader :window_size, :logger, :ws_max_receive_size,
:js_errors, :base_url, :slowmo, :pending_connection_errors,
:url, :ws_url, :env, :process_timeout, :browser_name, :browser_path,
- :save_path, :proxy, :port, :host, :headless, :browser_options,
+ :save_path, :proxy, :port, :host, :headless, :incognito, :browser_options,
:ignore_default_browser_options, :xvfb, :flatten
attr_accessor :timeout, :default_user_agent
20
@@ -27,6 +27,7 @@ def initialize(options = nil)
27
@window_size = @options.fetch(:window_size, WINDOW_SIZE)
28
@js_errors = @options.fetch(:js_errors, false)
29
@headless = @options.fetch(:headless, true)
30
+ @incognito = @options.fetch(:incognito, true)
31
@flatten = @options.fetch(:flatten, true)
32
@pending_connection_errors = @options.fetch(:pending_connection_errors, true)
33
@process_timeout = @options.fetch(:process_timeout, PROCESS_TIMEOUT)
lib/ferrum/browser/options/chrome.rb
@@ -78,6 +78,7 @@ def merge_required(flags, options, user_data_dir)
78
def merge_default(flags, options)
79
defaults = except("headless", "disable-gpu") if options.headless == false
80
defaults ||= DEFAULT_OPTIONS
81
+ defaults.delete("no-startup-window") if options.incognito == false
82
# On Windows, the --disable-gpu flag is a temporary workaround for a few bugs.
83
# See https://bugs.chromium.org/p/chromium/issues/detail?id=737678 for more information.
84
defaults = defaults.merge("disable-gpu" => nil) if Utils::Platform.windows?
lib/ferrum/context.rb
@@ -61,6 +61,7 @@ def add_target(params:, session_id: nil)
61
new_target = Target.new(@client, session_id, params)
62
# `put_if_absent` returns nil if added a new value or existing if there was one already
63
target = @targets.put_if_absent(new_target.id, new_target) || new_target
64
+ @default_target ||= target
65
66
new_pending = Concurrent::IVar.new
67
pending = @pendings.put_if_absent(target.id, new_pending) || new_pending
lib/ferrum/contexts.rb
@@ -69,13 +69,19 @@ def size
69
70
private
71
72
- # rubocop:disable Metrics/PerceivedComplexity
+ # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
73
def subscribe
74
@client.on("Target.attachedToTarget") do |params|
75
info, session_id = params.values_at("targetInfo", "sessionId")
76
next unless ALLOWED_TARGET_TYPES.include?(info["type"])
77
context_id = info["browserContextId"]
+ unless @contexts[context_id]
+ context = Context.new(@client, self, context_id)
+ @contexts[context_id] = context
+ @default_context ||= context
+ end
+
85
@contexts[context_id]&.add_target(session_id: session_id, params: info)
86
if params["waitingForDebugger"]
87
@client.session(session_id).command("Runtime.runIfWaitingForDebugger", async: true)
@@ -114,7 +120,7 @@ def subscribe
114
120
context&.delete_target(params["targetId"])
115
121
end
116
122
117
- # rubocop:enable Metrics/PerceivedComplexity
123
+ # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
118
124
119
125
def discover
126
@client.command("Target.setDiscoverTargets", discover: true)
0 commit comments