1# Copyright 2024 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from __future__ import annotations 6 7import enum 8 9 10class BrowserAttributes(enum.IntFlag): 11 SAFARI = enum.auto() 12 FIREFOX = enum.auto() 13 CHROMIUM = enum.auto() 14 CHROME = enum.auto() 15 EDGE = enum.auto() 16 17 CHROMIUM_BASED = enum.auto() 18 19 WEBDRIVER = enum.auto() 20 APPLESCRIPT = enum.auto() 21 22 MOBILE = enum.auto() 23 DESKTOP = enum.auto() 24 25 REMOTE = enum.auto() 26 27 @property 28 def is_chromium_based(self) -> bool: 29 return bool(self.CHROMIUM_BASED & self) 30 31 @property 32 def is_chrome(self) -> bool: 33 return bool(self & self.CHROME) 34 35 @property 36 def is_safari(self) -> bool: 37 return bool(self & self.SAFARI) 38 39 @property 40 def is_edge(self) -> bool: 41 return bool(self & self.EDGE) 42 43 @property 44 def is_firefox(self) -> bool: 45 return bool(self & self.FIREFOX) 46 47 @property 48 def is_remote(self) -> bool: 49 return bool(self & self.REMOTE) 50 51 @property 52 def is_local(self) -> bool: 53 return not self.is_remote 54