示例#1
0
        protected override void OnResize(EventArgs e)
        {
            var viewportSize = new ViewportSize(Width, Height, UserSettings.Instance.UI.UIScale);

            screenManager.OnResize(viewportSize);
            renderContext.OnResize(viewportSize);
            base.OnResize(e);
        }
示例#2
0
 internal Task SetViewportSizeAsync(ViewportSize viewport)
 => Connection.SendMessageToServer(
     Guid,
     "setViewportSize",
     new Dictionary <string, object>
 {
     ["viewportSize"] = viewport,
 });
示例#3
0
        public async Task ShouldMakeACopyOfDefaultViewport()
        {
            var viewport = new ViewportSize
            {
                Width  = 456,
                Height = 789
            };

            await using var context = await Browser.NewContextAsync(new() { ViewportSize = viewport });

            viewport.Width = 567;

            var page = await context.NewPageAsync();

            await TestUtils.VerifyViewportAsync(page, 456, 789);
        }
示例#4
0
 /// <inheritdoc/>
 public new async Task <IChromiumBrowserContext> NewContextAsync(
     ViewportSize viewport,
     string userAgent                = null,
     bool?bypassCSP                  = null,
     bool?javaScriptEnabled          = null,
     string timezoneId               = null,
     Geolocation geolocation         = null,
     ContextPermission[] permissions = null,
     bool?isMobile               = null,
     bool?offline                = null,
     decimal?deviceScaleFactor   = null,
     Credentials httpCredentials = null,
     bool?hasTouch               = null,
     bool?acceptDownloads        = null,
     bool?ignoreHTTPSErrors      = null,
     ColorScheme?colorScheme     = null,
     string locale               = null,
     Dictionary <string, string> extraHTTPHeaders = null,
     RecordHarOptions recordHar     = null,
     RecordVideoOptions recordVideo = null,
     ProxySettings proxy            = null,
     string storageStatePath        = null,
     StorageState storageState      = null)
 => await base.NewContextAsync(
     viewport,
     userAgent,
     bypassCSP,
     javaScriptEnabled,
     timezoneId,
     geolocation,
     permissions,
     isMobile,
     offline,
     deviceScaleFactor,
     httpCredentials,
     hasTouch,
     acceptDownloads,
     ignoreHTTPSErrors,
     colorScheme,
     locale,
     extraHTTPHeaders,
     recordHar,
     recordVideo,
     proxy,
     storageStatePath,
     storageState).ConfigureAwait(false) as IChromiumBrowserContext;
        public async Task ShouldSupportScreenSize()
        {
            await using var context = await Browser.NewContextAsync(new()
            {
                ScreenSize = new ScreenSize()
                {
                    Width  = 750,
                    Height = 1334,
                },
                ViewportSize = new ViewportSize()
                {
                    Width  = 375,
                    Height = 667
                }
            });

            var page = await context.NewPageAsync();

            Assert.True(await page.EvaluateAsync <bool?>("() => matchMedia('(device-height: 1334px)').matches"));
            Assert.True(await page.EvaluateAsync <bool?>("() => matchMedia('(device-width: 750px)').matches"));
            await TestUtils.VerifyViewportAsync(page, 375, 667);
        }
 /// <inheritdoc/>
 public new async Task <IChromiumBrowserContext> NewContextAsync(
     string userAgent                = null,
     bool?bypassCSP                  = null,
     bool?javaScriptEnabled          = null,
     string timezoneId               = null,
     Geolocation geolocation         = null,
     ContextPermission[] permissions = null,
     bool?isMobile               = null,
     bool?offline                = null,
     decimal?deviceScaleFactor   = null,
     Credentials httpCredentials = null,
     bool?hasTouch               = null,
     bool?acceptDownloads        = null,
     bool?ignoreHTTPSErrors      = null,
     ColorScheme?colorScheme     = null,
     string locale               = null,
     Dictionary <string, string> extraHttpHeaders = null,
     string videosPath      = null,
     ViewportSize videoSize = null)
 => await base.NewContextAsync(
     userAgent,
     bypassCSP,
     javaScriptEnabled,
     timezoneId,
     geolocation,
     permissions,
     isMobile,
     offline,
     deviceScaleFactor,
     httpCredentials,
     hasTouch,
     acceptDownloads,
     ignoreHTTPSErrors,
     colorScheme,
     locale,
     extraHttpHeaders).ConfigureAwait(false) as IChromiumBrowserContext;
