public bool IsPromise(ICefV8Value v8Value, ICefV8Context context) { using (new ContextHelper(context)) using (var global = context.GetGlobal()) using (var s = global.GetValue(HelperObjectName)) { var userData = s.GetUserData() as PromiseUserData; var isPromise = userData.IsPromise; using (var result = isPromise.ExecuteFunction(null, new[] { v8Value })) { return(result.GetBoolValue()); } } }
public void Then(ICefV8Value promise, ICefV8Context context, Action <PromiseResult> continuation) { var id = pendingPromises.Save(context.GetFrame().Identifier, new PendingPromise { Continuation = continuation }); using (new ContextHelper(context)) using (var global = context.GetGlobal()) using (var s = global.GetValue(HelperObjectName)) { var userData = s.GetUserData() as PromiseUserData; var waitForPromise = userData.WaitForPromise; using (var idValue = CefV8Value.CreateString(id.ToString())) { waitForPromise.ExecuteFunctionWithContext(context, null, new[] { promise, idValue }).Dispose(); } } }