I am trying to get Jint engine from the javascript service. However, when there is no script tag with a body, GetJint
method returns null. I can get Jint engine after adding a script dynamically or including a script tag with body at start. It can be tested with following method.
[TestMethod] public async Task JintTest() { var cfg = Configuration.Default.WithJavaScript().WithDefaultLoader(); var svc = cfg.Services.OfType<ScriptingService>().FirstOrDefault(x => x.Engine.Type == "text/javascript"); var htmlEmpty = "<!doctype html><script type=\"text/javascript\"></script>"; var htmlNonEmpty = "<!doctype html><script type=\"text/javascript\">a=5</script>"; var document = await BrowsingContext.New(cfg).OpenAsync(m => m.Content(htmlNonEmpty)); Assert.IsNotNull(svc.Engine.GetJint(document), "Can't get Jint when the script tag is not empty"); document = await BrowsingContext.New(cfg).OpenAsync(m => m.Content(htmlEmpty)); Assert.IsNotNull(svc.Engine.GetJint(document), "Can't get Jint when the script tag is empty"); // Currently error is here var script = document.CreateElement("script"); script.SetAttribute("type","text/javascript"); script.TextContent = "a=5"; document.Head.AppendChild(script); Assert.IsNotNull(svc.Engine.GetJint(document), "Can't get Jint even after dynamically adding the script"); }
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