{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}

module Test.WebDriver.Capabilities where

import Test.WebDriver.Chrome.Extension
import Test.WebDriver.Firefox.Profile
import Test.WebDriver.JSON

import Data.Aeson
import Data.Aeson.Types (Parser, typeMismatch, Pair)

import Data.Text (Text, toLower, toUpper)
import Data.Default (Default, def)
import Data.Word (Word16)
import Data.Maybe (fromMaybe, catMaybes)
import Data.String (fromString)

import Control.Applicative
import Control.Exception.Lifted (throw)

import Prelude -- hides some "unused import" warnings

#if MIN_VERSION_aeson(2,0,0)
import qualified Data.Aeson.KeyMap          as HM (delete, toList, empty)
#else
import qualified Data.HashMap.Strict        as HM (delete, toList, empty)
#endif


-- |A typeclass for readable 'Capabilities'
class GetCapabilities t where
  getCaps :: t -> Capabilities

instance GetCapabilities Capabilities where
  getCaps :: Capabilities -> Capabilities
getCaps = Capabilities -> Capabilities
forall a. a -> a
id

-- |A typeclass for writable 'Capabilities'
class SetCapabilities t where
  setCaps :: Capabilities -> t -> t

-- |Read/write 'Capabilities'
type HasCapabilities t = (GetCapabilities t, SetCapabilities t)

-- |Modifies the 'wdCapabilities' field of a 'WDConfig' by applying the given function. Overloaded to work with any 'HasCapabilities' instance.
modifyCaps :: HasCapabilities t => (Capabilities -> Capabilities) -> t -> t
modifyCaps :: forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps Capabilities -> Capabilities
f t
c = Capabilities -> t -> t
forall t. SetCapabilities t => Capabilities -> t -> t
setCaps (Capabilities -> Capabilities
f (t -> Capabilities
forall t. GetCapabilities t => t -> Capabilities
getCaps t
c)) t
c

-- |A helper function for setting the 'browser' capability of a 'HasCapabilities' instance
useBrowser :: HasCapabilities t => Browser -> t -> t
useBrowser :: forall t. HasCapabilities t => Browser -> t -> t
useBrowser Browser
b = (Capabilities -> Capabilities) -> t -> t
forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps ((Capabilities -> Capabilities) -> t -> t)
-> (Capabilities -> Capabilities) -> t -> t
forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { browser = b }

-- |A helper function for setting the 'version' capability of a 'HasCapabilities' instance
useVersion :: HasCapabilities t => String -> t -> t
useVersion :: forall t. HasCapabilities t => String -> t -> t
useVersion String
v = (Capabilities -> Capabilities) -> t -> t
forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps ((Capabilities -> Capabilities) -> t -> t)
-> (Capabilities -> Capabilities) -> t -> t
forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { version = Just v }

-- |A helper function for setting the 'platform' capability of a 'HasCapabilities' instance
usePlatform :: HasCapabilities t => Platform -> t -> t
usePlatform :: forall t. HasCapabilities t => Platform -> t -> t
usePlatform Platform
p = (Capabilities -> Capabilities) -> t -> t
forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps ((Capabilities -> Capabilities) -> t -> t)
-> (Capabilities -> Capabilities) -> t -> t
forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { platform = p }

-- |A helper function for setting the 'useProxy' capability of a 'HasCapabilities' instance
useProxy :: HasCapabilities t => ProxyType -> t -> t
useProxy :: forall t. HasCapabilities t => ProxyType -> t -> t
useProxy ProxyType
p = (Capabilities -> Capabilities) -> t -> t
forall t.
HasCapabilities t =>
(Capabilities -> Capabilities) -> t -> t
modifyCaps ((Capabilities -> Capabilities) -> t -> t)
-> (Capabilities -> Capabilities) -> t -> t
forall a b. (a -> b) -> a -> b
$ \Capabilities
c -> Capabilities
c { proxy = p }


{- |A structure describing the capabilities of a session. This record
serves dual roles.

* It's used to specify the desired capabilities for a session before
it's created. In this usage, fields that are set to Nothing indicate
that we have no preference for that capability.

* When received from the server , it's used to
describe the actual capabilities given to us by the WebDriver
server. Here a value of Nothing indicates that the server doesn't
support the capability. Thus, for Maybe Bool fields, both Nothing and
Just False indicate a lack of support for the desired capability.
-}
data Capabilities =
  Capabilities { -- |Browser choice and browser specific settings.
                 Capabilities -> Browser
browser                  :: Browser
                 -- |Browser version to use.
               , Capabilities -> Maybe String
version                  :: Maybe String
                 -- |Platform on which the browser should run.
               , Capabilities -> Platform
platform                 :: Platform
                 -- |Proxy configuration settings.
               , Capabilities -> ProxyType
proxy                    :: ProxyType
                 -- |Whether the session supports executing JavaScript via
                 -- 'executeJS' and 'asyncJS'.
               , Capabilities -> Maybe Bool
javascriptEnabled        :: Maybe Bool
                 -- |Whether the session supports taking screenshots of the
                 -- current page with the 'screenshot' command
               , Capabilities -> Maybe Bool
takesScreenshot          :: Maybe Bool
                 -- |Whether the session can interact with modal popups,
                 -- such as window.alert and window.confirm via
                 -- 'acceptAlerts', 'dismissAlerts', etc.
               , Capabilities -> Maybe Bool
handlesAlerts            :: Maybe Bool
                 -- |Whether the session can interact with database storage.
               , Capabilities -> Maybe Bool
databaseEnabled          :: Maybe Bool
                 -- |Whether the session can set and query the browser's
                 -- location context with 'setLocation' and 'getLocation'.
               , Capabilities -> Maybe Bool
locationContextEnabled   :: Maybe Bool
                 -- |Whether the session can interact with the application cache
                 -- .
               , Capabilities -> Maybe Bool
applicationCacheEnabled  :: Maybe Bool
                 -- |Whether the session can query for the browser's
                 -- connectivity and disable it if desired
               , Capabilities -> Maybe Bool
browserConnectionEnabled :: Maybe Bool
                 -- |Whether the session supports CSS selectors when searching
                 -- for elements.
               , Capabilities -> Maybe Bool
cssSelectorsEnabled      :: Maybe Bool
                 -- |Whether Web Storage ('getKey', 'setKey', etc) support is
                 -- enabled
               , Capabilities -> Maybe Bool
webStorageEnabled        :: Maybe Bool
                 -- |Whether the session can rotate the current page's current
                 -- layout between 'Portrait' and 'Landscape' orientations.
               , Capabilities -> Maybe Bool
rotatable                :: Maybe Bool
                 -- |Whether the session should accept all SSL certs by default
               , Capabilities -> Maybe Bool
acceptSSLCerts           :: Maybe Bool
                 -- |Whether the session is capable of generating native OS
                 -- events when simulating user input.
               , Capabilities -> Maybe Bool
nativeEvents             :: Maybe Bool
                 -- |How the session should handle unexpected alerts.
               , Capabilities -> Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
                 -- |A list of ('Text', 'Value') pairs specifying additional non-standard capabilities.
               , Capabilities -> [Pair]
additionalCaps           :: [Pair]
               } deriving (Capabilities -> Capabilities -> Bool
(Capabilities -> Capabilities -> Bool)
-> (Capabilities -> Capabilities -> Bool) -> Eq Capabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Capabilities -> Capabilities -> Bool
== :: Capabilities -> Capabilities -> Bool
$c/= :: Capabilities -> Capabilities -> Bool
/= :: Capabilities -> Capabilities -> Bool
Eq, Int -> Capabilities -> ShowS
[Capabilities] -> ShowS
Capabilities -> String
(Int -> Capabilities -> ShowS)
-> (Capabilities -> String)
-> ([Capabilities] -> ShowS)
-> Show Capabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Capabilities -> ShowS
showsPrec :: Int -> Capabilities -> ShowS
$cshow :: Capabilities -> String
show :: Capabilities -> String
$cshowList :: [Capabilities] -> ShowS
showList :: [Capabilities] -> ShowS
Show)

instance Default Capabilities where
  def :: Capabilities
def = Capabilities { browser :: Browser
browser = Browser
firefox
                     , version :: Maybe String
version = Maybe String
forall a. Maybe a
Nothing
                     , platform :: Platform
platform = Platform
Any
                     , javascriptEnabled :: Maybe Bool
javascriptEnabled = Maybe Bool
forall a. Maybe a
Nothing
                     , takesScreenshot :: Maybe Bool
takesScreenshot = Maybe Bool
forall a. Maybe a
Nothing
                     , handlesAlerts :: Maybe Bool
handlesAlerts = Maybe Bool
forall a. Maybe a
Nothing
                     , databaseEnabled :: Maybe Bool
databaseEnabled = Maybe Bool
forall a. Maybe a
Nothing
                     , locationContextEnabled :: Maybe Bool
locationContextEnabled = Maybe Bool
forall a. Maybe a
Nothing
                     , applicationCacheEnabled :: Maybe Bool
applicationCacheEnabled = Maybe Bool
forall a. Maybe a
Nothing
                     , browserConnectionEnabled :: Maybe Bool
browserConnectionEnabled = Maybe Bool
forall a. Maybe a
Nothing
                     , cssSelectorsEnabled :: Maybe Bool
cssSelectorsEnabled = Maybe Bool
forall a. Maybe a
Nothing
                     , webStorageEnabled :: Maybe Bool
webStorageEnabled = Maybe Bool
forall a. Maybe a
Nothing
                     , rotatable :: Maybe Bool
rotatable = Maybe Bool
forall a. Maybe a
Nothing
                     , acceptSSLCerts :: Maybe Bool
acceptSSLCerts = Maybe Bool
forall a. Maybe a
Nothing
                     , nativeEvents :: Maybe Bool
nativeEvents = Maybe Bool
forall a. Maybe a
Nothing
                     , proxy :: ProxyType
proxy = ProxyType
UseSystemSettings
                     , unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior = Maybe UnexpectedAlertBehavior
forall a. Maybe a
Nothing
                     , additionalCaps :: [Pair]
additionalCaps = []
                     }

-- |Default capabilities. This is the same as the 'Default' instance, but with
-- less polymorphism. By default, we use 'firefox' of an unspecified 'version'
-- with default system-wide 'proxy' settings on whatever 'platform' is available
-- . All 'Maybe' capabilities are set to 'Nothing' (no preference).
defaultCaps :: Capabilities
defaultCaps :: Capabilities
defaultCaps = Capabilities
forall a. Default a => a
def

-- |Same as 'defaultCaps', but with all 'Maybe' 'Bool' capabilities set to
-- 'Just' 'True'.
allCaps :: Capabilities
allCaps :: Capabilities
allCaps = Capabilities
defaultCaps { javascriptEnabled = Just True
                      , takesScreenshot = Just True
                      , handlesAlerts = Just True
                      , databaseEnabled = Just True
                      , locationContextEnabled = Just True
                      , applicationCacheEnabled = Just True
                      , browserConnectionEnabled = Just True
                      , cssSelectorsEnabled = Just True
                      , webStorageEnabled = Just True
                      , rotatable = Just True
                      , acceptSSLCerts = Just True
                      , nativeEvents = Just True
                      }

instance ToJSON Capabilities where
  toJSON :: Capabilities -> Value
toJSON Capabilities{[Pair]
Maybe Bool
Maybe String
Maybe UnexpectedAlertBehavior
ProxyType
Platform
Browser
browser :: Capabilities -> Browser
version :: Capabilities -> Maybe String
platform :: Capabilities -> Platform
proxy :: Capabilities -> ProxyType
javascriptEnabled :: Capabilities -> Maybe Bool
takesScreenshot :: Capabilities -> Maybe Bool
handlesAlerts :: Capabilities -> Maybe Bool
databaseEnabled :: Capabilities -> Maybe Bool
locationContextEnabled :: Capabilities -> Maybe Bool
applicationCacheEnabled :: Capabilities -> Maybe Bool
browserConnectionEnabled :: Capabilities -> Maybe Bool
cssSelectorsEnabled :: Capabilities -> Maybe Bool
webStorageEnabled :: Capabilities -> Maybe Bool
rotatable :: Capabilities -> Maybe Bool
acceptSSLCerts :: Capabilities -> Maybe Bool
nativeEvents :: Capabilities -> Maybe Bool
unexpectedAlertBehavior :: Capabilities -> Maybe UnexpectedAlertBehavior
additionalCaps :: Capabilities -> [Pair]
browser :: Browser
version :: Maybe String
platform :: Platform
proxy :: ProxyType
javascriptEnabled :: Maybe Bool
takesScreenshot :: Maybe Bool
handlesAlerts :: Maybe Bool
databaseEnabled :: Maybe Bool
locationContextEnabled :: Maybe Bool
applicationCacheEnabled :: Maybe Bool
browserConnectionEnabled :: Maybe Bool
cssSelectorsEnabled :: Maybe Bool
webStorageEnabled :: Maybe Bool
rotatable :: Maybe Bool
acceptSSLCerts :: Maybe Bool
nativeEvents :: Maybe Bool
unexpectedAlertBehavior :: Maybe UnexpectedAlertBehavior
additionalCaps :: [Pair]
..} =
    [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ (Pair -> Bool) -> [Pair] -> [Pair]
forall a. (a -> Bool) -> [a] -> [a]
filter (\Pair
p -> Pair -> Value
forall a b. (a, b) -> b
snd Pair
p Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
/= Value
Null)
           ([Pair] -> [Pair]) -> [Pair] -> [Pair]
forall a b. (a -> b) -> a -> b
$ [ Key
"browserName" Key -> Browser -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Browser
browser
             , Key
"version" Key -> Maybe String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe String
version
             , Key
"platform" Key -> Platform -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Platform
platform
             , Key
"proxy" Key -> ProxyType -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ProxyType
proxy
             , Key
"javascriptEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
javascriptEnabled
             , Key
"takesScreenshot" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
takesScreenshot
             , Key
"handlesAlerts" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
handlesAlerts
             , Key
"databaseEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
databaseEnabled
             , Key
"locationContextEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
locationContextEnabled
             , Key
"applicationCacheEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
applicationCacheEnabled
             , Key
"browserConnectionEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
browserConnectionEnabled
             , Key
"cssSelectorsEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
cssSelectorsEnabled
             , Key
"webStorageEnabled" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
webStorageEnabled
             , Key
"rotatable" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
rotatable
             , Key
"acceptSslCerts" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
acceptSSLCerts
             , Key
"nativeEvents" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
nativeEvents
             , Key
"unexpectedAlertBehavior" Key -> Maybe UnexpectedAlertBehavior -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe UnexpectedAlertBehavior
unexpectedAlertBehavior
             ]
    [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [Pair]
browserInfo
    [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [Pair]
additionalCaps
    where
      browserInfo :: [Pair]
browserInfo = case Browser
browser of
        Firefox {Maybe Bool
Maybe String
Maybe (PreparedProfile Firefox)
LogLevel
ffProfile :: Maybe (PreparedProfile Firefox)
ffLogPref :: LogLevel
ffBinary :: Maybe String
ffAcceptInsecureCerts :: Maybe Bool
ffProfile :: Browser -> Maybe (PreparedProfile Firefox)
ffLogPref :: Browser -> LogLevel
ffBinary :: Browser -> Maybe String
ffAcceptInsecureCerts :: Browser -> Maybe Bool
..}
          -> [Key
"firefox_profile" Key -> Maybe (PreparedProfile Firefox) -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe (PreparedProfile Firefox)
ffProfile
             ,Key
"loggingPrefs" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [Key
"driver" Key -> LogLevel -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= LogLevel
ffLogPref]
             ,Key
"firefox_binary" Key -> Maybe String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe String
ffBinary
             ,Key
"acceptInsecureCerts" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool -> Maybe Bool -> Bool
forall a. a -> Maybe a -> a
fromMaybe Bool
False Maybe Bool
ffAcceptInsecureCerts
             ]
        Chrome {[String]
[ChromeExtension]
Maybe String
Object
chromeDriverVersion :: Maybe String
chromeBinary :: Maybe String
chromeOptions :: [String]
chromeExtensions :: [ChromeExtension]
chromeExperimentalOptions :: Object
chromeDriverVersion :: Browser -> Maybe String
chromeBinary :: Browser -> Maybe String
chromeOptions :: Browser -> [String]
chromeExtensions :: Browser -> [ChromeExtension]
chromeExperimentalOptions :: Browser -> Object
..}
          -> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes [ Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"chrome.chromedriverVersion" Maybe String
chromeDriverVersion ]
             [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [ Key
"chromeOptions" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object ([Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes
                  [ Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"binary" Maybe String
chromeBinary
                  ] [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++
                  [ Key
"args"       Key -> [String] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [String]
chromeOptions
                  , Key
"extensions" Key -> [ChromeExtension] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [ChromeExtension]
chromeExtensions
                  ] [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ Object -> [Pair]
forall v. KeyMap v -> [(Key, v)]
HM.toList Object
chromeExperimentalOptions
                )]
        IE {Bool
Integer
Maybe String
Maybe Text
IEElementScrollBehavior
IELogLevel
ieIgnoreProtectedModeSettings :: Bool
ieIgnoreZoomSetting :: Bool
ieInitialBrowserUrl :: Maybe Text
ieElementScrollBehavior :: IEElementScrollBehavior
ieEnablePersistentHover :: Bool
ieEnableElementCacheCleanup :: Bool
ieRequireWindowFocus :: Bool
ieBrowserAttachTimeout :: Integer
ieLogFile :: Maybe String
ieLogLevel :: IELogLevel
ieHost :: Maybe Text
ieExtractPath :: Maybe Text
ieSilent :: Bool
ieForceCreateProcess :: Bool
ieSwitches :: Maybe Text
ieIgnoreProtectedModeSettings :: Browser -> Bool
ieIgnoreZoomSetting :: Browser -> Bool
ieInitialBrowserUrl :: Browser -> Maybe Text
ieElementScrollBehavior :: Browser -> IEElementScrollBehavior
ieEnablePersistentHover :: Browser -> Bool
ieEnableElementCacheCleanup :: Browser -> Bool
ieRequireWindowFocus :: Browser -> Bool
ieBrowserAttachTimeout :: Browser -> Integer
ieLogFile :: Browser -> Maybe String
ieLogLevel :: Browser -> IELogLevel
ieHost :: Browser -> Maybe Text
ieExtractPath :: Browser -> Maybe Text
ieSilent :: Browser -> Bool
ieForceCreateProcess :: Browser -> Bool
ieSwitches :: Browser -> Maybe Text
..}
          -> [Key
"ignoreProtectedModeSettings" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieIgnoreProtectedModeSettings
             ,Key
"ignoreZoomSetting" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieIgnoreZoomSetting
             ,Key
"initialBrowserUrl" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieInitialBrowserUrl
             ,Key
"elementScrollBehavior" Key -> IEElementScrollBehavior -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= IEElementScrollBehavior
ieElementScrollBehavior
             ,Key
"enablePersistentHover" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieEnablePersistentHover
             ,Key
"enableElementCacheCleanup" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieEnableElementCacheCleanup
             ,Key
"requireWindowFocus" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieRequireWindowFocus
             ,Key
"browserAttachTimeout" Key -> Integer -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Integer
ieBrowserAttachTimeout
             ,Key
"logFile" Key -> Maybe String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe String
ieLogFile
             ,Key
"logLevel" Key -> IELogLevel -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= IELogLevel
ieLogLevel
             ,Key
"host" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieHost
             ,Key
"extractPath" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieExtractPath
             ,Key
"silent" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieSilent
             ,Key
"forceCreateProcess" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
ieForceCreateProcess
             ,Key
"internetExplorerSwitches" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
ieSwitches
             ]
        Opera{Bool
Maybe Int
Maybe String
Maybe Word16
LogLevel
operaBinary :: Maybe String
operaProduct :: Maybe String
operaDetach :: Bool
operaAutoStart :: Bool
operaIdle :: Bool
operaDisplay :: Maybe Int
operaLauncher :: Maybe String
operaPort :: Maybe Word16
operaHost :: Maybe String
operaOptions :: Maybe String
operaLogFile :: Maybe String
operaLogPref :: LogLevel
operaBinary :: Browser -> Maybe String
operaProduct :: Browser -> Maybe String
operaDetach :: Browser -> Bool
operaAutoStart :: Browser -> Bool
operaIdle :: Browser -> Bool
operaDisplay :: Browser -> Maybe Int
operaLauncher :: Browser -> Maybe String
operaPort :: Browser -> Maybe Word16
operaHost :: Browser -> Maybe String
operaOptions :: Browser -> Maybe String
operaLogFile :: Browser -> Maybe String
operaLogPref :: Browser -> LogLevel
..}
          -> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes [ Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.binary" Maybe String
operaBinary
                       , Key -> Maybe Int -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.display" Maybe Int
operaDisplay
                       , Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.product" Maybe String
operaProduct
                       , Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.launcher" Maybe String
operaLauncher
                       , Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.host" Maybe String
operaHost
                       , Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"opera.logging.file" Maybe String
operaLogFile
                       ]
             [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ [Key
"opera.detatch" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
operaDetach
                ,Key
"opera.no_quit" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
operaDetach --backwards compatability
                ,Key
"opera.autostart" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
operaAutoStart
                , Key
"opera.idle" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
operaIdle
                -- ,"opera.profile" .= operaProfile
                ,Key
"opera.port" Key -> Word16 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Word16 -> Maybe Word16 -> Word16
forall a. a -> Maybe a -> a
fromMaybe Word16
forall a. Bounded a => a
maxBound {- (-1) -} Maybe Word16
operaPort
                 --note: consider replacing operaOptions with a list of options
                ,Key
"opera.arguments" Key -> Maybe String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe String
operaOptions
                ,Key
"opera.logging.level" Key -> LogLevel -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= LogLevel
operaLogPref
                ]

        Phantomjs {[String]
Maybe String
phantomjsBinary :: Maybe String
phantomjsOptions :: [String]
phantomjsBinary :: Browser -> Maybe String
phantomjsOptions :: Browser -> [String]
..}
          -> [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
catMaybes [ Key -> Maybe String -> Maybe Pair
forall {f :: * -> *} {e} {b} {a}.
(Functor f, KeyValue e b, ToJSON a) =>
Key -> f a -> f b
opt Key
"phantomjs.binary.path" Maybe String
phantomjsBinary
                       ] [Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++
                       [ Key
"phantomjs.cli.args" Key -> [String] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [String]
phantomjsOptions
                       ]

        Browser
_ -> []

        where
          opt :: Key -> f a -> f b
opt Key
k = (a -> b) -> f a -> f b
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Key
k Key -> a -> b
forall v. ToJSON v => Key -> v -> b
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=)


instance FromJSON Capabilities where
  parseJSON :: Value -> Parser Capabilities
parseJSON (Object Object
o) = do
    Browser
browser <- Text -> Parser Browser
forall a. FromJSON a => Text -> Parser a
req Text
"browserName"
    Browser
-> Maybe String
-> Platform
-> ProxyType
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe UnexpectedAlertBehavior
-> [Pair]
-> Capabilities
Capabilities (Browser
 -> Maybe String
 -> Platform
 -> ProxyType
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe UnexpectedAlertBehavior
 -> [Pair]
 -> Capabilities)
-> Parser Browser
-> Parser
     (Maybe String
      -> Platform
      -> ProxyType
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Browser -> Parser Browser
getBrowserCaps Browser
browser
                 Parser
  (Maybe String
   -> Platform
   -> ProxyType
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe String)
-> Parser
     (Platform
      -> ProxyType
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"version" Maybe String
forall a. Maybe a
Nothing
                 Parser
  (Platform
   -> ProxyType
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser Platform
-> Parser
     (ProxyType
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser Platform
forall a. FromJSON a => Text -> Parser a
req Text
"platform"
                 Parser
  (ProxyType
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser ProxyType
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> ProxyType -> Parser ProxyType
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"proxy" ProxyType
NoProxy
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"javascriptEnabled"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"takesScreenshot"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"handlesAlerts"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"databaseEnabled"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"locationContextEnabled"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"applicationCacheEnabled"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"browserConnectionEnabled"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"cssSelectorEnabled"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"webStorageEnabled"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe UnexpectedAlertBehavior
      -> [Pair]
      -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"rotatable"
                 Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe UnexpectedAlertBehavior
   -> [Pair]
   -> Capabilities)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"acceptSslCerts"
                 Parser
  (Maybe Bool
   -> Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities)
-> Parser (Maybe Bool)
-> Parser (Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser (Maybe Bool)
b Text
"nativeEvents"
                 Parser (Maybe UnexpectedAlertBehavior -> [Pair] -> Capabilities)
-> Parser (Maybe UnexpectedAlertBehavior)
-> Parser ([Pair] -> Capabilities)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> Maybe UnexpectedAlertBehavior
-> Parser (Maybe UnexpectedAlertBehavior)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"unexpectedAlertBehaviour" Maybe UnexpectedAlertBehavior
forall a. Maybe a
Nothing
                 Parser ([Pair] -> Capabilities)
-> Parser [Pair] -> Parser Capabilities
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Pair] -> Parser [Pair]
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Browser -> [Pair]
additionalCapabilities Browser
browser)

    where --some helpful JSON accessor shorthands
          req :: FromJSON a => Text -> Parser a
          req :: forall a. FromJSON a => Text -> Parser a
req = (Object
o Object -> Key -> Parser a
forall a. FromJSON a => Object -> Key -> Parser a
.:) (Key -> Parser a) -> (Text -> Key) -> Text -> Parser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Key
fromText  -- required field
          opt :: FromJSON a => Text -> a -> Parser a
          opt :: forall a. FromJSON a => Text -> a -> Parser a
opt Text
k a
d = Object
o Object -> Text -> Parser (Maybe a)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:?? Text
k Parser (Maybe a) -> a -> Parser a
forall a. Parser (Maybe a) -> a -> Parser a
.!= a
d -- optional field
          b :: Text -> Parser (Maybe Bool)
          b :: Text -> Parser (Maybe Bool)
b Text
k = Text -> Maybe Bool -> Parser (Maybe Bool)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
k Maybe Bool
forall a. Maybe a
Nothing     -- Maybe Bool field

          -- produce additionalCaps by removing known capabilities from the JSON object
          additionalCapabilities :: Browser -> [Pair]
additionalCapabilities = Object -> [Pair]
forall v. KeyMap v -> [(Key, v)]
HM.toList (Object -> [Pair]) -> (Browser -> Object) -> Browser -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Key -> Object -> Object) -> Object -> [Key] -> Object
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Key -> Object -> Object
forall v. Key -> KeyMap v -> KeyMap v
HM.delete Object
o ([Key] -> Object) -> (Browser -> [Key]) -> Browser -> Object
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Browser -> [Key]
forall {a}. IsString a => Browser -> [a]
knownCapabilities

          knownCapabilities :: Browser -> [a]
knownCapabilities Browser
browser =
            [ a
"browserName", a
"version", a
"platform", a
"proxy"
            , a
"javascriptEnabled", a
"takesScreenshot", a
"handlesAlerts"
            , a
"databaseEnabled", a
"locationContextEnabled"
            , a
"applicationCacheEnabled", a
"browserConnectionEnabled"
            , a
"cssSelectorEnabled",a
"webStorageEnabled", a
"rotatable"
            , a
"acceptSslCerts", a
"nativeEvents", a
"unexpectedBrowserBehaviour"]
            [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++ case Browser
browser of
              Firefox {} -> [a
"firefox_profile", a
"loggingPrefs", a
"firefox_binary", a
"acceptInsecureCerts"]
              Chrome {} -> [a
"chrome.chromedriverVersion", a
"chrome.extensions", a
"chrome.switches", a
"chrome.extensions"]
              IE {} -> [a
"ignoreProtectedModeSettings", a
"ignoreZoomSettings", a
"initialBrowserUrl", a
"elementScrollBehavior"
                       ,a
"enablePersistentHover", a
"enableElementCacheCleanup", a
"requireWindowFocus", a
"browserAttachTimeout"
                       ,a
"logFile", a
"logLevel", a
"host", a
"extractPath", a
"silent", a
"forceCreateProcess", a
"internetExplorerSwitches"]
              Opera {} -> [a
"opera.binary", a
"opera.product", a
"opera.no_quit", a
"opera.autostart", a
"opera.idle", a
"opera.display"
                          ,a
"opera.launcher", a
"opera.port", a
"opera.host", a
"opera.arguments", a
"opera.logging.file", a
"opera.logging.level"]
              Browser
_ -> []
          getBrowserCaps :: Browser -> Parser Browser
getBrowserCaps Browser
browser =
            case Browser
browser of
              Firefox {} -> Maybe (PreparedProfile Firefox)
-> LogLevel -> Maybe String -> Maybe Bool -> Browser
Firefox (Maybe (PreparedProfile Firefox)
 -> LogLevel -> Maybe String -> Maybe Bool -> Browser)
-> Parser (Maybe (PreparedProfile Firefox))
-> Parser (LogLevel -> Maybe String -> Maybe Bool -> Browser)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> Maybe (PreparedProfile Firefox)
-> Parser (Maybe (PreparedProfile Firefox))
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"firefox_profile" Maybe (PreparedProfile Firefox)
forall a. Maybe a
Nothing
                                    Parser (LogLevel -> Maybe String -> Maybe Bool -> Browser)
-> Parser LogLevel
-> Parser (Maybe String -> Maybe Bool -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> LogLevel -> Parser LogLevel
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"loggingPrefs" LogLevel
forall a. Default a => a
def
                                    Parser (Maybe String -> Maybe Bool -> Browser)
-> Parser (Maybe String) -> Parser (Maybe Bool -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"firefox_binary" Maybe String
forall a. Maybe a
Nothing
                                    Parser (Maybe Bool -> Browser)
-> Parser (Maybe Bool) -> Parser Browser
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Bool -> Parser (Maybe Bool)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"acceptInsecureCerts" Maybe Bool
forall a. Maybe a
Nothing
              Chrome {} -> Maybe String
-> Maybe String
-> [String]
-> [ChromeExtension]
-> Object
-> Browser
Chrome (Maybe String
 -> Maybe String
 -> [String]
 -> [ChromeExtension]
 -> Object
 -> Browser)
-> Parser (Maybe String)
-> Parser
     (Maybe String
      -> [String] -> [ChromeExtension] -> Object -> Browser)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.chromedriverVersion" Maybe String
forall a. Maybe a
Nothing
                                  Parser
  (Maybe String
   -> [String] -> [ChromeExtension] -> Object -> Browser)
-> Parser (Maybe String)
-> Parser ([String] -> [ChromeExtension] -> Object -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.binary" Maybe String
forall a. Maybe a
Nothing
                                  Parser ([String] -> [ChromeExtension] -> Object -> Browser)
-> Parser [String]
-> Parser ([ChromeExtension] -> Object -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> [String] -> Parser [String]
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.switches" []
                                  Parser ([ChromeExtension] -> Object -> Browser)
-> Parser [ChromeExtension] -> Parser (Object -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> [ChromeExtension] -> Parser [ChromeExtension]
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"chrome.extensions" []
                                  Parser (Object -> Browser) -> Parser Object -> Parser Browser
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object -> Parser Object
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Object
forall v. KeyMap v
HM.empty
              IE {} -> Bool
-> Bool
-> Maybe Text
-> IEElementScrollBehavior
-> Bool
-> Bool
-> Bool
-> Integer
-> Maybe String
-> IELogLevel
-> Maybe Text
-> Maybe Text
-> Bool
-> Bool
-> Maybe Text
-> Browser
IE (Bool
 -> Bool
 -> Maybe Text
 -> IEElementScrollBehavior
 -> Bool
 -> Bool
 -> Bool
 -> Integer
 -> Maybe String
 -> IELogLevel
 -> Maybe Text
 -> Maybe Text
 -> Bool
 -> Bool
 -> Maybe Text
 -> Browser)
-> Parser Bool
-> Parser
     (Bool
      -> Maybe Text
      -> IEElementScrollBehavior
      -> Bool
      -> Bool
      -> Bool
      -> Integer
      -> Maybe String
      -> IELogLevel
      -> Maybe Text
      -> Maybe Text
      -> Bool
      -> Bool
      -> Maybe Text
      -> Browser)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"ignoreProtectedModeSettings" Bool
True
                          Parser
  (Bool
   -> Maybe Text
   -> IEElementScrollBehavior
   -> Bool
   -> Bool
   -> Bool
   -> Integer
   -> Maybe String
   -> IELogLevel
   -> Maybe Text
   -> Maybe Text
   -> Bool
   -> Bool
   -> Maybe Text
   -> Browser)
-> Parser Bool
-> Parser
     (Maybe Text
      -> IEElementScrollBehavior
      -> Bool
      -> Bool
      -> Bool
      -> Integer
      -> Maybe String
      -> IELogLevel
      -> Maybe Text
      -> Maybe Text
      -> Bool
      -> Bool
      -> Maybe Text
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"ignoreZoomSettings" Bool
False
                          Parser
  (Maybe Text
   -> IEElementScrollBehavior
   -> Bool
   -> Bool
   -> Bool
   -> Integer
   -> Maybe String
   -> IELogLevel
   -> Maybe Text
   -> Maybe Text
   -> Bool
   -> Bool
   -> Maybe Text
   -> Browser)
-> Parser (Maybe Text)
-> Parser
     (IEElementScrollBehavior
      -> Bool
      -> Bool
      -> Bool
      -> Integer
      -> Maybe String
      -> IELogLevel
      -> Maybe Text
      -> Maybe Text
      -> Bool
      -> Bool
      -> Maybe Text
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Text -> Parser (Maybe Text)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"initialBrowserUrl" Maybe Text
forall a. Maybe a
Nothing
                          Parser
  (IEElementScrollBehavior
   -> Bool
   -> Bool
   -> Bool
   -> Integer
   -> Maybe String
   -> IELogLevel
   -> Maybe Text
   -> Maybe Text
   -> Bool
   -> Bool
   -> Maybe Text
   -> Browser)
-> Parser IEElementScrollBehavior
-> Parser
     (Bool
      -> Bool
      -> Bool
      -> Integer
      -> Maybe String
      -> IELogLevel
      -> Maybe Text
      -> Maybe Text
      -> Bool
      -> Bool
      -> Maybe Text
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> IEElementScrollBehavior -> Parser IEElementScrollBehavior
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"elementScrollBehavior" IEElementScrollBehavior
forall a. Default a => a
def
                          Parser
  (Bool
   -> Bool
   -> Bool
   -> Integer
   -> Maybe String
   -> IELogLevel
   -> Maybe Text
   -> Maybe Text
   -> Bool
   -> Bool
   -> Maybe Text
   -> Browser)
-> Parser Bool
-> Parser
     (Bool
      -> Bool
      -> Integer
      -> Maybe String
      -> IELogLevel
      -> Maybe Text
      -> Maybe Text
      -> Bool
      -> Bool
      -> Maybe Text
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"enablePersistentHover" Bool
True
                          Parser
  (Bool
   -> Bool
   -> Integer
   -> Maybe String
   -> IELogLevel
   -> Maybe Text
   -> Maybe Text
   -> Bool
   -> Bool
   -> Maybe Text
   -> Browser)
-> Parser Bool
-> Parser
     (Bool
      -> Integer
      -> Maybe String
      -> IELogLevel
      -> Maybe Text
      -> Maybe Text
      -> Bool
      -> Bool
      -> Maybe Text
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"enableElementCacheCleanup" Bool
True
                          Parser
  (Bool
   -> Integer
   -> Maybe String
   -> IELogLevel
   -> Maybe Text
   -> Maybe Text
   -> Bool
   -> Bool
   -> Maybe Text
   -> Browser)
-> Parser Bool
-> Parser
     (Integer
      -> Maybe String
      -> IELogLevel
      -> Maybe Text
      -> Maybe Text
      -> Bool
      -> Bool
      -> Maybe Text
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"requireWindowFocus" Bool
False
                          Parser
  (Integer
   -> Maybe String
   -> IELogLevel
   -> Maybe Text
   -> Maybe Text
   -> Bool
   -> Bool
   -> Maybe Text
   -> Browser)
-> Parser Integer
-> Parser
     (Maybe String
      -> IELogLevel
      -> Maybe Text
      -> Maybe Text
      -> Bool
      -> Bool
      -> Maybe Text
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Integer -> Parser Integer
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"browserAttachTimeout" Integer
0
                          Parser
  (Maybe String
   -> IELogLevel
   -> Maybe Text
   -> Maybe Text
   -> Bool
   -> Bool
   -> Maybe Text
   -> Browser)
-> Parser (Maybe String)
-> Parser
     (IELogLevel
      -> Maybe Text
      -> Maybe Text
      -> Bool
      -> Bool
      -> Maybe Text
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"logFile" Maybe String
forall a. Maybe a
Nothing
                          Parser
  (IELogLevel
   -> Maybe Text
   -> Maybe Text
   -> Bool
   -> Bool
   -> Maybe Text
   -> Browser)
-> Parser IELogLevel
-> Parser
     (Maybe Text -> Maybe Text -> Bool -> Bool -> Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> IELogLevel -> Parser IELogLevel
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"logLevel" IELogLevel
forall a. Default a => a
def
                          Parser
  (Maybe Text -> Maybe Text -> Bool -> Bool -> Maybe Text -> Browser)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Bool -> Bool -> Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Text -> Parser (Maybe Text)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"host" Maybe Text
forall a. Maybe a
Nothing
                          Parser (Maybe Text -> Bool -> Bool -> Maybe Text -> Browser)
-> Parser (Maybe Text)
-> Parser (Bool -> Bool -> Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Text -> Parser (Maybe Text)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"extractPath" Maybe Text
forall a. Maybe a
Nothing
                          Parser (Bool -> Bool -> Maybe Text -> Browser)
-> Parser Bool -> Parser (Bool -> Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"silent" Bool
False
                          Parser (Bool -> Maybe Text -> Browser)
-> Parser Bool -> Parser (Maybe Text -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"forceCreateProcess" Bool
False
                          Parser (Maybe Text -> Browser)
-> Parser (Maybe Text) -> Parser Browser
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Text -> Parser (Maybe Text)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"internetExplorerSwitches" Maybe Text
forall a. Maybe a
Nothing
              Opera {} -> Maybe String
-> Maybe String
-> Bool
-> Bool
-> Bool
-> Maybe Int
-> Maybe String
-> Maybe Word16
-> Maybe String
-> Maybe String
-> Maybe String
-> LogLevel
-> Browser
Opera (Maybe String
 -> Maybe String
 -> Bool
 -> Bool
 -> Bool
 -> Maybe Int
 -> Maybe String
 -> Maybe Word16
 -> Maybe String
 -> Maybe String
 -> Maybe String
 -> LogLevel
 -> Browser)
-> Parser (Maybe String)
-> Parser
     (Maybe String
      -> Bool
      -> Bool
      -> Bool
      -> Maybe Int
      -> Maybe String
      -> Maybe Word16
      -> Maybe String
      -> Maybe String
      -> Maybe String
      -> LogLevel
      -> Browser)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.binary" Maybe String
forall a. Maybe a
Nothing
                                Parser
  (Maybe String
   -> Bool
   -> Bool
   -> Bool
   -> Maybe Int
   -> Maybe String
   -> Maybe Word16
   -> Maybe String
   -> Maybe String
   -> Maybe String
   -> LogLevel
   -> Browser)
-> Parser (Maybe String)
-> Parser
     (Bool
      -> Bool
      -> Bool
      -> Maybe Int
      -> Maybe String
      -> Maybe Word16
      -> Maybe String
      -> Maybe String
      -> Maybe String
      -> LogLevel
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.product" Maybe String
forall a. Maybe a
Nothing
                                Parser
  (Bool
   -> Bool
   -> Bool
   -> Maybe Int
   -> Maybe String
   -> Maybe Word16
   -> Maybe String
   -> Maybe String
   -> Maybe String
   -> LogLevel
   -> Browser)
-> Parser Bool
-> Parser
     (Bool
      -> Bool
      -> Maybe Int
      -> Maybe String
      -> Maybe Word16
      -> Maybe String
      -> Maybe String
      -> Maybe String
      -> LogLevel
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.no_quit" Bool
False
                                Parser
  (Bool
   -> Bool
   -> Maybe Int
   -> Maybe String
   -> Maybe Word16
   -> Maybe String
   -> Maybe String
   -> Maybe String
   -> LogLevel
   -> Browser)
-> Parser Bool
-> Parser
     (Bool
      -> Maybe Int
      -> Maybe String
      -> Maybe Word16
      -> Maybe String
      -> Maybe String
      -> Maybe String
      -> LogLevel
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.autostart" Bool
True
                                Parser
  (Bool
   -> Maybe Int
   -> Maybe String
   -> Maybe Word16
   -> Maybe String
   -> Maybe String
   -> Maybe String
   -> LogLevel
   -> Browser)
-> Parser Bool
-> Parser
     (Maybe Int
      -> Maybe String
      -> Maybe Word16
      -> Maybe String
      -> Maybe String
      -> Maybe String
      -> LogLevel
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> Parser Bool
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.idle" Bool
False
                                Parser
  (Maybe Int
   -> Maybe String
   -> Maybe Word16
   -> Maybe String
   -> Maybe String
   -> Maybe String
   -> LogLevel
   -> Browser)
-> Parser (Maybe Int)
-> Parser
     (Maybe String
      -> Maybe Word16
      -> Maybe String
      -> Maybe String
      -> Maybe String
      -> LogLevel
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Int -> Parser (Maybe Int)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.display" Maybe Int
forall a. Maybe a
Nothing
                                Parser
  (Maybe String
   -> Maybe Word16
   -> Maybe String
   -> Maybe String
   -> Maybe String
   -> LogLevel
   -> Browser)
-> Parser (Maybe String)
-> Parser
     (Maybe Word16
      -> Maybe String
      -> Maybe String
      -> Maybe String
      -> LogLevel
      -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.launcher" Maybe String
forall a. Maybe a
Nothing
                                Parser
  (Maybe Word16
   -> Maybe String
   -> Maybe String
   -> Maybe String
   -> LogLevel
   -> Browser)
-> Parser (Maybe Word16)
-> Parser
     (Maybe String
      -> Maybe String -> Maybe String -> LogLevel -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe Word16 -> Parser (Maybe Word16)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.port" (Word16 -> Maybe Word16
forall a. a -> Maybe a
Just Word16
0)
                                Parser
  (Maybe String
   -> Maybe String -> Maybe String -> LogLevel -> Browser)
-> Parser (Maybe String)
-> Parser (Maybe String -> Maybe String -> LogLevel -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.host" Maybe String
forall a. Maybe a
Nothing
                                Parser (Maybe String -> Maybe String -> LogLevel -> Browser)
-> Parser (Maybe String)
-> Parser (Maybe String -> LogLevel -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.arguments" Maybe String
forall a. Maybe a
Nothing
                                Parser (Maybe String -> LogLevel -> Browser)
-> Parser (Maybe String) -> Parser (LogLevel -> Browser)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Maybe String -> Parser (Maybe String)
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.logging.file" Maybe String
forall a. Maybe a
Nothing
                                Parser (LogLevel -> Browser) -> Parser LogLevel -> Parser Browser
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> LogLevel -> Parser LogLevel
forall a. FromJSON a => Text -> a -> Parser a
opt Text
"opera.logging.level" LogLevel
forall a. Default a => a
def
              Browser
_ -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
browser

  parseJSON Value
v = String -> Value -> Parser Capabilities
forall a. String -> Value -> Parser a
typeMismatch String
"Capabilities" Value
v

-- |This constructor simultaneously specifies which browser the session will
-- use, while also providing browser-specific configuration. Default
-- configuration is provided for each browser by 'firefox', 'chrome', 'opera',
-- 'ie', etc.
--
-- This library uses 'firefox' as its 'Default' browser configuration, when no
-- browser choice is specified.
data Browser = Firefox { -- |The firefox profile to use. If Nothing,
                         -- a default temporary profile is automatically created
                         -- and used.
                         Browser -> Maybe (PreparedProfile Firefox)
ffProfile :: Maybe (PreparedProfile Firefox)
                         -- |Firefox logging preference
                       , Browser -> LogLevel
ffLogPref :: LogLevel
                         -- |Server-side path to Firefox binary. If Nothing,
                         -- use a sensible system-based default.
                       , Browser -> Maybe String
ffBinary :: Maybe FilePath
                         -- |Available after Firefox 52, and required only for Firefox
                         -- geckodriver. Indicates whether untrusted and self-signed TLS
                         -- certificates are implicitly trusted on navigation for the
                         -- duration of the session.
                       , Browser -> Maybe Bool
ffAcceptInsecureCerts :: Maybe Bool
                       }
             | Chrome { -- |Version of the Chrome Webdriver server server to use
                        --
                        -- for more information on chromedriver see
                        -- <https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver>
                        Browser -> Maybe String
chromeDriverVersion :: Maybe String
                        -- |Server-side path to Chrome binary. If Nothing,
                        -- use a sensible system-based default.
                      , Browser -> Maybe String
chromeBinary :: Maybe FilePath
                        -- |A list of command-line options to pass to the
                        -- Chrome binary.
                      , Browser -> [String]
chromeOptions :: [String]
                        -- |A list of extensions to use.
                      , Browser -> [ChromeExtension]
chromeExtensions :: [ChromeExtension]
                        -- | Experimental options not yet exposed through a standard API.
                      , Browser -> Object
chromeExperimentalOptions :: Object
                      }
             | IE { -- |Whether to skip the protected mode check. If set, tests
                    -- may become flaky, unresponsive, or browsers may hang. If
                    -- not set, and protected mode settings are not the same for
                    -- all zones, an exception will be thrown on driver
                    -- construction.
                    Browser -> Bool
ieIgnoreProtectedModeSettings :: Bool
                    -- |Indicates whether to skip the check that the browser's zoom
                    -- level is set to 100%. Value is set to false by default.
                  , Browser -> Bool
ieIgnoreZoomSetting :: Bool
                    -- |Allows the user to specify the initial URL loaded when IE
                    -- starts. Intended to be used with ignoreProtectedModeSettings
                    -- to allow the user to initialize IE in the proper Protected Mode
                    -- zone. Using this capability may cause browser instability or
                    -- flaky and unresponsive code. Only \"best effort\" support is
                    -- provided when using this capability.
                  , Browser -> Maybe Text
ieInitialBrowserUrl :: Maybe Text
                    -- |Allows the user to specify whether elements are scrolled into
                    -- the viewport for interaction to align with the top or bottom
                    -- of the viewport. The default value is to align with the top of
                    -- the viewport.
                  , Browser -> IEElementScrollBehavior
ieElementScrollBehavior :: IEElementScrollBehavior
                    -- |Determines whether persistent hovering is enabled (true by
                    -- default). Persistent hovering is achieved by continuously firing
                    -- mouse over events at the last location the mouse cursor has been
                    -- moved to.
                  , Browser -> Bool
ieEnablePersistentHover :: Bool
                    -- |Determines whether the driver should attempt to remove obsolete
                    -- elements from the element cache on page navigation (true by
                    -- default). This is to help manage the IE driver's memory footprint
                    -- , removing references to invalid elements.
                  , Browser -> Bool
ieEnableElementCacheCleanup :: Bool
                    -- |Determines whether to require that the IE window have focus
                    -- before performing any user interaction operations (mouse or
                    -- keyboard events). This capability is false by default, but
                    -- delivers much more accurate native events interactions.
                  , Browser -> Bool
ieRequireWindowFocus :: Bool
                    -- |The timeout, in milliseconds, that the driver will attempt to
                    -- locate and attach to a newly opened instance of Internet Explorer
                    -- . The default is zero, which indicates waiting indefinitely.
                  , Browser -> Integer
ieBrowserAttachTimeout :: Integer
                    -- |The path to file where server should write log messages to.
                    -- By default it writes to stdout.
                  , Browser -> Maybe String
ieLogFile :: Maybe FilePath
                    -- |The log level used by the server. Defaults to 'IELogFatal'
                  , Browser -> IELogLevel
ieLogLevel :: IELogLevel
                    -- |The address of the host adapter on which the server will listen
                    -- for commands.
                  , Browser -> Maybe Text
ieHost :: Maybe Text
                    -- |The path to the directory used to extract supporting files used
                    -- by the server. Defaults to the TEMP directory if not specified.
                  , Browser -> Maybe Text
ieExtractPath :: Maybe Text
                    -- |Suppresses diagnostic output when the server is started.
                  , Browser -> Bool
ieSilent :: Bool
                    -- |Forces launching Internet Explorer using the CreateProcess API.
                    -- If this option is not specified, IE is launched using the
                    -- IELaunchURL, if it is available. For IE 8 and above, this option
                    -- requires the TabProcGrowth registry value to be set to 0.
                  , Browser -> Bool
ieForceCreateProcess :: Bool
                    -- |Specifies command-line switches with which to launch Internet
                    -- Explorer. This is only valid when used with the
                    -- forceCreateProcess.
                  , Browser -> Maybe Text
ieSwitches :: Maybe Text
                  }
             | Opera { -- |Server-side path to the Opera binary
                       Browser -> Maybe String
operaBinary    :: Maybe FilePath
                     --, operaNoRestart :: Maybe Bool
                       -- |Which Opera product we're using, e.g. \"desktop\",
                       -- \"core\"
                     , Browser -> Maybe String
operaProduct   :: Maybe String
                       -- |Whether the Opera instance should stay open after
                       -- we close the session. If false, closing the session
                       -- closes the browser.
                     , Browser -> Bool
operaDetach    :: Bool
                       -- |Whether to auto-start the Opera binary. If false,
                       -- OperaDriver will wait for a connection from the
                       -- browser. By default this is True.
                     , Browser -> Bool
operaAutoStart :: Bool
                       -- |Whether to use Opera's alternative implicit wait
                       -- implementation. It will use an in-browser heuristic
                       -- to guess when a page has finished loading. This
                       -- feature is experimental, and disabled by default.
                     , Browser -> Bool
operaIdle      :: Bool
                       -- |(*nix only) which X display to use.
                     , Browser -> Maybe Int
operaDisplay   :: Maybe Int
                     --, operaProfile   :: Maybe (PreparedProfile Opera)
                       -- |Path to the launcher binary to use. The launcher
                       -- is a gateway between OperaDriver and the Opera
                       -- browser. If Nothing, OperaDriver will use the
                       -- launcher supplied with the package.
                     , Browser -> Maybe String
operaLauncher  :: Maybe FilePath
                       -- |The port we should use to connect to Opera. If Just 0
                       -- , use a random port. If Nothing, use the default
                       -- Opera port. The default 'opera' constructor uses
                       -- Just 0, since Nothing is likely to cause "address
                       -- already in use" errors.
                     , Browser -> Maybe Word16
operaPort      :: Maybe Word16
                       -- |The host Opera should connect to. Unless you're
                       -- starting Opera manually you won't need this.
                     , Browser -> Maybe String
operaHost      :: Maybe String
                       -- |Command-line arguments to pass to Opera.
                     , Browser -> Maybe String
operaOptions   :: Maybe String
                       -- |Where to send the log output. If Nothing, logging is
                       -- disabled.
                     , Browser -> Maybe String
operaLogFile   :: Maybe FilePath
                       -- |Log level preference. Defaults to 'LogInfo'
                     , Browser -> LogLevel
operaLogPref   :: LogLevel
                     }

             | Phantomjs { Browser -> Maybe String
phantomjsBinary  :: Maybe FilePath
                         , Browser -> [String]
phantomjsOptions :: [String]
                         }

             | HTMLUnit
             | IPhone
             | IPad
             | Android
             -- |some other browser, specified by a string name
             | Browser Text
             deriving (Browser -> Browser -> Bool
(Browser -> Browser -> Bool)
-> (Browser -> Browser -> Bool) -> Eq Browser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Browser -> Browser -> Bool
== :: Browser -> Browser -> Bool
$c/= :: Browser -> Browser -> Bool
/= :: Browser -> Browser -> Bool
Eq, Int -> Browser -> ShowS
[Browser] -> ShowS
Browser -> String
(Int -> Browser -> ShowS)
-> (Browser -> String) -> ([Browser] -> ShowS) -> Show Browser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Browser -> ShowS
showsPrec :: Int -> Browser -> ShowS
$cshow :: Browser -> String
show :: Browser -> String
$cshowList :: [Browser] -> ShowS
showList :: [Browser] -> ShowS
Show)

instance Default Browser where
  def :: Browser
def = Browser
firefox


instance ToJSON Browser where
  toJSON :: Browser -> Value
toJSON Firefox {}   = Text -> Value
String Text
"firefox"
  toJSON Chrome {}    = Text -> Value
String Text
"chrome"
  toJSON Opera {}     = Text -> Value
String Text
"opera"
  toJSON IE {}        = Text -> Value
String Text
"internet explorer"
  toJSON Phantomjs {} = Text -> Value
String Text
"phantomjs"
  toJSON (Browser Text
b)  = Text -> Value
String Text
b
  toJSON Browser
b            = Text -> Value
String (Text -> Value) -> (Browser -> Text) -> Browser -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
toLower (Text -> Text) -> (Browser -> Text) -> Browser -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall a. IsString a => String -> a
fromString (String -> Text) -> (Browser -> String) -> Browser -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Browser -> String
forall a. Show a => a -> String
show (Browser -> Value) -> Browser -> Value
forall a b. (a -> b) -> a -> b
$ Browser
b

instance FromJSON Browser where
  parseJSON :: Value -> Parser Browser
parseJSON (String Text
jStr) = case Text -> Text
toLower Text
jStr of
    Text
"firefox"           -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
firefox
    Text
"chrome"            -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
chrome
    Text
"internet explorer" -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
ie
    Text
"opera"             -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
opera
    Text
"phantomjs"         -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
phantomjs
    -- "safari"            -> return safari
    Text
"iphone"            -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
iPhone
    Text
"ipad"              -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
iPad
    Text
"android"           -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
android
    Text
"htmlunit"          -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Browser
htmlUnit
    Text
other               -> Browser -> Parser Browser
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Browser
Browser Text
other)
  parseJSON Value
v = String -> Value -> Parser Browser
forall a. String -> Value -> Parser a
typeMismatch String
"Browser" Value
v


-- |Default Firefox settings. All Maybe fields are set to Nothing. ffLogPref
-- is set to 'LogInfo'.
firefox :: Browser
firefox :: Browser
firefox = Maybe (PreparedProfile Firefox)
-> LogLevel -> Maybe String -> Maybe Bool -> Browser
Firefox Maybe (PreparedProfile Firefox)
forall a. Maybe a
Nothing LogLevel
forall a. Default a => a
def Maybe String
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing

-- |Default Chrome settings. All Maybe fields are set to Nothing, no options are
-- specified, and no extensions are used.
chrome :: Browser
chrome :: Browser
chrome = Maybe String
-> Maybe String
-> [String]
-> [ChromeExtension]
-> Object
-> Browser
Chrome Maybe String
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing [] [] Object
forall v. KeyMap v
HM.empty

-- |Default IE settings. See the 'IE' constructor for more details on
-- individual defaults
ie :: Browser
ie :: Browser
ie = IE { ieIgnoreProtectedModeSettings :: Bool
ieIgnoreProtectedModeSettings = Bool
True
        , ieIgnoreZoomSetting :: Bool
ieIgnoreZoomSetting = Bool
False
        , ieInitialBrowserUrl :: Maybe Text
ieInitialBrowserUrl = Maybe Text
forall a. Maybe a
Nothing
        , ieElementScrollBehavior :: IEElementScrollBehavior
ieElementScrollBehavior = IEElementScrollBehavior
forall a. Default a => a
def
        , ieEnablePersistentHover :: Bool
ieEnablePersistentHover = Bool
True
        , ieEnableElementCacheCleanup :: Bool
ieEnableElementCacheCleanup = Bool
True
        , ieRequireWindowFocus :: Bool
ieRequireWindowFocus = Bool
False
        , ieBrowserAttachTimeout :: Integer
ieBrowserAttachTimeout = Integer
0
        , ieLogFile :: Maybe String
ieLogFile = Maybe String
forall a. Maybe a
Nothing
        , ieLogLevel :: IELogLevel
ieLogLevel = IELogLevel
forall a. Default a => a
def
        , ieHost :: Maybe Text
ieHost = Maybe Text
forall a. Maybe a
Nothing
        , ieExtractPath :: Maybe Text
ieExtractPath = Maybe Text
forall a. Maybe a
Nothing
        , ieSilent :: Bool
ieSilent = Bool
False
        , ieForceCreateProcess :: Bool
ieForceCreateProcess = Bool
False
        , ieSwitches :: Maybe Text
ieSwitches = Maybe Text
forall a. Maybe a
Nothing
        }

-- |Default Opera settings. See the 'Opera' constructor for more details on
-- individual defaults.
opera :: Browser
opera :: Browser
opera = Opera { operaBinary :: Maybe String
operaBinary = Maybe String
forall a. Maybe a
Nothing
              --, operaNoRestart = Nothing
              , operaProduct :: Maybe String
operaProduct = Maybe String
forall a. Maybe a
Nothing
              , operaDetach :: Bool
operaDetach = Bool
False
              , operaAutoStart :: Bool
operaAutoStart = Bool
True
              , operaDisplay :: Maybe Int
operaDisplay = Maybe Int
forall a. Maybe a
Nothing
              , operaIdle :: Bool
operaIdle = Bool
False
--              , operaProfile = Nothing
              , operaLauncher :: Maybe String
operaLauncher = Maybe String
forall a. Maybe a
Nothing
              , operaHost :: Maybe String
operaHost = Maybe String
forall a. Maybe a
Nothing
              , operaPort :: Maybe Word16
operaPort = Word16 -> Maybe Word16
forall a. a -> Maybe a
Just Word16
0
              , operaOptions :: Maybe String
operaOptions = Maybe String
forall a. Maybe a
Nothing
              , operaLogFile :: Maybe String
operaLogFile = Maybe String
forall a. Maybe a
Nothing
              , operaLogPref :: LogLevel
operaLogPref = LogLevel
forall a. Default a => a
def
              }

phantomjs :: Browser
phantomjs :: Browser
phantomjs = Maybe String -> [String] -> Browser
Phantomjs Maybe String
forall a. Maybe a
Nothing []

--safari :: Browser
--safari = Safari

htmlUnit :: Browser
htmlUnit :: Browser
htmlUnit = Browser
HTMLUnit

iPhone :: Browser
iPhone :: Browser
iPhone = Browser
IPhone

iPad :: Browser
iPad :: Browser
iPad = Browser
IPad

android :: Browser
android :: Browser
android = Browser
Android

-- |Represents platform options supported by WebDriver. The value Any represents
-- no preference.
data Platform = Windows | XP | Vista | Mac | Linux | Unix | Any
              deriving (Platform -> Platform -> Bool
(Platform -> Platform -> Bool)
-> (Platform -> Platform -> Bool) -> Eq Platform
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Platform -> Platform -> Bool
== :: Platform -> Platform -> Bool
$c/= :: Platform -> Platform -> Bool
/= :: Platform -> Platform -> Bool
Eq, Int -> Platform -> ShowS
[Platform] -> ShowS
Platform -> String
(Int -> Platform -> ShowS)
-> (Platform -> String) -> ([Platform] -> ShowS) -> Show Platform
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Platform -> ShowS
showsPrec :: Int -> Platform -> ShowS
$cshow :: Platform -> String
show :: Platform -> String
$cshowList :: [Platform] -> ShowS
showList :: [Platform] -> ShowS
Show, Eq Platform
Eq Platform =>
(Platform -> Platform -> Ordering)
-> (Platform -> Platform -> Bool)
-> (Platform -> Platform -> Bool)
-> (Platform -> Platform -> Bool)
-> (Platform -> Platform -> Bool)
-> (Platform -> Platform -> Platform)
-> (Platform -> Platform -> Platform)
-> Ord Platform
Platform -> Platform -> Bool
Platform -> Platform -> Ordering
Platform -> Platform -> Platform
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Platform -> Platform -> Ordering
compare :: Platform -> Platform -> Ordering
$c< :: Platform -> Platform -> Bool
< :: Platform -> Platform -> Bool
$c<= :: Platform -> Platform -> Bool
<= :: Platform -> Platform -> Bool
$c> :: Platform -> Platform -> Bool
> :: Platform -> Platform -> Bool
$c>= :: Platform -> Platform -> Bool
>= :: Platform -> Platform -> Bool
$cmax :: Platform -> Platform -> Platform
max :: Platform -> Platform -> Platform
$cmin :: Platform -> Platform -> Platform
min :: Platform -> Platform -> Platform
Ord, Platform
Platform -> Platform -> Bounded Platform
forall a. a -> a -> Bounded a
$cminBound :: Platform
minBound :: Platform
$cmaxBound :: Platform
maxBound :: Platform
Bounded, Int -> Platform
Platform -> Int
Platform -> [Platform]
Platform -> Platform
Platform -> Platform -> [Platform]
Platform -> Platform -> Platform -> [Platform]
(Platform -> Platform)
-> (Platform -> Platform)
-> (Int -> Platform)
-> (Platform -> Int)
-> (Platform -> [Platform])
-> (Platform -> Platform -> [Platform])
-> (Platform -> Platform -> [Platform])
-> (Platform -> Platform -> Platform -> [Platform])
-> Enum Platform
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Platform -> Platform
succ :: Platform -> Platform
$cpred :: Platform -> Platform
pred :: Platform -> Platform
$ctoEnum :: Int -> Platform
toEnum :: Int -> Platform
$cfromEnum :: Platform -> Int
fromEnum :: Platform -> Int
$cenumFrom :: Platform -> [Platform]
enumFrom :: Platform -> [Platform]
$cenumFromThen :: Platform -> Platform -> [Platform]
enumFromThen :: Platform -> Platform -> [Platform]
$cenumFromTo :: Platform -> Platform -> [Platform]
enumFromTo :: Platform -> Platform -> [Platform]
$cenumFromThenTo :: Platform -> Platform -> Platform -> [Platform]
enumFromThenTo :: Platform -> Platform -> Platform -> [Platform]
Enum)

instance ToJSON Platform where
  toJSON :: Platform -> Value
toJSON = Text -> Value
String (Text -> Value) -> (Platform -> Text) -> Platform -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
toUpper (Text -> Text) -> (Platform -> Text) -> Platform -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall a. IsString a => String -> a
fromString (String -> Text) -> (Platform -> String) -> Platform -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Platform -> String
forall a. Show a => a -> String
show

instance FromJSON Platform where
  parseJSON :: Value -> Parser Platform
parseJSON (String Text
jStr) = case Text -> Text
toLower Text
jStr of
    Text
"windows" -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Windows
    Text
"xp"      -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
XP
    Text
"vista"   -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Vista
    Text
"mac"     -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Mac
    Text
"linux"   -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Linux
    Text
"unix"    -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Unix
    Text
"any"     -> Platform -> Parser Platform
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Platform
Any
    Text
err -> String -> Parser Platform
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Platform) -> String -> Parser Platform
forall a b. (a -> b) -> a -> b
$ String
"Invalid Platform string " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
err
  parseJSON Value
v = String -> Value -> Parser Platform
forall a. String -> Value -> Parser a
typeMismatch String
"Platform" Value
v

-- |Available settings for the proxy 'Capabilities' field
data ProxyType = NoProxy
               | UseSystemSettings
               | AutoDetect
                 -- |Use a proxy auto-config file specified by URL
               | PAC { ProxyType -> String
autoConfigUrl :: String }
                 -- |Manually specify proxy hosts as hostname:port strings.
                 -- Note that behavior is undefined for empty strings.
               | Manual { ProxyType -> String
ftpProxy  :: String
                        , ProxyType -> String
sslProxy  :: String
                        , ProxyType -> String
httpProxy :: String
                        }
               deriving (ProxyType -> ProxyType -> Bool
(ProxyType -> ProxyType -> Bool)
-> (ProxyType -> ProxyType -> Bool) -> Eq ProxyType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProxyType -> ProxyType -> Bool
== :: ProxyType -> ProxyType -> Bool
$c/= :: ProxyType -> ProxyType -> Bool
/= :: ProxyType -> ProxyType -> Bool
Eq, Int -> ProxyType -> ShowS
[ProxyType] -> ShowS
ProxyType -> String
(Int -> ProxyType -> ShowS)
-> (ProxyType -> String)
-> ([ProxyType] -> ShowS)
-> Show ProxyType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProxyType -> ShowS
showsPrec :: Int -> ProxyType -> ShowS
$cshow :: ProxyType -> String
show :: ProxyType -> String
$cshowList :: [ProxyType] -> ShowS
showList :: [ProxyType] -> ShowS
Show)

instance FromJSON ProxyType where
  parseJSON :: Value -> Parser ProxyType
parseJSON (Object Object
obj) = do
    Text
pTyp <- Text -> Parser Text
forall a. FromJSON a => Text -> Parser a
f Text
"proxyType"
    case Text -> Text
toLower Text
pTyp of
      Text
"direct" -> ProxyType -> Parser ProxyType
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ProxyType
NoProxy
      Text
"system" -> ProxyType -> Parser ProxyType
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ProxyType
UseSystemSettings
      Text
"pac"    -> String -> ProxyType
PAC (String -> ProxyType) -> Parser String -> Parser ProxyType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Parser String
forall a. FromJSON a => Text -> Parser a
f Text
"autoConfigUrl"
      Text
"manual" -> String -> String -> String -> ProxyType
Manual (String -> String -> String -> ProxyType)
-> Parser String -> Parser (String -> String -> ProxyType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Parser String
forall a. FromJSON a => Text -> Parser a
f Text
"ftpProxy"
                         Parser (String -> String -> ProxyType)
-> Parser String -> Parser (String -> ProxyType)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser String
forall a. FromJSON a => Text -> Parser a
f Text
"sslProxy"
                         Parser (String -> ProxyType) -> Parser String -> Parser ProxyType
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Parser String
forall a. FromJSON a => Text -> Parser a
f Text
"httpProxy"
      Text
_ -> String -> Parser ProxyType
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ProxyType) -> String -> Parser ProxyType
forall a b. (a -> b) -> a -> b
$ String
"Invalid ProxyType " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
pTyp
    where
      f :: FromJSON a => Text -> Parser a
      f :: forall a. FromJSON a => Text -> Parser a
f = (Object
obj Object -> Key -> Parser a
forall a. FromJSON a => Object -> Key -> Parser a
.:) (Key -> Parser a) -> (Text -> Key) -> Text -> Parser a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Key
fromText
  parseJSON Value
v = String -> Value -> Parser ProxyType
forall a. String -> Value -> Parser a
typeMismatch String
"ProxyType" Value
v

instance ToJSON ProxyType where
  toJSON :: ProxyType -> Value
toJSON ProxyType
pt = [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ case ProxyType
pt of
    ProxyType
NoProxy ->
      [Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"DIRECT" :: String)]
    ProxyType
UseSystemSettings ->
      [Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"SYSTEM" :: String)]
    ProxyType
AutoDetect ->
      [Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"AUTODETECT" :: String)]
    PAC{autoConfigUrl :: ProxyType -> String
autoConfigUrl = String
url} ->
      [Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"PAC" :: String)
      ,Key
"proxyAutoconfigUrl" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
url
      ]
    Manual{ftpProxy :: ProxyType -> String
ftpProxy = String
ftp, sslProxy :: ProxyType -> String
sslProxy = String
ssl, httpProxy :: ProxyType -> String
httpProxy = String
http} ->
      [Key
"proxyType" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (String
"MANUAL" :: String)
      ,Key
"ftpProxy"  Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
ftp
      ,Key
"sslProxy"  Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
ssl
      ,Key
"httpProxy" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
http
      ]

data UnexpectedAlertBehavior = AcceptAlert | DismissAlert | IgnoreAlert
                              deriving (UnexpectedAlertBehavior
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> Bounded UnexpectedAlertBehavior
forall a. a -> a -> Bounded a
$cminBound :: UnexpectedAlertBehavior
minBound :: UnexpectedAlertBehavior
$cmaxBound :: UnexpectedAlertBehavior
maxBound :: UnexpectedAlertBehavior
Bounded, Int -> UnexpectedAlertBehavior
UnexpectedAlertBehavior -> Int
UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
UnexpectedAlertBehavior -> UnexpectedAlertBehavior
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior]
(UnexpectedAlertBehavior -> UnexpectedAlertBehavior)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior)
-> (Int -> UnexpectedAlertBehavior)
-> (UnexpectedAlertBehavior -> Int)
-> (UnexpectedAlertBehavior -> [UnexpectedAlertBehavior])
-> (UnexpectedAlertBehavior
    -> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior])
-> (UnexpectedAlertBehavior
    -> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior])
-> (UnexpectedAlertBehavior
    -> UnexpectedAlertBehavior
    -> UnexpectedAlertBehavior
    -> [UnexpectedAlertBehavior])
-> Enum UnexpectedAlertBehavior
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
succ :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$cpred :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
pred :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$ctoEnum :: Int -> UnexpectedAlertBehavior
toEnum :: Int -> UnexpectedAlertBehavior
$cfromEnum :: UnexpectedAlertBehavior -> Int
fromEnum :: UnexpectedAlertBehavior -> Int
$cenumFrom :: UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
enumFrom :: UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
$cenumFromThen :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
enumFromThen :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
$cenumFromTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
enumFromTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> [UnexpectedAlertBehavior]
$cenumFromThenTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior]
enumFromThenTo :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> UnexpectedAlertBehavior
-> [UnexpectedAlertBehavior]
Enum, UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
(UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> Eq UnexpectedAlertBehavior
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
== :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c/= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
/= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
Eq, Eq UnexpectedAlertBehavior
Eq UnexpectedAlertBehavior =>
(UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool)
-> (UnexpectedAlertBehavior
    -> UnexpectedAlertBehavior -> UnexpectedAlertBehavior)
-> (UnexpectedAlertBehavior
    -> UnexpectedAlertBehavior -> UnexpectedAlertBehavior)
-> Ord UnexpectedAlertBehavior
UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering
UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering
compare :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Ordering
$c< :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
< :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c<= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
<= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c> :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
> :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$c>= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
>= :: UnexpectedAlertBehavior -> UnexpectedAlertBehavior -> Bool
$cmax :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
max :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
$cmin :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
min :: UnexpectedAlertBehavior
-> UnexpectedAlertBehavior -> UnexpectedAlertBehavior
Ord, ReadPrec [UnexpectedAlertBehavior]
ReadPrec UnexpectedAlertBehavior
Int -> ReadS UnexpectedAlertBehavior
ReadS [UnexpectedAlertBehavior]
(Int -> ReadS UnexpectedAlertBehavior)
-> ReadS [UnexpectedAlertBehavior]
-> ReadPrec UnexpectedAlertBehavior
-> ReadPrec [UnexpectedAlertBehavior]
-> Read UnexpectedAlertBehavior
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS UnexpectedAlertBehavior
readsPrec :: Int -> ReadS UnexpectedAlertBehavior
$creadList :: ReadS [UnexpectedAlertBehavior]
readList :: ReadS [UnexpectedAlertBehavior]
$creadPrec :: ReadPrec UnexpectedAlertBehavior
readPrec :: ReadPrec UnexpectedAlertBehavior
$creadListPrec :: ReadPrec [UnexpectedAlertBehavior]
readListPrec :: ReadPrec [UnexpectedAlertBehavior]
Read, Int -> UnexpectedAlertBehavior -> ShowS
[UnexpectedAlertBehavior] -> ShowS
UnexpectedAlertBehavior -> String
(Int -> UnexpectedAlertBehavior -> ShowS)
-> (UnexpectedAlertBehavior -> String)
-> ([UnexpectedAlertBehavior] -> ShowS)
-> Show UnexpectedAlertBehavior
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UnexpectedAlertBehavior -> ShowS
showsPrec :: Int -> UnexpectedAlertBehavior -> ShowS
$cshow :: UnexpectedAlertBehavior -> String
show :: UnexpectedAlertBehavior -> String
$cshowList :: [UnexpectedAlertBehavior] -> ShowS
showList :: [UnexpectedAlertBehavior] -> ShowS
Show)

instance ToJSON UnexpectedAlertBehavior where
  toJSON :: UnexpectedAlertBehavior -> Value
toJSON UnexpectedAlertBehavior
AcceptAlert  = Text -> Value
String Text
"accept"
  toJSON UnexpectedAlertBehavior
DismissAlert = Text -> Value
String Text
"dismiss"
  toJSON UnexpectedAlertBehavior
IgnoreAlert  = Text -> Value
String Text
"ignore"

instance FromJSON UnexpectedAlertBehavior where
  parseJSON :: Value -> Parser UnexpectedAlertBehavior
parseJSON (String Text
s) =
    UnexpectedAlertBehavior -> Parser UnexpectedAlertBehavior
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (UnexpectedAlertBehavior -> Parser UnexpectedAlertBehavior)
-> UnexpectedAlertBehavior -> Parser UnexpectedAlertBehavior
forall a b. (a -> b) -> a -> b
$ case Text
s of
      Text
"accept"  -> UnexpectedAlertBehavior
AcceptAlert
      Text
"dismiss" -> UnexpectedAlertBehavior
DismissAlert
      Text
"ignore"  -> UnexpectedAlertBehavior
IgnoreAlert
      Text
err       -> BadJSON -> UnexpectedAlertBehavior
forall a e. Exception e => e -> a
throw (BadJSON -> UnexpectedAlertBehavior)
-> (String -> BadJSON) -> String -> UnexpectedAlertBehavior
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> BadJSON
BadJSON
                   (String -> UnexpectedAlertBehavior)
-> String -> UnexpectedAlertBehavior
forall a b. (a -> b) -> a -> b
$ String
"Invalid string value for UnexpectedAlertBehavior: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
err
  parseJSON Value
v = String -> Value -> Parser UnexpectedAlertBehavior
forall a. String -> Value -> Parser a
typeMismatch String
"UnexpectedAlertBehavior" Value
v

-- |Indicates a log verbosity level. Used in 'Firefox' and 'Opera' configuration.
data LogLevel = LogOff | LogSevere | LogWarning | LogInfo | LogConfig
              | LogFine | LogFiner | LogFinest | LogDebug | LogAll
             deriving (LogLevel -> LogLevel -> Bool
(LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> Bool) -> Eq LogLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LogLevel -> LogLevel -> Bool
== :: LogLevel -> LogLevel -> Bool
$c/= :: LogLevel -> LogLevel -> Bool
/= :: LogLevel -> LogLevel -> Bool
Eq, Int -> LogLevel -> ShowS
[LogLevel] -> ShowS
LogLevel -> String
(Int -> LogLevel -> ShowS)
-> (LogLevel -> String) -> ([LogLevel] -> ShowS) -> Show LogLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LogLevel -> ShowS
showsPrec :: Int -> LogLevel -> ShowS
$cshow :: LogLevel -> String
show :: LogLevel -> String
$cshowList :: [LogLevel] -> ShowS
showList :: [LogLevel] -> ShowS
Show, ReadPrec [LogLevel]
ReadPrec LogLevel
Int -> ReadS LogLevel
ReadS [LogLevel]
(Int -> ReadS LogLevel)
-> ReadS [LogLevel]
-> ReadPrec LogLevel
-> ReadPrec [LogLevel]
-> Read LogLevel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS LogLevel
readsPrec :: Int -> ReadS LogLevel
$creadList :: ReadS [LogLevel]
readList :: ReadS [LogLevel]
$creadPrec :: ReadPrec LogLevel
readPrec :: ReadPrec LogLevel
$creadListPrec :: ReadPrec [LogLevel]
readListPrec :: ReadPrec [LogLevel]
Read, Eq LogLevel
Eq LogLevel =>
(LogLevel -> LogLevel -> Ordering)
-> (LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> Bool)
-> (LogLevel -> LogLevel -> LogLevel)
-> (LogLevel -> LogLevel -> LogLevel)
-> Ord LogLevel
LogLevel -> LogLevel -> Bool
LogLevel -> LogLevel -> Ordering
LogLevel -> LogLevel -> LogLevel
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: LogLevel -> LogLevel -> Ordering
compare :: LogLevel -> LogLevel -> Ordering
$c< :: LogLevel -> LogLevel -> Bool
< :: LogLevel -> LogLevel -> Bool
$c<= :: LogLevel -> LogLevel -> Bool
<= :: LogLevel -> LogLevel -> Bool
$c> :: LogLevel -> LogLevel -> Bool
> :: LogLevel -> LogLevel -> Bool
$c>= :: LogLevel -> LogLevel -> Bool
>= :: LogLevel -> LogLevel -> Bool
$cmax :: LogLevel -> LogLevel -> LogLevel
max :: LogLevel -> LogLevel -> LogLevel
$cmin :: LogLevel -> LogLevel -> LogLevel
min :: LogLevel -> LogLevel -> LogLevel
Ord, LogLevel
LogLevel -> LogLevel -> Bounded LogLevel
forall a. a -> a -> Bounded a
$cminBound :: LogLevel
minBound :: LogLevel
$cmaxBound :: LogLevel
maxBound :: LogLevel
Bounded, Int -> LogLevel
LogLevel -> Int
LogLevel -> [LogLevel]
LogLevel -> LogLevel
LogLevel -> LogLevel -> [LogLevel]
LogLevel -> LogLevel -> LogLevel -> [LogLevel]
(LogLevel -> LogLevel)
-> (LogLevel -> LogLevel)
-> (Int -> LogLevel)
-> (LogLevel -> Int)
-> (LogLevel -> [LogLevel])
-> (LogLevel -> LogLevel -> [LogLevel])
-> (LogLevel -> LogLevel -> [LogLevel])
-> (LogLevel -> LogLevel -> LogLevel -> [LogLevel])
-> Enum LogLevel
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: LogLevel -> LogLevel
succ :: LogLevel -> LogLevel
$cpred :: LogLevel -> LogLevel
pred :: LogLevel -> LogLevel
$ctoEnum :: Int -> LogLevel
toEnum :: Int -> LogLevel
$cfromEnum :: LogLevel -> Int
fromEnum :: LogLevel -> Int
$cenumFrom :: LogLevel -> [LogLevel]
enumFrom :: LogLevel -> [LogLevel]
$cenumFromThen :: LogLevel -> LogLevel -> [LogLevel]
enumFromThen :: LogLevel -> LogLevel -> [LogLevel]
$cenumFromTo :: LogLevel -> LogLevel -> [LogLevel]
enumFromTo :: LogLevel -> LogLevel -> [LogLevel]
$cenumFromThenTo :: LogLevel -> LogLevel -> LogLevel -> [LogLevel]
enumFromThenTo :: LogLevel -> LogLevel -> LogLevel -> [LogLevel]
Enum)

instance Default LogLevel where
  def :: LogLevel
def = LogLevel
LogInfo

instance ToJSON LogLevel where
  toJSON :: LogLevel -> Value
toJSON LogLevel
p= Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ case LogLevel
p of
    LogLevel
LogOff -> Text
"OFF"
    LogLevel
LogSevere -> Text
"SEVERE"
    LogLevel
LogWarning -> Text
"WARNING"
    LogLevel
LogInfo -> Text
"INFO"
    LogLevel
LogConfig -> Text
"CONFIG"
    LogLevel
LogFine -> Text
"FINE"
    LogLevel
LogFiner -> Text
"FINER"
    LogLevel
LogFinest -> Text
"FINEST"
    LogLevel
LogDebug -> Text
"DEBUG"
    LogLevel
LogAll -> Text
"ALL"

instance FromJSON LogLevel where
  parseJSON :: Value -> Parser LogLevel
parseJSON (String Text
s) = LogLevel -> Parser LogLevel
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (LogLevel -> Parser LogLevel) -> LogLevel -> Parser LogLevel
forall a b. (a -> b) -> a -> b
$ case Text
s of
    Text
"OFF" -> LogLevel
LogOff
    Text
"SEVERE" -> LogLevel
LogSevere
    Text
"WARNING" -> LogLevel
LogWarning
    Text
"INFO" -> LogLevel
LogInfo
    Text
"CONFIG" -> LogLevel
LogConfig
    Text
"FINE" -> LogLevel
LogFine
    Text
"FINER" -> LogLevel
LogFiner
    Text
"FINEST" -> LogLevel
LogFinest
    Text
"DEBUG" -> LogLevel
LogDebug
    Text
"ALL" -> LogLevel
LogAll
    Text
_ -> BadJSON -> LogLevel
forall a e. Exception e => e -> a
throw (BadJSON -> LogLevel) -> (String -> BadJSON) -> String -> LogLevel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> BadJSON
BadJSON (String -> LogLevel) -> String -> LogLevel
forall a b. (a -> b) -> a -> b
$ String
"Invalid logging preference: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
s
  parseJSON Value
other = String -> Value -> Parser LogLevel
forall a. String -> Value -> Parser a
typeMismatch String
"LogLevel" Value
other


-- |Logging levels for Internet Explorer
data IELogLevel = IELogTrace | IELogDebug | IELogInfo | IELogWarn | IELogError
                | IELogFatal
                deriving (IELogLevel -> IELogLevel -> Bool
(IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> Bool) -> Eq IELogLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IELogLevel -> IELogLevel -> Bool
== :: IELogLevel -> IELogLevel -> Bool
$c/= :: IELogLevel -> IELogLevel -> Bool
/= :: IELogLevel -> IELogLevel -> Bool
Eq, Int -> IELogLevel -> ShowS
[IELogLevel] -> ShowS
IELogLevel -> String
(Int -> IELogLevel -> ShowS)
-> (IELogLevel -> String)
-> ([IELogLevel] -> ShowS)
-> Show IELogLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IELogLevel -> ShowS
showsPrec :: Int -> IELogLevel -> ShowS
$cshow :: IELogLevel -> String
show :: IELogLevel -> String
$cshowList :: [IELogLevel] -> ShowS
showList :: [IELogLevel] -> ShowS
Show, ReadPrec [IELogLevel]
ReadPrec IELogLevel
Int -> ReadS IELogLevel
ReadS [IELogLevel]
(Int -> ReadS IELogLevel)
-> ReadS [IELogLevel]
-> ReadPrec IELogLevel
-> ReadPrec [IELogLevel]
-> Read IELogLevel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS IELogLevel
readsPrec :: Int -> ReadS IELogLevel
$creadList :: ReadS [IELogLevel]
readList :: ReadS [IELogLevel]
$creadPrec :: ReadPrec IELogLevel
readPrec :: ReadPrec IELogLevel
$creadListPrec :: ReadPrec [IELogLevel]
readListPrec :: ReadPrec [IELogLevel]
Read, Eq IELogLevel
Eq IELogLevel =>
(IELogLevel -> IELogLevel -> Ordering)
-> (IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> Bool)
-> (IELogLevel -> IELogLevel -> IELogLevel)
-> (IELogLevel -> IELogLevel -> IELogLevel)
-> Ord IELogLevel
IELogLevel -> IELogLevel -> Bool
IELogLevel -> IELogLevel -> Ordering
IELogLevel -> IELogLevel -> IELogLevel
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: IELogLevel -> IELogLevel -> Ordering
compare :: IELogLevel -> IELogLevel -> Ordering
$c< :: IELogLevel -> IELogLevel -> Bool
< :: IELogLevel -> IELogLevel -> Bool
$c<= :: IELogLevel -> IELogLevel -> Bool
<= :: IELogLevel -> IELogLevel -> Bool
$c> :: IELogLevel -> IELogLevel -> Bool
> :: IELogLevel -> IELogLevel -> Bool
$c>= :: IELogLevel -> IELogLevel -> Bool
>= :: IELogLevel -> IELogLevel -> Bool
$cmax :: IELogLevel -> IELogLevel -> IELogLevel
max :: IELogLevel -> IELogLevel -> IELogLevel
$cmin :: IELogLevel -> IELogLevel -> IELogLevel
min :: IELogLevel -> IELogLevel -> IELogLevel
Ord, IELogLevel
IELogLevel -> IELogLevel -> Bounded IELogLevel
forall a. a -> a -> Bounded a
$cminBound :: IELogLevel
minBound :: IELogLevel
$cmaxBound :: IELogLevel
maxBound :: IELogLevel
Bounded, Int -> IELogLevel
IELogLevel -> Int
IELogLevel -> [IELogLevel]
IELogLevel -> IELogLevel
IELogLevel -> IELogLevel -> [IELogLevel]
IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel]
(IELogLevel -> IELogLevel)
-> (IELogLevel -> IELogLevel)
-> (Int -> IELogLevel)
-> (IELogLevel -> Int)
-> (IELogLevel -> [IELogLevel])
-> (IELogLevel -> IELogLevel -> [IELogLevel])
-> (IELogLevel -> IELogLevel -> [IELogLevel])
-> (IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel])
-> Enum IELogLevel
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: IELogLevel -> IELogLevel
succ :: IELogLevel -> IELogLevel
$cpred :: IELogLevel -> IELogLevel
pred :: IELogLevel -> IELogLevel
$ctoEnum :: Int -> IELogLevel
toEnum :: Int -> IELogLevel
$cfromEnum :: IELogLevel -> Int
fromEnum :: IELogLevel -> Int
$cenumFrom :: IELogLevel -> [IELogLevel]
enumFrom :: IELogLevel -> [IELogLevel]
$cenumFromThen :: IELogLevel -> IELogLevel -> [IELogLevel]
enumFromThen :: IELogLevel -> IELogLevel -> [IELogLevel]
$cenumFromTo :: IELogLevel -> IELogLevel -> [IELogLevel]
enumFromTo :: IELogLevel -> IELogLevel -> [IELogLevel]
$cenumFromThenTo :: IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel]
enumFromThenTo :: IELogLevel -> IELogLevel -> IELogLevel -> [IELogLevel]
Enum)

instance Default IELogLevel where
  def :: IELogLevel
def = IELogLevel
IELogFatal


instance ToJSON IELogLevel where
  toJSON :: IELogLevel -> Value
toJSON IELogLevel
p= Text -> Value
String (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ case IELogLevel
p of
    IELogLevel
IELogTrace -> Text
"TRACE"
    IELogLevel
IELogDebug -> Text
"DEBUG"
    IELogLevel
IELogInfo -> Text
"INFO"
    IELogLevel
IELogWarn -> Text
"WARN"
    IELogLevel
IELogError -> Text
"ERROR"
    IELogLevel
IELogFatal -> Text
"FATAL"

instance FromJSON IELogLevel where
  parseJSON :: Value -> Parser IELogLevel
parseJSON (String Text
s) = IELogLevel -> Parser IELogLevel
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (IELogLevel -> Parser IELogLevel)
-> IELogLevel -> Parser IELogLevel
forall a b. (a -> b) -> a -> b
$ case Text
s of
    Text
"TRACE" -> IELogLevel
IELogTrace
    Text
"DEBIG" -> IELogLevel
IELogDebug
    Text
"INFO"  -> IELogLevel
IELogInfo
    Text
"WARN"  -> IELogLevel
IELogWarn
    Text
"ERROR" -> IELogLevel
IELogError
    Text
"FATAL" -> IELogLevel
IELogFatal
    Text
_ -> BadJSON -> IELogLevel
forall a e. Exception e => e -> a
throw (BadJSON -> IELogLevel)
-> (String -> BadJSON) -> String -> IELogLevel
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> BadJSON
BadJSON (String -> IELogLevel) -> String -> IELogLevel
forall a b. (a -> b) -> a -> b
$ String
"Invalid logging preference: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
forall a. Show a => a -> String
show Text
s
  parseJSON Value
other = String -> Value -> Parser IELogLevel
forall a. String -> Value -> Parser a
typeMismatch String
"IELogLevel" Value
other

-- |Specifies how elements scroll into the viewport. (see 'ieElementScrollBehavior')
data IEElementScrollBehavior = AlignTop | AlignBottom
                             deriving (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
(IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> Eq IEElementScrollBehavior
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
== :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c/= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
/= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
Eq, Eq IEElementScrollBehavior
Eq IEElementScrollBehavior =>
(IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior -> IEElementScrollBehavior -> Bool)
-> (IEElementScrollBehavior
    -> IEElementScrollBehavior -> IEElementScrollBehavior)
-> (IEElementScrollBehavior
    -> IEElementScrollBehavior -> IEElementScrollBehavior)
-> Ord IEElementScrollBehavior
IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering
IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering
compare :: IEElementScrollBehavior -> IEElementScrollBehavior -> Ordering
$c< :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
< :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c<= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
<= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c> :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
> :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$c>= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
>= :: IEElementScrollBehavior -> IEElementScrollBehavior -> Bool
$cmax :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
max :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
$cmin :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
min :: IEElementScrollBehavior
-> IEElementScrollBehavior -> IEElementScrollBehavior
Ord, Int -> IEElementScrollBehavior -> ShowS
[IEElementScrollBehavior] -> ShowS
IEElementScrollBehavior -> String
(Int -> IEElementScrollBehavior -> ShowS)
-> (IEElementScrollBehavior -> String)
-> ([IEElementScrollBehavior] -> ShowS)
-> Show IEElementScrollBehavior
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IEElementScrollBehavior -> ShowS
showsPrec :: Int -> IEElementScrollBehavior -> ShowS
$cshow :: IEElementScrollBehavior -> String
show :: IEElementScrollBehavior -> String
$cshowList :: [IEElementScrollBehavior] -> ShowS
showList :: [IEElementScrollBehavior] -> ShowS
Show, ReadPrec [IEElementScrollBehavior]
ReadPrec IEElementScrollBehavior
Int -> ReadS IEElementScrollBehavior
ReadS [IEElementScrollBehavior]
(Int -> ReadS IEElementScrollBehavior)
-> ReadS [IEElementScrollBehavior]
-> ReadPrec IEElementScrollBehavior
-> ReadPrec [IEElementScrollBehavior]
-> Read IEElementScrollBehavior
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS IEElementScrollBehavior
readsPrec :: Int -> ReadS IEElementScrollBehavior
$creadList :: ReadS [IEElementScrollBehavior]
readList :: ReadS [IEElementScrollBehavior]
$creadPrec :: ReadPrec IEElementScrollBehavior
readPrec :: ReadPrec IEElementScrollBehavior
$creadListPrec :: ReadPrec [IEElementScrollBehavior]
readListPrec :: ReadPrec [IEElementScrollBehavior]
Read, Int -> IEElementScrollBehavior
IEElementScrollBehavior -> Int
IEElementScrollBehavior -> [IEElementScrollBehavior]
IEElementScrollBehavior -> IEElementScrollBehavior
IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior]
(IEElementScrollBehavior -> IEElementScrollBehavior)
-> (IEElementScrollBehavior -> IEElementScrollBehavior)
-> (Int -> IEElementScrollBehavior)
-> (IEElementScrollBehavior -> Int)
-> (IEElementScrollBehavior -> [IEElementScrollBehavior])
-> (IEElementScrollBehavior
    -> IEElementScrollBehavior -> [IEElementScrollBehavior])
-> (IEElementScrollBehavior
    -> IEElementScrollBehavior -> [IEElementScrollBehavior])
-> (IEElementScrollBehavior
    -> IEElementScrollBehavior
    -> IEElementScrollBehavior
    -> [IEElementScrollBehavior])
-> Enum IEElementScrollBehavior
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: IEElementScrollBehavior -> IEElementScrollBehavior
succ :: IEElementScrollBehavior -> IEElementScrollBehavior
$cpred :: IEElementScrollBehavior -> IEElementScrollBehavior
pred :: IEElementScrollBehavior -> IEElementScrollBehavior
$ctoEnum :: Int -> IEElementScrollBehavior
toEnum :: Int -> IEElementScrollBehavior
$cfromEnum :: IEElementScrollBehavior -> Int
fromEnum :: IEElementScrollBehavior -> Int
$cenumFrom :: IEElementScrollBehavior -> [IEElementScrollBehavior]
enumFrom :: IEElementScrollBehavior -> [IEElementScrollBehavior]
$cenumFromThen :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
enumFromThen :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
$cenumFromTo :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
enumFromTo :: IEElementScrollBehavior
-> IEElementScrollBehavior -> [IEElementScrollBehavior]
$cenumFromThenTo :: IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior]
enumFromThenTo :: IEElementScrollBehavior
-> IEElementScrollBehavior
-> IEElementScrollBehavior
-> [IEElementScrollBehavior]
Enum, IEElementScrollBehavior
IEElementScrollBehavior
-> IEElementScrollBehavior -> Bounded IEElementScrollBehavior
forall a. a -> a -> Bounded a
$cminBound :: IEElementScrollBehavior
minBound :: IEElementScrollBehavior
$cmaxBound :: IEElementScrollBehavior
maxBound :: IEElementScrollBehavior
Bounded)

instance Default IEElementScrollBehavior where
  def :: IEElementScrollBehavior
def = IEElementScrollBehavior
AlignTop

instance ToJSON IEElementScrollBehavior where
  toJSON :: IEElementScrollBehavior -> Value
toJSON IEElementScrollBehavior
AlignTop    = Int -> Value
forall a. ToJSON a => a -> Value
toJSON (Int
0 :: Int)
  toJSON IEElementScrollBehavior
AlignBottom = Int -> Value
forall a. ToJSON a => a -> Value
toJSON (Int
1 :: Int)

instance FromJSON IEElementScrollBehavior where
  parseJSON :: Value -> Parser IEElementScrollBehavior
parseJSON Value
v = do
    Integer
n <- Value -> Parser Integer
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
    case Integer
n :: Integer of
      Integer
0 -> IEElementScrollBehavior -> Parser IEElementScrollBehavior
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return IEElementScrollBehavior
AlignTop
      Integer
1 -> IEElementScrollBehavior -> Parser IEElementScrollBehavior
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return IEElementScrollBehavior
AlignBottom
      Integer
_ -> String -> Parser IEElementScrollBehavior
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser IEElementScrollBehavior)
-> String -> Parser IEElementScrollBehavior
forall a b. (a -> b) -> a -> b
$ String
"Invalid integer for IEElementScrollBehavior: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Integer -> String
forall a. Show a => a -> String
show Integer
n