示例#7
0
 public void OnResize(ViewportSize viewportSize)
 {
     Max = GetDimension(viewportSize);
 }
示例#8
0
        internal Task <BrowserContextChannel> NewContextAsync(
            bool?acceptDownloads    = null,
            bool?bypassCSP          = null,
            ColorScheme colorScheme = ColorScheme.Undefined,
            float?deviceScaleFactor = null,
            IEnumerable <KeyValuePair <string, string> > extraHTTPHeaders = null,
            Geolocation geolocation         = null,
            bool?hasTouch                   = null,
            HttpCredentials httpCredentials = null,
            bool?ignoreHTTPSErrors          = null,
            bool?isMobile                   = null,
            bool?javaScriptEnabled          = null,
            string locale                   = null,
            bool?offline = null,
            IEnumerable <string> permissions = null,
            Proxy proxy = null,
            bool?recordHarOmitContent       = null,
            string recordHarPath            = null,
            string recordVideoDir           = null,
            RecordVideoSize recordVideoSize = null,
            string storageState             = null,
            string storageStatePath         = null,
            string timezoneId         = null,
            string userAgent          = null,
            ViewportSize viewportSize = default)
        {
            var args = new Dictionary <string, object>();

            if (acceptDownloads.HasValue)
            {
                args.Add("acceptDownloads", acceptDownloads.Value);
            }

            if (bypassCSP.HasValue)
            {
                args.Add("bypassCSP", bypassCSP.Value);
            }

            if (colorScheme != ColorScheme.Undefined)
            {
                args.Add("colorScheme", colorScheme);
            }

            if (deviceScaleFactor.HasValue)
            {
                args.Add("deviceScaleFactor", deviceScaleFactor.Value);
            }

            if (extraHTTPHeaders != null)
            {
                args["extraHTTPHeaders"] = extraHTTPHeaders.Select(kv => new HeaderEntry {
                    Name = kv.Key, Value = kv.Value
                }).ToArray();
            }

            if (geolocation != null)
            {
                args.Add("geolocation", geolocation);
            }

            if (hasTouch.HasValue)
            {
                args.Add("hasTouch", hasTouch.Value);
            }

            if (httpCredentials != null)
            {
                args.Add("httpCredentials", httpCredentials);
            }

            if (ignoreHTTPSErrors.HasValue)
            {
                args.Add("ignoreHTTPSErrors", ignoreHTTPSErrors.Value);
            }

            if (isMobile.HasValue)
            {
                args.Add("isMobile", isMobile.Value);
            }

            if (javaScriptEnabled.HasValue)
            {
                args.Add("javaScriptEnabled", javaScriptEnabled.Value);
            }

            if (!string.IsNullOrEmpty(locale))
            {
                args.Add("locale", locale);
            }

            if (offline.HasValue)
            {
                args.Add("offline", offline.Value);
            }

            if (permissions != null)
            {
                args.Add("permissions", permissions);
            }

            if (proxy != null)
            {
                args.Add("proxy", proxy);
            }

            if (!string.IsNullOrEmpty(recordHarPath))
            {
                args.Add("recordHar", new
                {
                    Path        = recordHarPath,
                    OmitContent = recordHarOmitContent,
                });
            }

            if (!string.IsNullOrEmpty(recordVideoDir) &&
                recordVideoDir != null)
            {
                args.Add("recordVideo", new Dictionary <string, object>()
                {
                    { "dir", recordVideoDir },
                    { "size", recordVideoSize },
                });
            }

            if (!string.IsNullOrEmpty(storageState))
            {
                args.Add("storageState", storageState);
            }

            if (!string.IsNullOrEmpty(storageStatePath))
            {
                args.Add("storageStatePath", storageStatePath);
            }

            if (!string.IsNullOrEmpty(timezoneId))
            {
                args.Add("timezoneId", timezoneId);
            }

            if (!string.IsNullOrEmpty(userAgent))
            {
                args.Add("userAgent", userAgent);
            }

            if (ViewportSize.NoViewport.Equals(viewportSize))
            {
                args.Add("noDefaultViewport", true);
            }
            else if (viewportSize != null && !ViewportSize.Default.Equals(viewportSize))
            {
                args.Add("viewport", viewportSize);
            }

            args["sdkLanguage"] = "csharp";

            return(Connection.SendMessageToServerAsync <BrowserContextChannel>(
                       Guid,
                       "newContext",
                       args,
                       true));
        }
