openLiveBrowser
Open the given URL in the user's system browser, optionally enabling debugging.
@param {string} url The URL to open.
@param {boolean=} enableRemoteDebugging Whether to turn on remote debugging. Default false.
@return {$.Promise}
962952
function openLiveBrowser(url, enableRemoteDebugging) {
        var result = new $.Deferred();

        brackets.app.openLiveBrowser(url, !!enableRemoteDebugging, function onRun(err, pid) {
            if (!err) {
                // Undefined ids never get removed from list, so don't push them on
                if (pid !== undefined) {
                    liveBrowserOpenedPIDs.push(pid);
                }
                result.resolve(pid);
            } else {
                result.reject(_browserErrToFileError(err));
            }
        });

        return result.promise();
    }
690800
function buildAbsoluteUrl(url, protocol, host) {
    if (protocolRelativeRegex.test(url)) {
      url = host + url;
    } else if (!httpRegex.test(url)) {
      if (!host) {
        throw new Error(
          'You are using using fetch with a path-relative URL, but host is missing from Fastboot request. Please set the hostWhitelist property in your environment.js.'
        );
      }
      url = protocol + '//' + host + url;
    }
    return url;
  }
784205
function(args) {
    var baseUrl = this.baseUrl + this.basePath;
    var authToken = this.authToken;
    var qs = this._buildQueryString(args.params);

    return new Promise(function(resolve, reject) {
      var req = new XMLHttpRequest();

      req.onreadystatechange = function() {
        if (req.readyState === 4) {
          try {
            var response = JSON.parse(req.responseText);
            var status = req.status;

            if (status >= 200 && status < 400) {
              return resolve(
                addShadowProperty({
                  target: response,
                  property: 'httpRequest',
                  value: req
                })
              );
            }

            return reject(
              createApiError(
                merge(response, {
                  status: status,
                  httpRequest: req
                })
              )
            );
          } catch (err) {
            reject(err);
          }
        }
      };

      req.open(args.method, baseUrl + args.path + qs, true);
      req.setRequestHeader('Authorization', 'Bearer ' + authToken);
      req.setRequestHeader('Accept', 'application/json');
      req.setRequestHeader('Content-type', 'application/json; charset=utf-8');
      req.send(args.payload ? JSON.stringify(args.payload) : null);
    });
  }
652741
function closeLiveBrowser(pid) {
        var result = new $.Deferred();

        if (isNaN(pid)) {
            pid = 0;
        }
        brackets.app.closeLiveBrowser(function (err) {
            if (!err) {
                var i = liveBrowserOpenedPIDs.indexOf(pid);
                if (i !== -1) {
                    liveBrowserOpenedPIDs.splice(i, 1);
                }
                result.resolve();
            } else {
                result.reject(_browserErrToFileError(err));
            }
        }, pid);

        return result.promise();
    }
1296962
function inetChecksite(url, callback) {

  return new Promise((resolve) => {
    process.nextTick(() => {

      let result = {
        url: url,
        ok: false,
        status: 404,
        ms: -1
      };
      if (url) {
        url = url.toLowerCase();
        let t = Date.now();
        if (_linux || _freebsd || _openbsd || _darwin || _sunos) {
          let args = ' -I --connect-timeout 5 -m 5 ' + url + ' 2>/dev/null | head -n 1 | cut -d " " -f2';
          let cmd = 'curl';
          exec(cmd + args, function (error, stdout) {
            let statusCode = parseInt(stdout.toString());
            result.status = statusCode || 404;
            result.ok = !error && (statusCode === 200 || statusCode === 301 || statusCode === 302 || statusCode === 304);
            result.ms = (result.ok ? Date.now() - t : -1);
            if (callback) { callback(result); }
            resolve(result);
          });
        }
        if (_windows) {   // if this is stable, this can be used for all OS types
          const http = (url.startsWith('https:') ? require('https') : require('http'));
          try {
            http.get(url, (res) => {
              const statusCode = res.statusCode;

              result.status = statusCode || 404;
              result.ok = (statusCode === 200 || statusCode === 301 || statusCode === 302 || statusCode === 304);

              if (statusCode !== 200) {
                res.resume();
                result.ms = (result.ok ? Date.now() - t : -1);
                if (callback) { callback(result); }
                resolve(result);
              } else {
                res.on('data', () => { });
                res.on('end', () => {
                  result.ms = (result.ok ? Date.now() - t : -1);
                  if (callback) { callback(result); }
                  resolve(result);
                });
              }
            }).on('error', () => {
              if (callback) { callback(result); }
              resolve(result);
            });
          } catch (err) {
            if (callback) { callback(result); }
            resolve(result);
          }
        }
      } else {
        if (callback) { callback(result); }
        resolve(result);
      }
    });
  });
}
118930
function(url)
    {
      //Parse the redirected url
      return provider.authorization_done(opt, url, window, function()
      {
        //Destroy the window
        window.destroy();

        //Get the arguments
        var args = [].slice.call(arguments);

        //Do the callback with the provided arguments
        return cb.apply(null, args);
      });
    }
