Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript events are not firing #34

Closed
mdesousa opened this issue Feb 2, 2017 · 4 comments
Closed

JavaScript events are not firing #34

mdesousa opened this issue Feb 2, 2017 · 4 comments
Milestone

Comments

@mdesousa
Copy link

mdesousa commented Feb 2, 2017

Hi, this is a great project! But I am running into a strange issue. I was not seeing the JavaScript events being fired in my code. I decided to create a new solution with a very simple test that I took from the AngleSharp.Scripting FireEventTests.cs unit tests (see below). The test passes when I run it in the AngleSharp solution but it fails when I run it from my solution. I don't understand how this is possible... am I missing something? Thanks!

    [TestMethod]
    public async Task MainAsyncTest()
    {
        var service = new JavaScriptProvider();
        var cfg = Configuration.Default.With(service);
        var html = "<!doctype html><div id=result>0</div><script>var i = 0; document.addEventListener('hello', function () { i++; document.querySelector('#result').textContent = i.toString(); }, false);</script>";
        var document = await BrowsingContext.New(cfg).OpenAsync(m => m.Content(html));
        var div = document.QuerySelector("#result");
        document.Dispatch(new CustomEvent("hello"));
        Assert.AreEqual("1", div.TextContent);
        document.Dispatch(new CustomEvent("hello"));
        Assert.AreEqual("2", div.TextContent);
    }
@mdesousa
Copy link
Author

mdesousa commented Feb 2, 2017

I think I found the problem... my solution was using the latest version of Jint (2.10.3). The test does not work with that version. When I switch to version 2.9.1, it works fine.

@FlorianRappl
Copy link
Contributor

Thanks for the heads up. I still note it as a bug such that I am forced to release a version asap that works against the latest v2 of Jint.

@FlorianRappl FlorianRappl added this to the v0.6 milestone Feb 2, 2017
@georgiosd
Copy link
Contributor

@mdesousa Can you try with my pull request? #37

@mdesousa
Copy link
Author

mdesousa commented May 7, 2017

The tests work fine now @georgiosd , thanks

@FlorianRappl FlorianRappl modified the milestones: v0.5.1, v0.6 May 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants