createBrowserContext method

Future<BrowserContextID> createBrowserContext({
  1. bool? disposeOnDetach,
  2. String? proxyServer,
  3. String? proxyBypassList,
  4. List<String>? originsWithUniversalNetworkAccess,
})

Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one. disposeOnDetach If specified, disposes this context when debugging session disconnects. proxyServer Proxy server, similar to the one passed to --proxy-server proxyBypassList Proxy bypass list, similar to the one passed to --proxy-bypass-list originsWithUniversalNetworkAccess An optional list of origins to grant unlimited cross-origin access to. Parts of the URL other than those constituting origin are ignored. Returns: The id of the context created.

Implementation

Future<browser.BrowserContextID> createBrowserContext(
    {bool? disposeOnDetach,
    String? proxyServer,
    String? proxyBypassList,
    List<String>? originsWithUniversalNetworkAccess}) async {
  var result = await _client.send('Target.createBrowserContext', {
    if (disposeOnDetach != null) 'disposeOnDetach': disposeOnDetach,
    if (proxyServer != null) 'proxyServer': proxyServer,
    if (proxyBypassList != null) 'proxyBypassList': proxyBypassList,
    if (originsWithUniversalNetworkAccess != null)
      'originsWithUniversalNetworkAccess': [
        ...originsWithUniversalNetworkAccess
      ],
  });
  return browser.BrowserContextID.fromJson(
      result['browserContextId'] as String);
}