diff --git a/src/AngleSharp.Js.Tests/FireEventTests.cs b/src/AngleSharp.Js.Tests/FireEventTests.cs index e468a1f..eac505c 100644 --- a/src/AngleSharp.Js.Tests/FireEventTests.cs +++ b/src/AngleSharp.Js.Tests/FireEventTests.cs @@ -4,6 +4,9 @@ namespace AngleSharp.Js.Tests using AngleSharp.Dom.Events; using AngleSharp.Scripting; using NUnit.Framework; + + using System; + using System.Linq; using System.Threading.Tasks; [TestFixture] @@ -256,6 +259,35 @@ public async Task DocumentLoadEventIsFired_Issue42() Assert.AreEqual("Success!", div?.TextContent); } + [Test] + public async Task DocumentReadyStateIsComplete_Issue86() + { + var cfg = Configuration.Default.WithJs().WithEventLoop(); + var html = @" + +
+ +"; + var context = BrowsingContext.New(cfg); + var document = await context.OpenAsync(m => m.Content(html)) + .WhenStable(); + + var divs = document.GetElementsByTagName("div"); + + // expected value will vary depending on AngleSharp package version + // 1.0.2 and greater, expected value will be { "interactive", "complete" + // prior to 1.0.2, expected value will be { "1", "2" } + var expected = new[] { DocumentReadyState.Interactive, DocumentReadyState.Complete } + .Select(e => e.GetOfficialName() ?? Convert.ToInt32(e).ToString()); + CollectionAssert.AreEqual(expected, divs.Select(d => d.TextContent)); + } + [Test] public async Task SetTimeoutWithStringAsFunction() {