Skip to content

Commit

Permalink
Add missing Firefox preferences (#1933)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Apr 13, 2022
1 parent 4e472ab commit 58e1985
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 43 deletions.
14 changes: 7 additions & 7 deletions lib/PuppeteerSharp.Tests/DragAndDropTests/InputDragTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public InputDragTests(ITestOutputHelper output) : base(output)
}

[PuppeteerTest("drag-and-drop.spec.ts", "Input.drag", "should throw an exception if not enabled before usage")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldThrowAnExceptionIfNotEnabledBeforeUsage()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/drag-and-drop.html");
Expand All @@ -25,7 +25,7 @@ public async Task ShouldThrowAnExceptionIfNotEnabledBeforeUsage()
}

[PuppeteerTest("drag-and-drop.spec.ts", "Input.drag", "should emit a dragIntercepted event when dragged")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldEmitADragInterceptedEventWhenDragged()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/drag-and-drop.html");
Expand All @@ -40,7 +40,7 @@ public async Task ShouldEmitADragInterceptedEventWhenDragged()
}

[PuppeteerTest("drag-and-drop.spec.ts", "Input.drag", "should emit a dragEnter")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldEmitADragEnter()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/drag-and-drop.html");
Expand All @@ -57,7 +57,7 @@ public async Task ShouldEmitADragEnter()
}

[PuppeteerTest("drag-and-drop.spec.ts", "Input.drag", "should emit a dragOver event")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldEmitADragOver()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/drag-and-drop.html");
Expand All @@ -76,7 +76,7 @@ public async Task ShouldEmitADragOver()
}

[PuppeteerTest("drag-and-drop.spec.ts", "Input.drag", "can be dropped")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
[SkipBrowserFact(skipFirefox: true)]
public async Task CanBeDropped()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/drag-and-drop.html");
Expand All @@ -97,7 +97,7 @@ public async Task CanBeDropped()
}

[PuppeteerTest("drag-and-drop.spec.ts", "Input.drag", "can be dragged and dropped with a single function")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
[SkipBrowserFact(skipFirefox: true)]
public async Task CanBeDraggedAndDroppedWithASingleFunction()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/drag-and-drop.html");
Expand All @@ -115,7 +115,7 @@ public async Task CanBeDraggedAndDroppedWithASingleFunction()
}

