protected override void Given() { base.Given(); WebView.IsJavaScriptEnabled = true; WebView.AddInitializeScript($"./non-exist.js"); WebView.NavigationCompleted += (o, e) => { _navSuccess = e.IsSuccess; Form.Close(); }; }
protected override void Given() { base.Given(); WebView.IsScriptNotifyAllowed = true; WebView.IsJavaScriptEnabled = true; WebView.AddInitializeScript("window.external.notify('preload');"); // Set up the event handler WebView.ScriptNotify += (o, e) => { _scriptNotifyCalled = true; Form.Close(); }; }
public WebViewWindow() { DoubleBuffered = true; _browser = new WebView(); _browser.IsJavaScriptEnabled = true; _browser.IsScriptNotifyAllowed = true; _browser.AddInitializeScript(WebAppTemplates.GetPolyfill()); _browser.ScriptNotify += async(sender, wsn) => { if (OnIPC != null) { OnIPC(wsn.Value); } /* * string notify = wsn.Value; * string id = notify.Substring(0, notify.IndexOf(":")); * notify = notify.Substring(notify.IndexOf(":") + 1); * * * Task<object> resultT = null; * if (OnIPC != null) * resultT = OnIPC(notify); * * if (resultT == null) * return; * * //resultT.Wait(); * object result = await resultT;//.Result; * * * if (result != null && result.GetType() == typeof(NoIPCResponse)) * return; * * if(!string.IsNullOrEmpty(id)) * Execute(WebAppTemplates.FormatIf( * $"_IPCResolves[{id}]", * $"_IPCResolves[{id}]({JsonConvert.SerializeObject(result)});")); */ }; this.FormClosing += (a, b) => { Invoke(() => { this.Controls.Remove(_browser); if (_needCleanup) { _browser.Process.Terminate(); _needCleanup = false; } _browser.Dispose(); }); }; AppDomain.CurrentDomain.ProcessExit += (a, b) => { if (_needCleanup) { _browser.Process.Terminate(); } }; _browser.Dock = DockStyle.Fill; Controls.Add(_browser); RegisterInitScript(string.Format(WebContext.LoadStringResource(Assembly.GetExecutingAssembly(), "LogicReinc.WebApp.Mixed.IPCSetup.WebView.js"))); _isReady = true; }
public void RegisterInitScript(string script) { _browser.AddInitializeScript(script); }
public void CannotPassNullForPreLoadScript() { WebView.AddInitializeScript(null); }