A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/AngleSharp/AngleSharp.Js/issues/50 below:

JavaScript DOMContentLoaded not triggered after upgrading Jint · Issue #50 · AngleSharp/AngleSharp.Js · GitHub

Hi,

We recently upgraded to the latest version of jint (from 2.10.4 --> 2.11.58) and noticed that the test below breaks. It looks like the DOMContentLoaded event is not triggered and the original HTML document never gets modified when it's loaded.

public void ExecuteOnLoadJavaScriptTest()
{
    // arrange
    var html = "<html><head></head><body><div id='status'>FAILED</div></body>" +
        "<script>document.addEventListener('DOMContentLoaded', function() { var element = document.getElementById('status'); element.innerHTML = 'SUCCESS'; });</script></html>";

    // act
    var config = Configuration.Default.WithJavaScript();
    var parser = new HtmlParser(config);
    var document = parser.Parse(html);
    while (document.ReadyState != DocumentReadyState.Complete)
    {
        // javascript processing is asynchronous, need to wait until document state is complete
        Thread.Sleep(100);
    }
    var result = document.DocumentElement.OuterHtml;

    // assert
    result.Should().StartWith("<html><head></head><body><div id=\"status\">SUCCESS</div>");
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4