Commit 8763f351 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Keep `CHROME_HEADLESS` working while displaying a deprecation warning

parent 04ac6b44
# frozen_string_literal: true
require 'active_support/deprecation'
require 'gitlab/qa'
require 'uri'
......@@ -66,7 +67,11 @@ module QA
# set to 'false' to have the browser run visibly instead of headless
def webdriver_headless?
enabled?(ENV['WEBDRIVER_HEADLESS'])
if ENV.key?('CHROME_HEADLESS')
ActiveSupport::Deprecation.warn("CHROME_HEADLESS is deprecated. Use WEBDRIVER_HEADLESS instead.")
end
enabled?(ENV['WEBDRIVER_HEADLESS']) || enabled?(ENV['CHROME_HEADLESS'])
end
# set to 'true' to have Chrome use a fixed profile directory
......
......@@ -55,6 +55,11 @@ RSpec.describe QA::Runtime::Env do
end
describe '.webdriver_headless?' do
before do
# We need to set this because we have a fallback for CHROME_HEADLESS
stub_env('CHROME_HEADLESS', 'false')
end
it_behaves_like 'boolean method',
method: :webdriver_headless?,
env_key: 'WEBDRIVER_HEADLESS',
......
......@@ -61,7 +61,7 @@ Capybara.register_driver :chrome do |app|
options.add_argument("no-sandbox")
# Run headless by default unless WEBDRIVER_HEADLESS specified
options.add_argument("headless") unless ENV['WEBDRIVER_HEADLESS'] =~ /^(false|no|0)$/i
options.add_argument("headless") unless ENV['WEBDRIVER_HEADLESS'] =~ /^(false|no|0)$/i || ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i
# Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab/issues/4252
options.add_argument("disable-dev-shm-usage") if ENV['CI'] || ENV['CI_SERVER']
......
......@@ -24,6 +24,8 @@ module LiveDebugger
end
def is_headless_disabled?
ENV['WEBDRIVER_HEADLESS'] =~ /^(false|no|0)$/i
ActiveSupport::Deprecation.warn("CHROME_HEADLESS is deprecated. Use WEBDRIVER_HEADLESS instead.") if ENV.key?('CHROME_HEADLESS')
ENV['WEBDRIVER_HEADLESS'] =~ /^(false|no|0)$/i || ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment