Module: TRMNLP::FirefoxDriver

Defined in:
lib/trmnlp/firefox_driver.rb

Overview

Builds the headless Firefox driver that screenshots rendered plugins. Shared by ‘trmnlp serve` (the PNG preview route) and `trmnlp build –png`.

Class Method Summary collapse

Class Method Details

.buildObject



11
12
13
14
15
# File 'lib/trmnlp/firefox_driver.rb', line 11

def build
  Selenium::WebDriver.for(:firefox, options:).tap do |driver|
    driver.manage.window.maximize
  end
end

.optionsObject



17
18
19
20
21
22
23
24
25
# File 'lib/trmnlp/firefox_driver.rb', line 17

def options
  Selenium::WebDriver::Firefox::Options.new.tap do |opts|
    opts.add_argument('--headless')
    opts.add_argument('--disable-web-security')
    # Subpixel antialiasing colour-fringes badly when quantized to 1-bit e-ink.
    opts.add_preference('gfx.text.disable-aa', true)
    opts.add_preference('gfx.text.subpixel-position.force-disabled', true)
  end
end