Beispiel #1
0
        public async Task ShouldWorkWithMixedContent()
        {
            HttpsServer.SetRoute("/mixedcontent.html", async(context) =>
            {
                await context.Response.WriteAsync($"<iframe src='{TestConstants.EmptyPage}'></iframe>");
            });
            await using var context = await Browser.NewContextAsync(new BrowserContextOptions { IgnoreHTTPSErrors = true });

            var page = await context.NewPageAsync();

            await page.GoToAsync(TestConstants.HttpsPrefix + "/mixedcontent.html", LifecycleEvent.DOMContentLoaded);

            Assert.Equal(2, page.Frames.Length);
            Assert.Equal(3, await page.MainFrame.EvaluateAsync <int>("1 + 2"));
            Assert.Equal(5, await page.FirstChildFrame().EvaluateAsync <int>("2 + 3"));
        }
        public async Task ShouldWorkWithMixedContent()
        {
            HttpsServer.SetRoute("/mixedcontent.html", async(context) =>
            {
                await context.Response.WriteAsync($"<iframe src='{Server.EmptyPage}'></iframe>");
            });
            await using var context = await Browser.NewContextAsync(new() { IgnoreHTTPSErrors = true });

            var page = await context.NewPageAsync();

            await page.GotoAsync(HttpsServer.Prefix + "/mixedcontent.html", new() { WaitUntil = WaitUntilState.DOMContentLoaded });

            Assert.AreEqual(2, page.Frames.Count);
            Assert.AreEqual(3, await page.MainFrame.EvaluateAsync <int>("1 + 2"));
            Assert.AreEqual(5, await page.FirstChildFrame().EvaluateAsync <int>("2 + 3"));
        }
        public async Task ShouldWorkWithMixedContent()
        {
            HttpsServer.SetRoute("/mixedcontent.html", async(context) =>
            {
                await context.Response.WriteAsync($"<iframe src='{TestConstants.EmptyPage}'></iframe>");
            });
            var page = await NewPageAsync(new BrowserContextOptions { IgnoreHTTPSErrors = true });

            await page.GoToAsync(TestConstants.HttpsPrefix + "/mixedcontent.html", new GoToOptions
            {
                WaitUntil = new[] { WaitUntilNavigation.Load }
            });

            Assert.Equal(2, page.Frames.Length);
            Assert.Equal(3, await page.MainFrame.EvaluateAsync <int>("1 + 2"));
            Assert.Equal(5, await page.FirstChildFrame().EvaluateAsync <int>("2 + 3"));
        }
        public async Task ShouldWorkWithMixedContent()
        {
            HttpsServer.SetRoute("/mixedcontent.html", async(context) =>
            {
                await context.Response.WriteAsync($"<iframe src='{TestConstants.EmptyPage}'></iframe>");
            });
            await Page.GoToAsync(TestConstants.HttpsPrefix + "/mixedcontent.html", new NavigationOptions
            {
                WaitUntil = new[] { WaitUntilNavigation.Load }
            });

            Assert.Equal(2, Page.Frames.Length);
            // Make sure blocked iframe has functional execution context
            // @see https://github.com/GoogleChrome/puppeteer/issues/2709
            Assert.Equal(3, await Page.MainFrame.EvaluateExpressionAsync <int>("1 + 2"));
            Assert.Equal(5, await Page.FirstChildFrame().EvaluateExpressionAsync <int>("2 + 3"));
        }