javascriptcore

Memory leak when using WKScriptMessageHandler

耗尽温柔 提交于 2019-12-20 09:53:45
问题 Not sure if I hit a bug in WebKit or I am doing something horribly wrong, but I can't figure out how to use WKScriptMessageHandler without causing whatever value contained in WKScriptMessage.body to leak. I was able to put together a minimum Mac project to isolate the issue, but to no avail. In the main view controller: class ViewController: NSViewController { var webView: WKWebView? override func viewDidLoad() { super.viewDidLoad() let userContentController = WKUserContentController()

How to include a external library in JavaScriptCore?

眉间皱痕 提交于 2019-12-19 04:01:19
问题 I am trying to load a external library via JavaScriptCore Specifically I want the end result of this: <script src="fancyLibrary.js" type="text/javascript"></script> But with the syntax of this: JSContext *context = [[JSContext alloc] initWithVirtualMachine:[[JSVirtualMachine alloc] init]]; [context loadExternalJavascriptFileWithName:@"fancyLibrary.js"]; JSValue *fancyFunction = context[@"fancy"]; Is this possible at the current time? I figure I can include the external library in the app

Alternative to v8 for exposing C++ objects to JavaScript (on PowerPC)

怎甘沉沦 提交于 2019-12-13 03:58:53
问题 I need to expose C++ classes (packed as shared libraries) to the magic world of JavaScript. The most obvious solution is to use Node.js/v8. Problem is that it has to run on PowerPC (please no comments on this...) and - alas! - v8 doesn't run on PowerPC (the v8-powerpc project seems to be dead). I'm trying to understand if there's any other viable solution, at the moment some possibilities are: emscripten, which converts LLVM bitcode into JavaScript; WebKit's JavaScriptCore, although I'm not

Binding native objects with JavascriptCore C Api

好久不见. 提交于 2019-12-11 15:48:22
问题 I'm working on a project that is going to use JavascriptCore to run javascript in a native app. I'm able to bind a C native object with the JSClassDefinition class and set up the static functions and values that I want to export to Javascript. My problem now is that I want to bind a struct that has attributes of type other structs. The code that works is this : struct Person { string name; string lastName; int age; int salary; int getSalary() { return salary; } }; ....... JSClassRef

WebKit2.JavascriptResult.get_value() throws exception “TypeError: Couldn't find foreign struct converter for 'JavaScriptCore.Value'”.

跟風遠走 提交于 2019-12-11 13:52:47
问题 I am writing a python3 + webkit2 + gtk3 based GUI. Everything works fine, but when I tried to use WebKit2.WebView.run_javascript_finish() in a callback function, getting the return (a WebKit2.JavascriptResult objetc), e extrat the value with WebKit2.JavascriptResult.get_value(), I received a "TypeError: Couldn't find foreign struct converter for 'JavaScriptCore.Value'". I have a "from gi.repository import JavaScriptCore" on the imports, and I dont know why this error is occuring. ps: Sorry

How to access a JSCValue Object's properties

◇◆丶佛笑我妖孽 提交于 2019-12-11 10:54:26
问题 With the following code: #include <webkit2/webkit-web-extension> /* Skipping through a lot of code */ { JSCValue* result = jsc_context_evalutate(jsCtx, "document.getElementsByTagName('body')", -1); std::cout << jsc_value_to_string(jsc_value_object_get_property_at_index(result, 0)) << "\n"; if (jsc_value_object_is_instance_of(result, "HTMLBodyElement")) std::cout << "Instance of HTMLBodyElement\n"; } I get [object HTMLBodyElement] printed but not Instance of HTMLBodyElement . I have a few

JavaScriptCore crash on iOS9

旧城冷巷雨未停 提交于 2019-12-11 03:34:01
问题 Encountering a crash for a iOS9 only. The crash is manifesting in JavaScriptCore though I'm not certain it has anything to do with JavaScriptCore. I'm more inclined to believe this is an issue with memory exhaustion more specifically and possible virtual memory exhaustion. As noted in the screenshot free RAM is exceptionally low so it's definitely not an ideal situation. I don't know enough about iOS internals to entirely what's going on here but wondering if there's others out there who have

Raising an Exception from Objective-C back to Javascript

爷,独闯天下 提交于 2019-12-11 02:17:12
问题 JavascriptCore permits us to expose our Objective-C classes to javascript via the JSExport protocol. Let's say, in one of the exposed Objective-C class's methods, a condition is encountered where it makes sense to raise an exception. Is there a way to create said exception and raise it such that the javascript code can process it as it would process a regular javascript exception? I tried doing a regular old [NSException raise...] and that immediately caused a crash. Am I relegated to

JavaScriptCore — Passing a function as a parameter to ObjC

纵然是瞬间 提交于 2019-12-08 07:35:33
问题 I have a UIWebView that utilizes JavaScriptCore. I'm trying to call an ObjC function from an web page. However, the function needs to be call asynchronously, so I'm passing in a callback function that is called when the async ObjC function is called. It is my understanding that JS functions are equivalent to NSBlock via the bridge. The current code I have is: context[@"currentUserLocation"] = ^( void(^callback)(NSString* str) ) { NSLog(@"Starting Async Function"); //generic async function

Using JSContextGroupSetExecutionTimeLimit in iOS

≯℡__Kan透↙ 提交于 2019-12-07 16:04:03
问题 I need to stop the execution of Javascript in a JSContext object? I found the following method which exactly what I need @function @abstract Sets the script execution time limit. @param group The JavaScript context group that this time limit applies to. @param limit The time limit of allowed script execution time in seconds. @param callback The callback function that will be invoked when the time limit has been reached. This will give you a chance to decide if you want to terminate the script