From aeefcd08a40a8bd886d3bca6eca00ec5ace325ee Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 10 Dec 2017 17:35:59 +1300 Subject: browser addon: start an isolated browser attached to the proxy A simple addon that starts an instance of Chrome attached to the current proxy. The instance is isolated in its own user data directory, and addons are turned off. Future work: - I wasn't able to test the Windows executable path - a Windows dev should confirm this for us. - In future it would be nice to support other browsers like Firefox. --- test/mitmproxy/addons/test_browser.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/mitmproxy/addons/test_browser.py (limited to 'test') diff --git a/test/mitmproxy/addons/test_browser.py b/test/mitmproxy/addons/test_browser.py new file mode 100644 index 00000000..d1b32186 --- /dev/null +++ b/test/mitmproxy/addons/test_browser.py @@ -0,0 +1,20 @@ +from unittest import mock + +from mitmproxy.addons import browser +from mitmproxy.test import taddons + + +def test_browser(): + with mock.patch("subprocess.Popen") as po: + b = browser.Browser() + with taddons.context() as tctx: + b.start() + assert po.called + b.start() + + assert not tctx.master.has_log("already running") + b.browser.poll = lambda: None + b.start() + assert tctx.master.has_log("already running") + b.done() + assert not b.browser -- cgit v1.2.3