Start an isolated instance of Chrome that points to the currently running proxy.
(self)
| 49 | logging.log(ALERT, "Invalid browser name.") |
| 50 | |
| 51 | def launch_chrome(self) -> None: |
| 52 | """ |
| 53 | Start an isolated instance of Chrome that points to the currently |
| 54 | running proxy. |
| 55 | """ |
| 56 | cmd = find_executable_cmd( |
| 57 | "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", |
| 58 | # https://stackoverflow.com/questions/40674914/google-chrome-path-in-windows-10 |
| 59 | r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", |
| 60 | r"C:\Program Files (x86)\Google\Application\chrome.exe", |
| 61 | # Linux binary names from Python's webbrowser module. |
| 62 | "google-chrome", |
| 63 | "google-chrome-stable", |
| 64 | "chrome", |
| 65 | "chromium", |
| 66 | "chromium-browser", |
| 67 | "google-chrome-unstable", |
| 68 | ) or find_flatpak_cmd( |
| 69 | "com.google.Chrome", |
| 70 | "org.chromium.Chromium", |
| 71 | "com.github.Eloston.UngoogledChromium", |
| 72 | "com.google.ChromeDev", |
| 73 | ) |
| 74 | |
| 75 | if not cmd: |
| 76 | logging.log( |
| 77 | ALERT, "Your platform is not supported yet - please submit a patch." |
| 78 | ) |
| 79 | return |
| 80 | |
| 81 | tdir = tempfile.TemporaryDirectory() |
| 82 | self.tdir.append(tdir) |
| 83 | self.browser.append( |
| 84 | subprocess.Popen( |
| 85 | [ |
| 86 | *cmd, |
| 87 | "--user-data-dir=%s" % str(tdir.name), |
| 88 | "--proxy-server={}:{}".format( |
| 89 | ctx.options.listen_host or "127.0.0.1", |
| 90 | ctx.options.listen_port or "8080", |
| 91 | ), |
| 92 | "--disable-fre", |
| 93 | "--no-default-browser-check", |
| 94 | "--no-first-run", |
| 95 | "--disable-extensions", |
| 96 | "about:blank", |
| 97 | ], |
| 98 | stdout=subprocess.DEVNULL, |
| 99 | stderr=subprocess.DEVNULL, |
| 100 | ) |
| 101 | ) |
| 102 | |
| 103 | def launch_firefox(self) -> None: |
| 104 | """ |
no test coverage detected