Skip to content

Commit 1153fff

Browse files
DominicBoettgerkblok
authored andcommitted
Linux support (#795)
1 parent bd515aa commit 1153fff

File tree

15 files changed

+176
-21
lines changed

15 files changed

+176
-21
lines changed

appveyor-linux.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: 1.0.{build}
2+
image: ubuntu1804
3+
configuration: Release
4+
environment:
5+
git_access_token:
6+
secure: FxcQ9C8a/NgcQB5dFdZts6ZWEDT4zMhA4qPQAYwWc7huMmhmTIl1sbFEIaAWQMTL
7+
matrix:
8+
- framework: netcoreapp2.0
9+
10+
before_build:
11+
- sh: >-
12+
sudo apt-get -y install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget xvfb
13+
14+
dotnet restore lib/PuppeteerSharp.sln
15+
16+
dotnet dev-certs https -ep lib/PuppeteerSharp.TestServer/testCert.cer
17+
18+
sudo openssl x509 -inform der -in lib/PuppeteerSharp.TestServer/testCert.cer -out /usr/local/share/ca-certificates/testCert.crt -outform pem
19+
20+
sudo update-ca-certificates
21+
22+
build_script:
23+
- sh: >-
24+
dotnet build -f $framework ./lib/PuppeteerSharp.Tests.CloseMe/PuppeteerSharp.Tests.CloseMe.csproj
25+
26+
dotnet build -f $framework ./lib/PuppeteerSharp.DevicesFetcher/PuppeteerSharp.DevicesFetcher.csproj
27+
28+
dotnet build -f $framework ./lib/PuppeteerSharp.Tests.DumpIO/PuppeteerSharp.Tests.DumpIO.csproj
29+
30+
dotnet build ./lib/PuppeteerSharp.TestServer/PuppeteerSharp.TestServer.csproj
31+
32+
dotnet build -f $framework ./lib/PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj
33+
34+
test_script:
35+
- sh: >-
36+
Xvfb :1 -screen 5 1024x768x8 &
37+
38+
export DISPLAY=:1.5
39+
40+
cd lib/PuppeteerSharp.Tests
41+
42+
dotnet test -f $framework -s test.runsettings
43+
44+
cache:
45+
- $HOME/.nuget/packages

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ on_success:
3939
4040
c:\projects\puppeteer-sharp\appveyor\GenerateDocs.ps1
4141
cache:
42-
- $HOME/.nuget/packages
42+
- $HOME/.nuget/packages

lib/PuppeteerSharp.Tests/FrameTests/FrameManagementTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public async Task ShouldSendEventsWhenFramesAreManipulatedDynamically()
3131

3232
Page.FrameAttached += (sender, e) => attachedFrames.Add(e.Frame);
3333

34-
await FrameUtils.AttachFrameAsync(Page, "frame1", "./assets/frame.html");
34+
await FrameUtils.AttachFrameAsync(Page, "frame1", "./Assets/frame.html");
3535

3636
Assert.Single(attachedFrames);
37-
Assert.Contains("/assets/frame.html", attachedFrames[0].Url);
37+
Assert.Contains("/Assets/frame.html", attachedFrames[0].Url);
3838

3939
// validate framenavigated events
4040
var navigatedFrames = new List<Frame>();

lib/PuppeteerSharp.Tests/InputTests/InputTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public async Task ShouldClickTheButtonAfterNavigation()
166166
public async Task ShouldUploadTheFile()
167167
{
168168
await Page.GoToAsync(TestConstants.ServerUrl + "/input/fileupload.html");
169-
var filePath = "./assets/file-to-upload.txt";
169+
var filePath = "./Assets/file-to-upload.txt";
170170
var input = await Page.QuerySelectorAsync("input");
171171
await input.UploadFileAsync(filePath);
172172
Assert.Equal("file-to-upload.txt", await Page.EvaluateFunctionAsync<string>("e => e.files[0].name", input));

lib/PuppeteerSharp.Tests/PageTests/AddScriptTagTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public async Task ShouldWorkWithAPathAndTypeModule()
4444
await Page.GoToAsync(TestConstants.EmptyPage);
4545
await Page.AddScriptTagAsync(new AddTagOptions
4646
{
47-
Path = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("assets", "es6", "es6pathimport.js")),
47+
Path = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("Assets", "es6", "es6pathimport.js")),
4848
Type = "module"
4949
});
5050
await Page.WaitForFunctionAsync("() => window.__es6injected");
@@ -79,7 +79,7 @@ public async Task ShouldWorkWithAPath()
7979
await Page.GoToAsync(TestConstants.EmptyPage);
8080
var scriptHandle = await Page.AddScriptTagAsync(new AddTagOptions
8181
{
82-
Path = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("assets", "injectedfile.js"))
82+
Path = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("Assets", "injectedfile.js"))
8383
});
8484
Assert.NotNull(scriptHandle as ElementHandle);
8585
Assert.Equal(42, await Page.EvaluateExpressionAsync<int>("__injected"));
@@ -91,10 +91,10 @@ public async Task ShouldIncludeSourcemapWhenPathIsProvided()
9191
await Page.GoToAsync(TestConstants.EmptyPage);
9292
await Page.AddScriptTagAsync(new AddTagOptions
9393
{
94-
Path = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("assets", "injectedfile.js"))
94+
Path = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("Assets", "injectedfile.js"))
9595
});
9696
var result = await Page.EvaluateExpressionAsync<string>("__injectedError.stack");
97-
Assert.Contains(Path.Combine("assets", "injectedfile.js"), result);
97+
Assert.Contains(Path.Combine("Assets", "injectedfile.js"), result);
9898
}
9999