[PuppeteerTest("drag-and-drop.spec.ts", "Input.drag", "can be disabled")]
[Fact(Timeout = TestConstants.DefaultTestTimeout)]
[SkipBrowserFact(skipFirefox: true)]
public async Task CanBeDisabled()
{
await Page.GoToAsync(TestConstants.ServerUrl + "/input/drag-and-drop.html");
Expand Down
2 changes: 1 addition & 1 deletion lib/PuppeteerSharp.Tests/Issues/Issue1878.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public Issue1878(ITestOutputHelper output) : base(output)
{
}

[PuppeteerFact]
[SkipBrowserFact(skipFirefox: true)]
public async Task MultiplePagesShouldNotShareSameScreenshotTaskQueue()
{
// 1st page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ await Task.WhenAll(
}

[PuppeteerTest("launcher.spec.ts", "Puppeteer.connect", "should support targetFilter option")]
[PuppeteerFact]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldSupportTargetFilter()
{
await using (var originalBrowser = await Puppeteer.LaunchAsync(TestConstants.DefaultBrowserOptions()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public async Task UserDataDirArgument()
}

[PuppeteerTest("launcher.spec.ts", "Puppeteer.launch", "userDataDir option should restore state")]
[PuppeteerFact]
[SkipBrowserFact(skipFirefox: true)]
public async Task UserDataDirOptionShouldRestoreState()
{
using (var userDataDir = new TempDirectory())
Expand Down
39 changes: 12 additions & 27 deletions lib/PuppeteerSharp.Tests/PageTests/WaitForNetworkIdleTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using PuppeteerSharp.Tests.Attributes;
using PuppeteerSharp.Xunit;
Expand Down Expand Up @@ -55,8 +54,10 @@ public async Task ShouldRespectTimeout()
Assert.Contains("Timeout of 1 ms exceeded", exception.Message);
}

// This should work on Firefox, this ignore should be temporal
// PRs are welcome :)
[PuppeteerTest("page.spec.ts", "Page.waitForNetworkIdle", "should respect idleTime")]
[PuppeteerFact]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldRespectIdleTimeout()
{
var t1 = DateTime.Now;
Expand All @@ -67,34 +68,25 @@ public async Task ShouldRespectIdleTimeout()

await Task.WhenAll(
task,
Page.EvaluateFunctionAsync(@"
(async () => {
await Promise.all([
fetch('/digits/1.png'),
fetch('/digits/2.png'),
]);
await new Promise((resolve) => setTimeout(resolve, 250));
})();").ContinueWith(x => t2 = DateTime.Now)
Page.EvaluateFunctionAsync(@"() =>
(async () => {
await Promise.all([
fetch('/digits/1.png'),
fetch('/digits/2.png'),
]);
await new Promise((resolve) => setTimeout(resolve, 250));
})()").ContinueWith(x => t2 = DateTime.Now)
);

Assert.True(t1 > t2);
Assert.True(t2 > t1);
}

[PuppeteerTest("page.spec.ts", "Page.waitForNetworkIdle", "should work with no timeout")]
[PuppeteerFact]
public async Task ShouldWorkWithNoTimeout()
{
var responseCount = 0;
var responseUrls = new List<string>(3);

await Page.GoToAsync(TestConstants.EmptyPage);

Page.FrameManager.NetworkManager.Response += (sender, args) =>
{
responseCount++;
responseUrls.Add(args.Response.Url);
};

await Task.WhenAll(
Page.WaitForNetworkIdleAsync(new WaitForNetworkIdleOptions { Timeout = 0 }),
Page.EvaluateFunctionAsync(@"() => setTimeout(() => {
Expand All @@ -103,13 +95,6 @@ await Task.WhenAll(
fetch('/digits/3.png');
}, 50)")
);

Assert.Equal(3, responseCount);
Assert.All(responseUrls, x =>
{
Assert.StartsWith(TestConstants.ServerUrl + "/digits", x);
Assert.EndsWith(".png", x);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task ShouldRunInSpecifiedFrame()
}

[PuppeteerTest("waittask.spec.ts", "Frame.waitForSelector", "should throw when frame is detached")]
[PuppeteerFact]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldThrowWhenFrameIsDetached()
{
await FrameUtils.AttachFrameAsync(Page, "frame1", TestConstants.EmptyPage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task ShouldRunInSpecifiedFrame()
}

[PuppeteerTest("waittask.spec.ts", "Frame.waitForXPath", "should throw when frame is detached")]
[PuppeteerFact]
[SkipBrowserFact(skipFirefox: true)]
public async Task ShouldThrowWhenFrameIsDetached()
{
await FrameUtils.AttachFrameAsync(Page, "frame1", TestConstants.EmptyPage);
Expand Down
2 changes: 0 additions & 2 deletions lib/PuppeteerSharp/BrowserFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Tar;
using Newtonsoft.Json;
using PuppeteerSharp.Helpers;
using PuppeteerSharp.Helpers.Linux;
Expand Down
7 changes: 5 additions & 2 deletions lib/PuppeteerSharp/FirefoxLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,11 @@ private static void CreateProfile(TempDirectory tempUserDataDirectory)
// Make sure opening about:addons will not hit the network
["extensions.webservice.discoverURL"] = $"http://{server}/dummy/discoveryURL",

// Force disable Fission until the Remote Agent is compatible
["fission.autostart"] = false,
// Temporarily force disable BFCache in parent (https://bit.ly/bug-1732263)
["fission.bfcacheInParent"] = false,

// Force all web content to use a single content process
["fission.webContentIsolationStrategy"] = 0,

// Allow the application to have focus even it runs in the background
["focusmanager.testmode"] = true,
Expand Down

0 comments on commit 58e1985

Please sign in to comment.