461523
public static Object displayURLonStandardBrowser(final Component parentComponent,
		final String url)
	{
		Object obj = null;
		try
		{
			if (System.getProperty(SYSTEM_PROPERTY_OS_NAME).startsWith(OS.MAC.getOs()))
			{
				obj = openURLinMacOS(url);
			}
			else if (System.getProperty(SYSTEM_PROPERTY_OS_NAME).startsWith(OS.WINDOWS.getOs()))
			{
				obj = openURLinWindowsOS(url);
			}
			else
			{ // if operate syste is Unix or Linux
				obj = openURLinUnixOS(url);
			}
		}
		catch (final Exception e)
		{
			JOptionPane.showMessageDialog(parentComponent,
				"An exception occured attempting to run the default web browser\n" + e.toString());
		}
		return obj;
	}
649854
private static Boolean openURLinUnixOS(final String url)
		throws InterruptedException, IOException, Exception
	{
		Boolean executed = false;
		for (final Browsers browser : Browsers.values())
		{
			if (!executed)
			{
				executed = Runtime.getRuntime()
					.exec(new String[] { UNIX_COMMAND_WHICH, browser.getBrowserName() })
					.waitFor() == 0;
				if (executed)
				{
					Runtime.getRuntime().exec(new String[] { browser.getBrowserName(), url });
				}
			}
		}
		if (!executed)
		{
			throw new Exception(Arrays.toString(Browsers.values()));
		}
		return executed;
	}
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);
  }
1020477
public void startBrowserOnUrl(final String browser, final String browserUrl) {
		setBrowser(browser);
        startDriverOnUrl(defaultWebDriverInstance(), browserUrl);
	}
132109
public String openNewWindow(final String url, final long timeoutSeconds) {
		String oldHandle = openNewWindow(timeoutSeconds);
		get(url);
		return oldHandle;
	}
680746
function loadRemoteRawData(url) {
  if (!url) {
    // TODO: we should return reject with an appropriate error
    return Promise.resolve(null)
  }

  return new Promise((resolve, reject) => {
    request(url, (error, result) => {
      if (error) {
        reject(error);
      }
      const responseError = detectResponseError(result);
      if (responseError) {
        reject(responseError);
        return;
      }
      resolve(result.response)
    })
  });
}
36855
def open_pr(self, url):
        
        if self.dry_run:
            click.echo(f"  dry-run: Create new PR: {url}")
        else:
            click.echo("Backport PR URL:")
            click.echo(url)
            webbrowser.open_new_tab(url)
