AngleSharp / AngleSharp.Js

:angel: Extends AngleSharp with a .NET-based JavaScript engine.
https://anglesharp.github.io
MIT License
105 stars 23 forks source link

btoa() and atob() are not working #55

Closed RyuzakiH closed 5 years ago

RyuzakiH commented 5 years ago

Description

btoa() and atob() methods are not working despite they're declared here WindowBase64.cs

Steps to Reproduce

  1. Create a console application (.NET Framework 4.6.2)
  2. Run this code (from AngleSharp.Samples)
    
    // We require a custom configuration with JavaScript
    var config = Configuration.Default.WithJs();

// This is our sample source, we will set the title and write on the document var source = @"<!doctype html>

Sample "; var document = BrowsingContext.New(config).OpenAsync(m => m.Content(source)).Result; // Modified HTML will be output Console.WriteLine(document.DocumentElement.OuterHtml); ``` **Expected behavior:** Oputput: (in browser) ```html Simple manipulation... dGVzdA== ``` **Actual behavior:** Output: ```html Simple manipulation... ``` **Environment details:** [Win 10, .NET Framework 4.6.2] It maybe an obvious question as I don't know the way the library works till now, or just don't know the right way to use it. ### Note - To get the javascript error append these lines: ```csharp var service = new JsScriptingService(); var result = service.EvaluateScript(document, "btoa('test')"); Console.WriteLine(result); ``` - **Exception:** System.Reflection.TargetException: 'Object does not match target type.' generated in [EngineExtensions](https://github.com/AngleSharp/AngleSharp.Js/blob/master/src/AngleSharp.Js/Extensions/EngineExtensions.cs#L205) (Call method). - When appending these lines: ```csharp var service = new JsScriptingService(); var result = service.EvaluateScript(document, "btoa"); Console.WriteLine(result); ``` Appended output: ```js function btoa() { [native code] } ``` So, it exists but I can't call it, maybe I'm using it the wrong way.
FlorianRappl commented 5 years ago

Thanks for the report - I'll look into it!

FlorianRappl commented 5 years ago

Landed in devel.