Giter Site home page Giter Site logo

Comments (8)

chillitom avatar chillitom commented on May 11, 2024

makes sense. want to provide a patch and test?

from cefsharp.

ataranto avatar ataranto commented on May 11, 2024

coming up. what kind of test?

from cefsharp.

chillitom avatar chillitom commented on May 11, 2024

if it's not a complete pain to set up then a couple of unit tests that RunScript behaves as expected for null/undefined and empty would be great

from cefsharp.

chillitom avatar chillitom commented on May 11, 2024

The big problem here is how to handle the exception/error path, without this we can't report errors to users. Unfortunately CEF is a little lacking here; Marshall suggested trying to watch for errors in the js console but this seems like quite a hack and would break if errors were sent to the console from within code. You're completely right that empty should be allowed though for cases with no return value. It is a shame that null and undefined are distinct from no value. I'm not sure what to do about this.

from cefsharp.

ataranto avatar ataranto commented on May 11, 2024

one crude solution would be to have separate api for running javascript that the caller expects to return a value and javascript that does not return a value.

RunScript();
RunScriptAndReturnObject();

i'm not a huge fan of this, though.

from cefsharp.

chillitom avatar chillitom commented on May 11, 2024

We could petition (or better still patch) Webkit to include a method which returns both the result and any exception that occurred, perhaps even along with a stack trace, err line no etc. if that's possible.

This would be far superior for both the success and error code paths.

from cefsharp.

chillitom avatar chillitom commented on May 11, 2024

n.b. this might not be feasible due to the several frames of WebFrameImpl between CEF and ScriptController

from cefsharp.

ataranto avatar ataranto commented on May 11, 2024

datapoint: both cocoa's WebView control and QT's QWebView control have a method that executes javascript and may return null (or equivalent) for both an execution failure or success.

from cefsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.