diff --git a/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json b/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json index 42a60d767..75c4f3ded 100644 --- a/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json +++ b/src/PlaywrightSharp.Nunit/TestExpectations/TestExpectations.local.json @@ -197,12 +197,6 @@ "parameters": ["headful"], "expectations": ["FAIL"] }, - { - "testIdPattern": "[emulation-focus.spec.ts] *", - "platforms": ["darwin", "linux", "win32"], - "parameters": ["headful"], - "expectations": ["FAIL"] - }, { "testIdPattern": "[eval-on-selector-all.spec.ts] *", "platforms": ["darwin", "linux", "win32"], diff --git a/src/PlaywrightSharp.Tests/EmulationFocusTests.cs b/src/PlaywrightSharp.Tests/EmulationFocusTests.cs index 03e9bcc8b..53007ca04 100644 --- a/src/PlaywrightSharp.Tests/EmulationFocusTests.cs +++ b/src/PlaywrightSharp.Tests/EmulationFocusTests.cs @@ -36,8 +36,8 @@ await TaskUtils.WhenAll( var popup = popupTask.Result; - Assert.That(await Page.EvaluateAsync("document.hasFocus()"), Is.True); Assert.That(await popup.EvaluateAsync("document.hasFocus()"), Is.True); + Assert.That(await Page.EvaluateAsync("document.hasFocus()"), Is.True); } [PlaywrightTest("emulation-focus.spec.ts", "should provide target for keyboard events")] @@ -128,6 +128,11 @@ public void ShouldNotAffectScreenshots() [Test, Timeout(TestConstants.DefaultTestTimeout)] public async Task ShouldChangeFocusedIframe() { + if (TestConstants.IsFirefox && !TestConstants.IsHeadless) + { + Assert.Ignore("Headed Firefox might lose focus"); + } + await Page.GoToAsync(TestConstants.EmptyPage); var (frame1, frame2) = await TaskUtils.WhenAll( diff --git a/src/PlaywrightSharp.Tests/TestConstants.cs b/src/PlaywrightSharp.Tests/TestConstants.cs index 4804ab2cb..8c177d4c2 100644 --- a/src/PlaywrightSharp.Tests/TestConstants.cs +++ b/src/PlaywrightSharp.Tests/TestConstants.cs @@ -117,6 +117,7 @@ internal static Task LaunchDefaultHeadful( internal static readonly bool IsChromium = Product.Equals(ChromiumProduct, StringComparison.OrdinalIgnoreCase); internal static readonly bool IsMacOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); internal static readonly bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + internal static readonly bool IsHeadless = Convert.ToBoolean(Environment.GetEnvironmentVariable("HEADLESS") ?? "true"); public static readonly IEnumerable NestedFramesDumpResult = new List() {