示例#9
0
 void AssertEqual(int width, int height, ViewportSize size)
 {
     Assert.AreEqual(width, size.Width);
     Assert.AreEqual(height, size.Height);
 }
示例#10
0
 public void OnResize(ViewportSize newSize)
 {
     _viewportSize = newSize;
     _screenLayers.ForEach((layer) => layer.OnResize(newSize));
 }
 /// <inheritdoc/>
 public new async Task <IChromiumBrowserContext> LaunchPersistentContextAsync(
     string userDataDir,
     ViewportSize viewport,
     bool?headless                   = null,
     string[] args                   = null,
     bool?devtools                   = null,
     string executablePath           = null,
     string downloadsPath            = null,
     bool?ignoreHTTPSErrors          = null,
     int?timeout                     = null,
     bool?dumpIO                     = null,
     int?slowMo                      = null,
     bool?ignoreDefaultArgs          = null,
     string[] ignoredDefaultArgs     = null,
     Dictionary <string, string> env = null,
     Dictionary <string, object> firefoxUserPrefs = null,
     ProxySettings proxy             = null,
     string userAgent                = null,
     bool?bypassCSP                  = null,
     bool?javaScriptEnabled          = null,
     string timezoneId               = null,
     Geolocation geolocation         = null,
     ContextPermission[] permissions = null,
     bool?isMobile               = null,
     bool?offline                = null,
     decimal?deviceScaleFactor   = null,
     Credentials httpCredentials = null,
     bool?hasTouch               = null,
     bool?acceptDownloads        = null,
     ColorScheme?colorScheme     = null,
     string locale               = null,
     Dictionary <string, string> extraHttpHeaders = null,
     bool?chromiumSandbox   = null,
     bool?handleSIGINT      = null,
     bool?handleSIGTERM     = null,
     bool?handleSIGHUP      = null,
     string videosPath      = null,
     ViewportSize videoSize = null)
 => await LaunchPersistentContextAsync(
     userDataDir,
     viewport,
     headless,
     args,
     devtools,
     executablePath,
     downloadsPath,
     ignoreHTTPSErrors,
     timeout,
     dumpIO,
     slowMo,
     ignoreDefaultArgs,
     ignoredDefaultArgs,
     env,
     firefoxUserPrefs,
     proxy,
     userAgent,
     bypassCSP,
     javaScriptEnabled,
     timezoneId,
     geolocation,
     permissions,
     isMobile,
     offline,
     deviceScaleFactor,
     httpCredentials,
     hasTouch,
     acceptDownloads,
     colorScheme,
     locale,
     extraHttpHeaders,
     chromiumSandbox,
     handleSIGINT,
     handleSIGTERM,
     handleSIGHUP,
     videosPath,
     videoSize).ConfigureAwait(false) as IChromiumBrowserContext;
        internal Task <BrowserContextChannel> LaunchPersistentContextAsync(
            string userDataDir,
            bool?headless = default,
            Microsoft.Playwright.BrowserChannel channel = default,
            string executablePath     = default,
            IEnumerable <string> args = default,
            Proxy proxy          = default,
            string downloadsPath = default,
            bool?chromiumSandbox = default,
            bool?handleSIGINT    = default,
            bool?handleSIGTERM   = default,
            bool?handleSIGHUP    = default,
            float?timeout        = default,
            IEnumerable <KeyValuePair <string, string> > env = default,
            bool?devtools                    = default,
            float?slowMo                     = default,
            bool?acceptDownloads             = default,
            bool?ignoreHTTPSErrors           = default,
            bool?bypassCSP                   = default,
            ViewportSize viewportSize        = default,
            ScreenSize screenSize            = default,
            string userAgent                 = default,
            float?deviceScaleFactor          = default,
            bool?isMobile                    = default,
            bool?hasTouch                    = default,
            bool?javaScriptEnabled           = default,
            string timezoneId                = default,
            Geolocation geolocation          = default,
            string locale                    = default,
            IEnumerable <string> permissions = default,
            IEnumerable <KeyValuePair <string, string> > extraHTTPHeaders = default,
            bool?offline = default,
            HttpCredentials httpCredentials        = default,
            ColorScheme colorScheme                = default,
            string recordHarPath                   = default,
            bool?recordHarOmitContent              = default,
            string recordVideoDir                  = default,
            RecordVideoSize recordVideoSize        = default,
            IEnumerable <string> ignoreDefaultArgs = default,
            bool?ignoreAllDefaultArgs              = default)
        {
            var channelArgs = new Dictionary <string, object>();

            if (!string.IsNullOrEmpty(userDataDir))
            {
                channelArgs.Add("userDataDir", userDataDir);
            }

            if (headless.HasValue)
            {
                channelArgs.Add("headless", headless);
            }

            if (channel != Microsoft.Playwright.BrowserChannel.Undefined)
            {
                channelArgs.Add("channel", channel);
            }

            if (!string.IsNullOrEmpty(executablePath))
            {
                channelArgs.Add("executablePath", executablePath);
            }

            if (args?.Any() == true)
            {
                channelArgs.Add("args", args);
            }

            if (!string.IsNullOrEmpty(downloadsPath))
            {
                channelArgs.Add("downloadsPath", downloadsPath);
            }

            if (proxy != null)
            {
                channelArgs.Add("proxy", proxy);
            }

            if (chromiumSandbox.HasValue)
            {
                channelArgs.Add("chromiumSandbox", chromiumSandbox);
            }

            if (handleSIGINT.HasValue)
            {
                channelArgs.Add("handleSIGINT", handleSIGINT);
            }

            if (handleSIGTERM.HasValue)
            {
                channelArgs.Add("handleSIGTERM", handleSIGTERM);
            }

            if (handleSIGHUP.HasValue)
            {
                channelArgs.Add("handleSIGHUP", handleSIGHUP);
            }

            if (timeout.HasValue)
            {
                channelArgs.Add("timeout", timeout);
            }

            if (env?.Any() == true)
            {
                channelArgs.Add("env", env.Remap());
            }

            if (devtools.HasValue)
            {
                channelArgs.Add("devtools", devtools);
            }

            if (slowMo.HasValue)
            {
                channelArgs.Add("slowMo", slowMo);
            }

            if (acceptDownloads.HasValue)
            {
                channelArgs.Add("acceptDownloads", acceptDownloads);
            }

            if (ignoreHTTPSErrors.HasValue)
            {
                channelArgs.Add("ignoreHTTPSErrors", ignoreHTTPSErrors);
            }

            if (bypassCSP.HasValue)
            {
                channelArgs.Add("bypassCSP", bypassCSP);
            }

            if (ViewportSize.NoViewport.Equals(viewportSize))
            {
                channelArgs.Add("noDefaultViewport", true);
            }
            else if (viewportSize != null && !ViewportSize.Default.Equals(viewportSize))
            {
                channelArgs.Add("viewport", viewportSize);
            }

            if (screenSize != default)
            {
                channelArgs.Add("screensize", screenSize);
            }

            if (!string.IsNullOrEmpty(userAgent))
            {
                channelArgs.Add("userAgent", userAgent);
            }

            if (deviceScaleFactor.HasValue)
            {
                channelArgs.Add("deviceScaleFactor", deviceScaleFactor);
            }

            if (isMobile.HasValue)
            {
                channelArgs.Add("isMobile", isMobile);
            }

            if (hasTouch.HasValue)
            {
                channelArgs.Add("hasTouch", hasTouch);
            }

            if (javaScriptEnabled.HasValue)
            {
                channelArgs.Add("javaScriptEnabled", javaScriptEnabled);
            }

            if (!string.IsNullOrEmpty(timezoneId))
            {
                channelArgs.Add("timezoneId", timezoneId);
            }

            if (geolocation != default)
            {
                channelArgs.Add("geolocation", geolocation);
            }

            if (!string.IsNullOrEmpty(locale))
            {
                channelArgs.Add("locale", locale);
            }

            if (permissions != null && permissions.Any())
            {
                channelArgs.Add("permissions", permissions);
            }

            if (extraHTTPHeaders != null && extraHTTPHeaders.Any())
            {
                channelArgs.Add("extraHTTPHeaders", extraHTTPHeaders.Remap());
            }

            if (offline.HasValue)
            {
                channelArgs.Add("offline", offline);
            }

            if (httpCredentials != default)
            {
                channelArgs.Add("httpCredentials", httpCredentials);
            }

            if (colorScheme != ColorScheme.Undefined)
            {
                channelArgs.Add("colorScheme", colorScheme);
            }

            if (!string.IsNullOrEmpty(recordHarPath))
            {
                channelArgs.Add("recordHar", new
                {
                    Path        = recordHarPath,
                    OmitContent = recordHarOmitContent.GetValueOrDefault(false),
                });
            }

            if (!string.IsNullOrEmpty(recordVideoDir) &&
                recordVideoDir != null)
            {
                channelArgs.Add("recordVideo", new Dictionary <string, object>()
                {
                    { "dir", recordVideoDir },
                    { "size", recordVideoSize },
                });
            }

            if (ignoreDefaultArgs != null && ignoreDefaultArgs.Any())
            {
                channelArgs.Add("ignoreDefaultArgs", ignoreDefaultArgs);
            }

            if (ignoreAllDefaultArgs.HasValue)
            {
                channelArgs.Add("ignoreAllDefaultArgs", ignoreAllDefaultArgs);
            }

            channelArgs.Add("sdkLanguage", "csharp");

            return(Connection.SendMessageToServerAsync <BrowserContextChannel>(Guid, "launchPersistentContext", channelArgs, false));
        }
