Use a number of methods to guess if the default webbrowser will open in
        the background as opposed to opening directly in the terminal.
543614
def display(self):
        

        if self._display is None:
            if sys.platform == 'darwin':
                # OS X won't set $DISPLAY unless xQuartz is installed.
                # If you're using OS X and you want to access a terminal
                # browser, you need to set it manually via $BROWSER.
                # See issue #166
                display = True
            else:
                display = bool(os.environ.get("DISPLAY"))

            # Use the convention defined here to parse $BROWSER
            # https://docs.python.org/2/library/webbrowser.html
            console_browsers = ['www-browser', 'links', 'links2', 'elinks',
                                'lynx', 'w3m']
            if "BROWSER" in os.environ:
                user_browser = os.environ["BROWSER"].split(os.pathsep)[0]
                if user_browser in console_browsers:
                    display = False
            if webbrowser._tryorder:
                if webbrowser._tryorder[0] in console_browsers:
                    display = False
            self._display = display
        return self._display
991348
def mkbrowseto(self, url):
        
        # Try-except block to work around webbrowser module bug
        # https://bugs.python.org/issue31014
        try:
            browser = os.environ['BROWSER']
        except KeyError:
            pass
        else:
            del os.environ['BROWSER']
            webbrowser.register(browser, None, webbrowser.GenericBrowser(browser))
            try_idx = webbrowser._tryorder.index(browser)
            webbrowser._tryorder.insert(0, webbrowser._tryorder.pop(try_idx))

        def browse(*args):
            # double ()() to ensure self.search evaluated at runtime, not when
            # browse() is _created_. [0] is self.search, [1] is self.enter
            # self.enter prevents opening URL when in search mode
            if self._get_search()[0]() is True:
                if self._get_search()[1]() is True:
                    self.search = False
                    self.enter = False
            elif not self.run:
                webbrowser.open(url)
            elif self.run and self.pipe:
                process = Popen(shlex.split(self.run), stdout=PIPE, stdin=PIPE)
                process.communicate(input=url.encode(sys.getdefaultencoding()))
            else:
                Popen(self.run.format(url), shell=True).communicate()

            size = self.tui.get_cols_rows()
            self.draw_screen(size)
        return browse
1363108
function privateBrowsing_start(useShortcut) {
    var dialog = null;

    if (this.enabled)
      return;

    if (this.showPrompt) {
      dialog = new modalDialog.modalDialog(this._controller.window);
      dialog.start(this._handler);
    }

    if (useShortcut) {
      var cmdKey = utils.getEntity(this.getDtds(), "privateBrowsingCmd.commandkey");
      this._controller.keypress(null, cmdKey, {accelKey: true, shiftKey: true});
    } else {
      this._controller.click(this._pbMenuItem);
    }

    if (dialog) {
      dialog.waitForDialog();
    }
    this.waitForTransistionComplete(true);
  }
706963
function openInNewWindow(event) {
		var isMac = window.navigator.platform.indexOf("Mac") !== -1; //$NON-NLS-0$
		return (isMac && event.metaKey) || (!isMac && event.ctrlKey);
	}
542805
function detectWebEnvironment(environments) {
    // If the given environment is just a Closure, we will defer the environment check
    // to the Closure the developer has provided, which allows them to totally swap
    // the webs environment detection logic with their own custom Closure's code.
    if (typeof environments === 'function') {
        return environments()
    }

    var hosts;
    for (var environment in environments) {
        hosts = environments[environment];

        // To determine the current environment, we'll simply iterate through the possible
        // environments and look for the host that matches the host for this request we
        // are currently processing here, then return back these environment's names.
        hosts = helper.parseObject(hosts);
        var k, host;
        for (k in hosts) {
            host = hosts[k];
            if (isMachine(host)) return environment;
        }
    }

    return 'production';
}
132109
public String openNewWindow(final String url, final long timeoutSeconds) {
		String oldHandle = openNewWindow(timeoutSeconds);
		get(url);
		return oldHandle;
	}
217231
function() {
    if (typeof window.Worker === 'undefined' || typeof window.URL === 'undefined') {
        return false;
    }

    try {
        /* eslint-disable no-new */
        new Worker(window.URL.createObjectURL(
            new Blob([''], { type: 'text/javascript' })
        ));
        /* eslint-enable no-new */
    } catch (e) {
        return false;
    }

    return true;
}
208682
def main():
    
    parser = __build_option_parser()
    args = parser.parse_args()
    analyze_ws = AnalyzeWS(args)
    try:
        analyze_ws.set_file(args.file_[0])
    except IOError:
        print 'IOError raised while reading file. Exiting!'
        sys.exit(3)

    # Start the chosen mode
    if args.to_file or args.to_browser:
        analyze_ws.to_file_mode()
        if args.to_browser:
            analyze_ws.to_browser_mode()
    else:
        analyze_ws.interactive_mode()
