Skip to content

Commit

Permalink
Move some chromium specific tests (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored and Meir017 committed Mar 17, 2019
1 parent 26af946 commit 2ef86e3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Xunit;
using Xunit.Abstractions;

namespace PuppeteerSharp.Tests.ConnectionsTests
namespace PuppeteerSharp.Tests.ChromiumSpecificTests
{
[Collection("PuppeteerLoaderFixture collection")]
public class BrowserUrlOptionTests : PuppeteerPageBaseTest
Expand Down
40 changes: 40 additions & 0 deletions lib/PuppeteerSharp.Tests/ChromiumSpecificTests/PageTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Xunit;
using Xunit.Abstractions;

namespace PuppeteerSharp.Tests.ChromiumSpecificTests
{
[Collection("PuppeteerLoaderFixture collection")]
public class PageTests : PuppeteerPageBaseTest
{
public PageTests(ITestOutputHelper output) : base(output)
{
}

[Fact]
public async Task ShouldWorkWithInterventionHeaders()
{
Server.SetRoute("/intervention", context => context.Response.WriteAsync($@"
<script>
document.write('<script src=""{TestConstants.CrossProcessHttpPrefix}/intervention.js"">' + '</scr' + 'ipt>');
</script>
"));
Server.SetRedirect("/intervention.js", "/redirect.js");

string interventionHeader = null;
Server.SetRoute("/redirect.js", context =>
{
interventionHeader = context.Request.Headers["intervention"];
return context.Response.WriteAsync("console.log(1);");
});

await Page.SetRequestInterceptionAsync(true);
Page.Request += async (sender, e) => await e.Request.ContinueAsync();

await Page.GoToAsync(TestConstants.ServerUrl + "/intervention");

Assert.Contains("www.chromestatus.com", interventionHeader);
}
}
}
25 changes: 0 additions & 25 deletions lib/PuppeteerSharp.Tests/PageTests/SetRequestInterceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,6 @@ public async Task ShouldIntercept()
Assert.Equal(TestConstants.Port, response.RemoteAddress.Port);
}

[Fact]
public async Task ShouldWorkWithInterventionHeaders()
{
Server.SetRoute("/intervention", context => context.Response.WriteAsync($@"
<script>
document.write('<script src=""{TestConstants.CrossProcessHttpPrefix}/intervention.js"">' + '</scr' + 'ipt>');
</script>
"));
Server.SetRedirect("/intervention.js", "/redirect.js");

string interventionHeader = null;
Server.SetRoute("/redirect.js", context =>
{
interventionHeader = context.Request.Headers["intervention"];
return context.Response.WriteAsync("console.log(1);");
});

await Page.SetRequestInterceptionAsync(true);
Page.Request += async (sender, e) => await e.Request.ContinueAsync();

await Page.GoToAsync(TestConstants.ServerUrl + "/intervention");

Assert.Contains("www.chromestatus.com", interventionHeader);
}

[Fact]
public async Task ShouldWorkWhenPostIsEedirectedWith302()
{
Expand Down

0 comments on commit 2ef86e3

Please sign in to comment.