100100
[Fact]

lib/PuppeteerSharp.Tests/PageTests/AddStyleTagTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public async Task ShouldThrowAnErrorIfLoadingFromUrlFail()
4444
public async Task ShouldWorkWithAPath()
4545
{
4646
await Page.GoToAsync(TestConstants.EmptyPage);
47-
var styleHandle = await Page.AddStyleTagAsync(new AddTagOptions { Path = "assets/injectedstyle.css" });
47+
var styleHandle = await Page.AddStyleTagAsync(new AddTagOptions { Path = "Assets/injectedstyle.css" });
4848
Assert.NotNull(styleHandle as ElementHandle);
4949
Assert.Equal("rgb(255, 0, 0)", await Page.EvaluateExpressionAsync<string>(
5050
"window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')"));
@@ -56,11 +56,11 @@ public async Task ShouldIncludeSourcemapWhenPathIsProvided()
5656
await Page.GoToAsync(TestConstants.EmptyPage);
5757
await Page.AddStyleTagAsync(new AddTagOptions
5858
{
59-
Path = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("assets", "injectedstyle.css"))
59+
Path = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("Assets", "injectedstyle.css"))
6060
});
6161
var styleHandle = await Page.QuerySelectorAsync("style");
6262
var styleContent = await Page.EvaluateFunctionAsync<string>("style => style.innerHTML", styleHandle);
63-
Assert.Contains(Path.Combine("assets", "injectedstyle.css"), styleContent);
63+
Assert.Contains(Path.Combine("Assets", "injectedstyle.css"), styleContent);
6464
}
6565

6666
[Fact]

lib/PuppeteerSharp.Tests/PageTests/GotoTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public async Task ShouldFailWhenNavigatingAndShowTheUrlAtTheErrorMessage()
318318
[Fact]
319319
public async Task ResponseOkShouldBeTrueForFile()
320320
{
321-
var fileToNavigate = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("assets", "file-to-upload.txt"));
321+
var fileToNavigate = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("Assets", "file-to-upload.txt"));
322322
var url = new Uri(fileToNavigate).AbsoluteUri;
323323

324324
var response = await Page.GoToAsync(url);

lib/PuppeteerSharp.Tests/PageTests/SetRequestInterceptionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public async Task ShouldWorkWithFileURLs()
524524
await e.Request.ContinueAsync();
525525
};
526526

527-
var uri = new Uri(Path.Combine(Directory.GetCurrentDirectory(), "assets", "one-style.html")).AbsoluteUri;
527+
var uri = new Uri(Path.Combine(Directory.GetCurrentDirectory(), "Assets", "one-style.html")).AbsoluteUri;
528528
await Page.GoToAsync(uri);
529529
Assert.Equal(2, urls.Count);
530530
Assert.Contains("one-style.html", urls);

lib/PuppeteerSharp.Tests/PuppeteerSharp.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
<PropertyGroup>
33
<TargetFrameworks>netcoreapp2.0;net471</TargetFrameworks>
44
<IsPackable>false</IsPackable>
5+
<IsTestProject>true</IsTestProject>
56
</PropertyGroup>
67
<ItemGroup>
78
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
89
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
910
<PackageReference Include="MicrosoftExtensions.Logging.Xunit" Version="1.0.0" />
11+
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
1012
<PackageReference Include="xunit" Version="2.4.0" />
1113
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
1214
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0002" />

lib/PuppeteerSharp.Tests/PuppeteerTests/BrowserFetcherTests.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.IO;
3+
using System.Runtime.InteropServices;
34
using System.Threading.Tasks;
5+
using PuppeteerSharp.Helpers.Linux;
46
using Xunit;
57
using Xunit.Abstractions;
68

@@ -39,7 +41,14 @@ public async Task ShouldDownloadAndExtractLinuxBinary()
3941
revisionInfo = await browserFetcher.DownloadAsync(123456);
4042
Assert.True(revisionInfo.Local);
4143
Assert.Equal("LINUX BINARY\n", File.ReadAllText(revisionInfo.ExecutablePath));
42-
Assert.Equal(new[] {123456}, browserFetcher.LocalRevisions());
44+
45+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
46+
{
47+
Assert.Equal(
48+
BrowserFetcher.BrowserPermissionsInLinux,
49+
LinuxSysCall.GetFileMode(revisionInfo.ExecutablePath) & BrowserFetcher.BrowserPermissionsInLinux);
50+
}
51+
Assert.Equal(new[] { 123456 }, browserFetcher.LocalRevisions());
4352
browserFetcher.Remove(123456);
4453
Assert.Empty(browserFetcher.LocalRevisions());
4554

0 commit comments

Comments
 (0)