246492
def patch_webbrowser():
    

    # https://bugs.python.org/issue31014
    # https://github.com/michael-lazar/rtv/issues/588
    def register_patch(name, klass, instance=None, update_tryorder=None, preferred=False):
        """
        Wrapper around webbrowser.register() that detects if the function was
        invoked with the legacy function signature. If so, the signature is
        fixed before passing it along to the underlying function.

        Examples:
            register(name, klass, instance, -1)
            register(name, klass, instance, update_tryorder=-1)
            register(name, klass, instance, preferred=True)
        """
        if update_tryorder is not None:
            preferred = (update_tryorder == -1)
        return webbrowser._register(name, klass, instance, preferred=preferred)

    if sys.version_info[:2] >= (3, 7):
        webbrowser._register = webbrowser.register
        webbrowser.register = register_patch

    # Add support for browsers that aren't defined in the python standard library
    webbrowser.register('surf', None, webbrowser.BackgroundBrowser('surf'))
    webbrowser.register('vimb', None, webbrowser.BackgroundBrowser('vimb'))
    webbrowser.register('qutebrowser', None, webbrowser.BackgroundBrowser('qutebrowser'))

    # Fix the opera browser, see https://github.com/michael-lazar/rtv/issues/476.
    # By default, opera will open a new tab in the current window, which is
    # what we want to do anyway.
    webbrowser.register('opera', None, webbrowser.BackgroundBrowser('opera'))

    # https://bugs.python.org/issue31348
    # Use MacOS actionscript when opening the program defined in by $BROWSER
    if sys.platform == 'darwin' and 'BROWSER' in os.environ:
        _userchoices = os.environ["BROWSER"].split(os.pathsep)
        for cmdline in reversed(_userchoices):
            if cmdline in ('safari', 'firefox', 'chrome', 'default'):
                browser = webbrowser.MacOSXOSAScript(cmdline)
                webbrowser.register(cmdline, None, browser, update_tryorder=-1)
224172
public static void openInDefaultBrowser(URL url) throws IOException {
        Runtime rt = Runtime.getRuntime();

        if (SystemUtils.IS_OS_WINDOWS) {
            rt.exec("rundll32 url.dll,FileProtocolHandler " + url);
        } else if (SystemUtils.IS_OS_MAC) {
            rt.exec("open" + url);
        } else {
            String[] browsers = {"epiphany", "firefox", "mozilla", "konqueror",
                    "netscape", "opera", "links", "lynx"};

            StringBuilder cmd = new StringBuilder();
            for (int i = 0; i < browsers.length; i++)
                cmd.append(i == 0 ? "" : " || ").append(browsers[i]).append(" \"").append(url).append("\" ");

            rt.exec(new String[]{"sh", "-c", cmd.toString()});
        }
    }
62851
def open_browser(url: str, browser: str = None) -> None:
    """"""
    if '--open-browser' in sys.argv:
        # Remove open browser to prevent making new tab on autoreload
        sys.argv.remove('--open-browser')
    if browser is None:
        browser = config.browser
    if browser in _browsers:
        webbrowser.get(browser).open(url)
    else:
        webbrowser.open(url)
822014
function createWindow() {
        // Create the browser window.

        // Get full path of the file getting opened
        const target = splitArgs(argv);
        if (target === '' && opts.defaultPath) {
            // Invalid, empty target, let's just create a window from default
            wm.createWindow(opts.defaultPath);
            return;
        }
        const targetPath = pathlib.resolve(process.cwd(), target);

        if (opts.changeDirectory === true) {
            // If we need to change into the relevant directory, do it now
            const dir = pathlib.dirname(targetPath);
            if (fs.existsSync(dir)) {
                process.chdir(dir);
            }
        } else if (String.isString(opts.changeDirectory)) {
            process.chdir(opts.changeDirectory);
        }
        wm.createWindow(targetPath);
    }
483103
protected function getDefaultBrowser()
    {
        $potential = array('xdg-open', 'open', 'start');
        /** @var \Symfony\Component\Console\Helper\ProcessHelper $process */
        $process = $this->getHelper('process');
        foreach ($potential as $browser) {
            // Check if command exists by executing help flag.

            if ($process->run($this->stdOut, "command -v $browser")->isSuccessful()) {
                return $browser;
            }
        }
        return false;
    }
212979
def _init_browser(self):
        
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('--disable-extensions')
        chrome_options.add_argument('--disable-infobars')
        chrome_options.add_argument('--ignore-certificate-errors')
        chrome_options.add_experimental_option('prefs', {
            'profile.managed_default_content_settings.notifications': 1
        })

        browser = webdriver.Chrome(chrome_options=chrome_options)
        browser.set_page_load_timeout(10)
        browser.implicitly_wait(1)
        browser.maximize_window()
        browser.get(settings.HARNESS_URL)
        self._browser = browser
        if not wait_until(lambda: 'Thread' in browser.title, 30):
            self.assertIn('Thread', browser.title)
1094203
def get_action(args):
    """"""
    redirect_mode = args.bang or args.search or args.lucky
    if redirect_mode and not args.url:
        return webbrowser.open_new_tab
    else:
        return print_result
1261169
public static final void launchBrowser(String url) throws IOException {
		try {
			if (isMac()) {
				Class macUtils = Class.forName("com.apple.mrj.MRJFileUtils");
				Method openURL = macUtils.getDeclaredMethod("openURL", new Class[] {String.class});
				openURL.invoke(null, new Object[] {url});
			}
			else if (isWindows())
				Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
			else { //assume Unix or Linux
	            String[] browsers = {
	               "firefox", "opera", "konqueror", "mozilla", "netscape" };
	            String browser = null;
	            for (int count = 0; count < browsers.length && browser == null; count++)
	               if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor() == 0)
	                  browser = browsers[count];
	            if (browser == null)
	               throw new Exception("Could not find web browser.");
	            else
	               Runtime.getRuntime().exec(new String[] {browser, url});
	            }
	         }
	      catch (Exception e) {
	         throw new IOException("Error attempting to launch web browser");
	      }
	}
309594
def run_local(client):
  """"""
  webbrowser.open(client.get_auth_uri())
  code = wait_for_redirect()
  return client.get_token(code)