1105485
function phantomas(url, opts) {
	var events = new EventEmitter(),
		browser, options;

	debug('OS: %s %s', process.platform, process.arch);
	debug('Node.js: %s', process.version);
	debug('phantomas: %s', VERSION);
	debug('Puppeteer: preferred revision r%s', puppeteer._launcher._preferredRevision);
	debug('URL: <%s>', url);

	// options handling
	options = util._extend({}, opts || {}); // use util._extend to avoid #563
	options.url = options.url || url || false;

	debug('Options: %s', JSON.stringify(options));

	events.setMaxListeners(100); // MaxListenersExceededWarning: Possible EventEmitter memory leak detected.

	var results = new Results();
	results.setUrl(url);
	results.setGenerator('phantomas v' + VERSION);

	// set up and run Puppeteer
	browser = new Browser();
	browser.bind(events);

	var promise = new Promise(async (resolve, reject) => {
		try {
			if (typeof options.url !== 'string') {
				return reject(Error('URL must be a string'));
			}

			const page = await browser.init(),
				debugScope = require('debug')('phantomas:scope:log');

			// prepare a small instance object that will be passed to modules and extensions on init
			const scope = {
				getParam: (param, _default) => {
					return options[param] || _default;
				},
				getVersion: () => VERSION,

				emit: events.emit.bind(events),
				on: events.on.bind(events),
				once: events.once.bind(events),

				log: debugScope.bind(debug),

				addOffender: results.addOffender.bind(results),
				incrMetric: results.incrMetric.bind(results),
				setMetric: results.setMetric,
				addToAvgMetric: results.addToAvgMetric,

				getMetric: results.getMetric,

				// @see https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#pageevaluatepagefunction-args
				evaluate: page.evaluate.bind(page),

				// @see https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#pageselector-1
				querySelectorAll: async (selector) => {
					debug('querySelectorAll("%s")', selector)
					return page.$$(selector);
				},

				// @see https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#pageevaluateonnewdocumentpagefunction-args
				injectJs: async (script) => {
					const debug = require('debug')('phantomas:injectJs'),
						preloadFile = require('fs').readFileSync(script, 'utf8');

					await page.evaluateOnNewDocument(preloadFile);

					debug(script + ' JavaScript file has been injected into page scope');
				}
			};

			// pass phantomas options to page scope
			// https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#pageevaluateonnewdocumentpagefunction-args
			await page.evaluateOnNewDocument(options => {
				window.__phantomas_options = options;
			}, options);

			// expose the function that will pass events from page scope code into Node.js layer
			// @see https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#pageexposefunctionname-puppeteerfunction
			await page.exposeFunction('__phantomas_emit', scope.emit);

			// Inject helper code into the browser's scope
			events.on('init', () => {
				scope.injectJs(__dirname + '/../core/scope.js');
			});

			// bind to sendMsg calls from page scope code
			events.on('scopeMessage', (type, args) => {
				const debug = require('debug')('phantomas:core:scopeEvents');
				// debug(type + ' [' + args + ']');

				switch(type) {
					case 'addOffender':
					case 'incrMetric':
					case 'log':
					case 'setMetric':
						scope[type].apply(scope, args);
						break;

					default:
						debug('Unrecognized event type: ' + type);
				}
			});

			// bind to a first response
			// and reject a promise if the first response is 4xx / 5xx HTTP error
			var firstResponseReceived = false;

			events.once('recv', async entry => {
				if (!firstResponseReceived && entry.status >= 400) {
					debug('<%s> response code is HTTP %d %s', entry.url, entry.status, entry.statusText);

					// close the browser before leaving here, otherwise subsequent instances will have problems
					await browser.close();
					reject(new Error('HTTP response code from <' + entry.url + '> is ' + entry.status));
				}

				firstResponseReceived = true;
			});

			// load modules and extensions
			debug('Loading core modules...');
			loader.loadCoreModules(scope);

			debug('Loading extensions...');
			loader.loadExtensions(scope);

			debug('Loading modules...');
			loader.loadModules(scope);

			await events.emit('init', page, browser); // @desc Browser's scope and modules are set up, the page is about to be loaded

			// https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#pagegotourl-options
			const waitUntil = options['wait-for-network-idle'] ? 'networkidle0' : undefined,
				timeout = options.timeout;

			await browser.visit(url, waitUntil, timeout);

			// resolve our run
			// https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#browserclose
			await events.emit('beforeClose', page); // @desc Called before the Chromium (and all of its pages) is closed
			await browser.close();

			// your last chance to add metrics
			await events.emit('report'); // @desc Called just before the phantomas results are returned to the caller

			resolve(results);
		}
		catch(ex) {
			// close the browser before leaving here, otherwise subsequent instances will have problems
			await browser.close();
			reject(ex);
		}
	});

	promise.on = events.on.bind(events);

	return promise;
}
980164
public static void launchWebBrowser(final Context context, final String url) {
        if (context != null && url != null && !"".equals(url)) {
            final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            if (browserIntent.resolveActivity(context.getPackageManager()) != null) {
                context.startActivity(browserIntent);
            } else {
                ToastUtils.quickToast(context, "Sorry, Could not open the link. You do not have an application installed to open it.");
                Log.e("Caffeine", "Failed to open link, because an application is not available to view it.");
            }
        } else {
            ToastUtils.quickToast(context, "Sorry, Could not open link.  No URL provided.");
        }
    }