示例#13
0
 public void OnResize(ViewportSize newSize)
 {
     ViewportSize = newSize;
     OnViewportSizeChanged();
 }
示例#14
0
 protected override float GetDimension(ViewportSize size) => size.ScaledHeight;
示例#15
0
 public void OnResize(ViewportSize viewportSize)
 {
     Compositor.SetViewportSize(viewportSize);
 }
示例#16
0
 public void OnResize(ViewportSize viewportSize)
 {
     screenX.OnResize(viewportSize);
     screenY.OnResize(viewportSize);
 }
示例#17
0
 protected override float GetDimension(ViewportSize size) => size.Width;
示例#18
0
        internal Task <BrowserContextChannel> NewContextAsync(
            bool?acceptDownloads        = null,
            bool?bypassCSP              = null,
            ColorScheme?colorScheme     = null,
            ReducedMotion?reducedMotion = null,
            ForcedColors?forcedColors   = null,
            float?deviceScaleFactor     = null,
            IEnumerable <KeyValuePair <string, string> > extraHTTPHeaders = null,
            Geolocation geolocation         = null,
            bool?hasTouch                   = null,
            HttpCredentials httpCredentials = null,
            bool?ignoreHTTPSErrors          = null,
            bool?isMobile                   = null,
            bool?javaScriptEnabled          = null,
            string locale                   = null,
            bool?offline = null,
            IEnumerable <string> permissions = null,
            Proxy proxy = null,
            bool?recordHarOmitContent = null,
            string recordHarPath      = null,
            Dictionary <string, object> recordVideo = null,
            string storageState       = null,
            string storageStatePath   = null,
            string timezoneId         = null,
            string userAgent          = null,
            ViewportSize viewportSize = default,
            ScreenSize screenSize     = default,
            string baseUrl            = default,
            bool?strictSelectors      = default)
        {
            var args = new Dictionary <string, object>
            {
                { "acceptDownloads", acceptDownloads },
                { "bypassCSP", bypassCSP },
                { "colorScheme", colorScheme },
                { "reducedMotion", reducedMotion },
                { "deviceScaleFactor", deviceScaleFactor },
            };

            if (extraHTTPHeaders != null)
            {
                args["extraHTTPHeaders"] = extraHTTPHeaders.Select(kv => new HeaderEntry {
                    Name = kv.Key, Value = kv.Value
                }).ToArray();
            }

            args.Add("geolocation", geolocation);
            args.Add("hasTouch", hasTouch);
            args.Add("httpCredentials", httpCredentials);
            args.Add("ignoreHTTPSErrors", ignoreHTTPSErrors);
            args.Add("isMobile", isMobile);
            args.Add("javaScriptEnabled", javaScriptEnabled);
            args.Add("locale", locale);
            args.Add("offline", offline);
            args.Add("permissions", permissions);
            args.Add("proxy", proxy);
            args.Add("strictSelectors", strictSelectors);
            args.Add("forcedColors", forcedColors);

            if (!string.IsNullOrEmpty(recordHarPath))
            {
                args.Add("recordHar", new
                {
                    Path        = recordHarPath,
                    OmitContent = recordHarOmitContent,
                });
            }

            if (recordVideo != null)
            {
                args.Add("recordVideo", recordVideo);
            }

            if (!string.IsNullOrEmpty(storageStatePath))
            {
                if (!File.Exists(storageStatePath))
                {
                    throw new PlaywrightException($"The specified storage state file does not exist: {storageStatePath}");
                }

                storageState = File.ReadAllText(storageStatePath);
            }

            if (!string.IsNullOrEmpty(storageState))
            {
                args.Add("storageState", JsonSerializer.Deserialize <StorageState>(storageState, Helpers.JsonExtensions.DefaultJsonSerializerOptions));
            }

            args.Add("timezoneId", timezoneId);
            args.Add("userAgent", userAgent);

            if (viewportSize?.Width == -1)
            {
                args.Add("noDefaultViewport", true);
            }
            else
            {
                args.Add("viewport", viewportSize);
                args.Add("screen", screenSize);
            }

            args.Add("baseURL", baseUrl);

            return(Connection.SendMessageToServerAsync <BrowserContextChannel>(
                       Guid,
                       "newContext",
                       args));
        }
