mirror of
https://github.com/python/cpython
synced 2024-09-16 04:59:58 +00:00
bpo-44844: Enable detection of Microsoft Edge browser in webbrowser module (GH-29908)
This commit is contained in:
parent
89e6a34461
commit
fd1947ecfb
|
@ -95,6 +95,31 @@ def test_open_new_tab(self):
|
||||||
arguments=[URL])
|
arguments=[URL])
|
||||||
|
|
||||||
|
|
||||||
|
class EdgeCommandTest(CommandTestMixin, unittest.TestCase):
|
||||||
|
|
||||||
|
browser_class = webbrowser.Edge
|
||||||
|
|
||||||
|
def test_open(self):
|
||||||
|
self._test('open',
|
||||||
|
options=[],
|
||||||
|
arguments=[URL])
|
||||||
|
|
||||||
|
def test_open_with_autoraise_false(self):
|
||||||
|
self._test('open', kw=dict(autoraise=False),
|
||||||
|
options=[],
|
||||||
|
arguments=[URL])
|
||||||
|
|
||||||
|
def test_open_new(self):
|
||||||
|
self._test('open_new',
|
||||||
|
options=['--new-window'],
|
||||||
|
arguments=[URL])
|
||||||
|
|
||||||
|
def test_open_new_tab(self):
|
||||||
|
self._test('open_new_tab',
|
||||||
|
options=[],
|
||||||
|
arguments=[URL])
|
||||||
|
|
||||||
|
|
||||||
class MozillaCommandTest(CommandTestMixin, unittest.TestCase):
|
class MozillaCommandTest(CommandTestMixin, unittest.TestCase):
|
||||||
|
|
||||||
browser_class = webbrowser.Mozilla
|
browser_class = webbrowser.Mozilla
|
||||||
|
|
|
@ -400,6 +400,16 @@ def open(self, url, new=0, autoraise=True):
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
|
|
||||||
|
class Edge(UnixBrowser):
|
||||||
|
"Launcher class for Microsoft Edge browser."
|
||||||
|
|
||||||
|
remote_args = ['%action', '%s']
|
||||||
|
remote_action = ""
|
||||||
|
remote_action_newwin = "--new-window"
|
||||||
|
remote_action_newtab = ""
|
||||||
|
background = True
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Platform support for Unix
|
# Platform support for Unix
|
||||||
#
|
#
|
||||||
|
@ -456,6 +466,10 @@ def register_X_browsers():
|
||||||
register("opera", None, Opera("opera"))
|
register("opera", None, Opera("opera"))
|
||||||
|
|
||||||
|
|
||||||
|
if shutil.which("microsoft-edge"):
|
||||||
|
register("microsoft-edge", None, Edge("microsoft-edge"))
|
||||||
|
|
||||||
|
|
||||||
def register_standard_browsers():
|
def register_standard_browsers():
|
||||||
global _tryorder
|
global _tryorder
|
||||||
_tryorder = []
|
_tryorder = []
|
||||||
|
@ -487,6 +501,8 @@ def register_standard_browsers():
|
||||||
"opera", edge64, edge32):
|
"opera", edge64, edge32):
|
||||||
if shutil.which(browser):
|
if shutil.which(browser):
|
||||||
register(browser, None, BackgroundBrowser(browser))
|
register(browser, None, BackgroundBrowser(browser))
|
||||||
|
if shutil.which("MicrosoftEdge.exe"):
|
||||||
|
register("microsoft-edge", None, Edge("MicrosoftEdge.exe"))
|
||||||
else:
|
else:
|
||||||
# Prefer X browsers if present
|
# Prefer X browsers if present
|
||||||
if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"):
|
if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"):
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Enables :mod:`webbrowser` to detect and launch Microsoft Edge browser.
|
Loading…
Reference in a new issue