1071095
function(url, onProgress) {
        onProgress = onProgress || function(){};
        return injectGlobalCatalogs()
            .then(function() {
                library.commit();
               return request.read(url);
            })
            .then(function(response) {
                // disable saves for better performance
                library.autosave(false);
                // index projects and source languages
                if (response.status !== 200) return Promise.reject(response);

                let projects;
                try {
                    projects = JSON.parse(response.data);
                } catch (err) {
                    return Promise.reject(err);
                }

                return promiseUtils.chain(downloadSourceLanguages, function(err, data) {
                    if(err instanceof Error) return Promise.reject(err);
                    console.log(err);
                    return false;
                }, {compact: true, onProgress: onProgress.bind(null, 'projects')})(projects);
            })
            .then(function(projects) {
                // index resources
                library.commit();
                if(!projects) return Promise.reject('No projects found');
                let list = [];
                for(let project of projects) {
                    for(let localizedProject of project) {
                        list.push({
                            id: localizedProject.id,
                            slug: localizedProject.slug,
                            source_language_id: localizedProject.source_language_id,
                            resourceUrl: localizedProject.resourceUrl
                        });
                    }
                }

                return promiseUtils.chain(downloadSourceResources, function(err, data) {
                    if(err instanceof Error) return Promise.reject(err);
                    console.log(err);
                    return false;
                }, {compact: true, onProgress: onProgress.bind(null, 'resources')})(list);
            }).then(function() {
                // keep the promise args clean
                library.commit();
                library.autosave(true);
                return Promise.resolve();
            }).catch(function(err) {
                library.autosave(true);
                return Promise.reject(err);
            });
    }
654168
function pongOnTheFlyOpenDlg(id, modalName, resourceURL, params) {
  log( "PoNG-OnTheFly", "Open " + id + " " + modalName + " " + resourceURL );
  var viewCfg = getViewConfig( id );
  log( "PoNG-OnTheFly", "GET " + resourceURL + '/' + viewCfg.type );
  $.getJSON( resourceURL + '/' + viewCfg.type, function(pluginConfig) {
    log( "PoNG-OnTheFly", "Config loaded from " + resourceURL + '/'
        + viewCfg.type );
    $( '#' + id + modalName + 'Dialog' ).dialog( 'open' );
    $( '#' + id + modalName + 'DialogConfig' ).val(
        JSON.stringify( pluginConfig, null, "  " ) );
  } );
  if ( params && params.assistUrl ) {
    $.get( 
        params.assistUrl, 
        function(assistTxt) {
          log( "PoNG-OnTheFly", "Assistance loaded from " + params.assistUrl );
          $( '#' + id + modalName + 'DialogAssist' ).val( assistTxt );
        } 
      ).fail(
          function() { publishEvent( 'feedback', {'text': 'Can not load assistance ' } ) }
      );
  }
}