示例#19
0
        internal Task <BrowserContextChannel> LaunchPersistentContextAsync(
            string userDataDir,
            bool?headless             = default,
            string channel            = default,
            string executablePath     = default,
            IEnumerable <string> args = default,
            Proxy proxy          = default,
            string downloadsPath = default,
            string tracesDir     = default,
            bool?chromiumSandbox = default,
            bool?handleSIGINT    = default,
            bool?handleSIGTERM   = default,
            bool?handleSIGHUP    = default,
            float?timeout        = default,
            IEnumerable <KeyValuePair <string, string> > env = default,
            bool?devtools                    = default,
            float?slowMo                     = default,
            bool?acceptDownloads             = default,
            bool?ignoreHTTPSErrors           = default,
            bool?bypassCSP                   = default,
            ViewportSize viewportSize        = default,
            ScreenSize screenSize            = default,
            string userAgent                 = default,
            float?deviceScaleFactor          = default,
            bool?isMobile                    = default,
            bool?hasTouch                    = default,
            bool?javaScriptEnabled           = default,
            string timezoneId                = default,
            Geolocation geolocation          = default,
            string locale                    = default,
            IEnumerable <string> permissions = default,
            IEnumerable <KeyValuePair <string, string> > extraHTTPHeaders = default,
            bool?offline = default,
            HttpCredentials httpCredentials         = default,
            ColorScheme?colorScheme                 = default,
            ReducedMotion?reducedMotion             = default,
            ForcedColors?forcedColors               = default,
            string recordHarPath                    = default,
            bool?recordHarOmitContent               = default,
            Dictionary <string, object> recordVideo = default,
            IEnumerable <string> ignoreDefaultArgs  = default,
            bool?ignoreAllDefaultArgs               = default,
            string baseUrl       = default,
            bool?strictSelectors = default)
        {
            var channelArgs = new Dictionary <string, object>
            {
                { "userDataDir", userDataDir },
                { "headless", headless },
                { "channel", channel },
                { "executablePath", executablePath },
                { "args", args },
                { "downloadsPath", downloadsPath },
                { "tracesDir", tracesDir },
                { "proxy", proxy },
                { "chromiumSandbox", chromiumSandbox },
                { "handleSIGINT", handleSIGINT },
                { "handleSIGTERM", handleSIGTERM },
                { "handleSIGHUP", handleSIGHUP },
                { "timeout", timeout },
                { "env", env.Remap() },
                { "devtools", devtools },
                { "slowMo", slowMo },
                { "acceptDownloads", acceptDownloads },
                { "ignoreHTTPSErrors", ignoreHTTPSErrors },
                { "bypassCSP", bypassCSP },
                { "strictSelectors", strictSelectors },
            };

            if (viewportSize?.Width == -1)
            {
                channelArgs.Add("noDefaultViewport", true);
            }
            else
            {
                channelArgs.Add("viewport", viewportSize);
            }

            channelArgs.Add("screensize", screenSize);
            channelArgs.Add("userAgent", userAgent);
            channelArgs.Add("deviceScaleFactor", deviceScaleFactor);
            channelArgs.Add("isMobile", isMobile);
            channelArgs.Add("hasTouch", hasTouch);
            channelArgs.Add("javaScriptEnabled", javaScriptEnabled);
            channelArgs.Add("timezoneId", timezoneId);
            channelArgs.Add("geolocation", geolocation);
            channelArgs.Add("locale", locale);
            channelArgs.Add("permissions", permissions);
            channelArgs.Add("extraHTTPHeaders", extraHTTPHeaders.Remap());
            channelArgs.Add("offline", offline);
            channelArgs.Add("httpCredentials", httpCredentials);
            channelArgs.Add("colorScheme", colorScheme);
            channelArgs.Add("reducedMotion", reducedMotion);

            if (!string.IsNullOrEmpty(recordHarPath))
            {
                channelArgs.Add("recordHar", new
                {
                    Path        = recordHarPath,
                    OmitContent = recordHarOmitContent.GetValueOrDefault(false),
                });
            }

            if (recordVideo != null)
            {
                channelArgs.Add("recordVideo", recordVideo);
            }

            channelArgs.Add("ignoreDefaultArgs", ignoreDefaultArgs);
            channelArgs.Add("ignoreAllDefaultArgs", ignoreAllDefaultArgs);
            channelArgs.Add("baseURL", baseUrl);
            channelArgs.Add("forcedColors", forcedColors);

            return(Connection.SendMessageToServerAsync <BrowserContextChannel>(Guid, "launchPersistentContext", channelArgs));
        }
示例#20
0
文件: GameCamera.cs 项目: Mattias1/td
 public void OnViewportSizeChanged(ViewportSize viewportSize)
 {
     this.viewportSize = viewportSize;
 }
示例#21
0
 protected abstract float GetDimension(ViewportSize size);