File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 99using System . Windows . Input ;
1010using GalaSoft . MvvmLight ;
1111using GalaSoft . MvvmLight . Command ;
12+ using System . Threading . Tasks ;
1213
1314namespace CefSharp . Wpf . Example . ViewModels
1415{
@@ -97,6 +98,7 @@ public DownloadItem DownloadItem
9798 public ICommand EvaluateJavaScriptCommand { get ; private set ; }
9899 public ICommand ShowDevToolsCommand { get ; private set ; }
99100 public ICommand CloseDevToolsCommand { get ; private set ; }
101+ public ICommand JavascriptBindingStressTest { get ; private set ; }
100102
101103 public BrowserTabViewModel ( string address )
102104 {
@@ -109,6 +111,20 @@ public BrowserTabViewModel(string address)
109111 EvaluateJavaScriptCommand = new RelayCommand < string > ( EvaluateJavaScript , s => ! String . IsNullOrWhiteSpace ( s ) ) ;
110112 ShowDevToolsCommand = new RelayCommand ( ( ) => webBrowser . ShowDevTools ( ) ) ;
111113 CloseDevToolsCommand = new RelayCommand ( ( ) => webBrowser . CloseDevTools ( ) ) ;
114+ JavascriptBindingStressTest = new RelayCommand ( ( ) =>
115+ {
116+ WebBrowser . Load ( CefExample . BindingTestUrl ) ;
117+ WebBrowser . LoadingStateChanged += ( e , args ) =>
118+ {
119+ if ( args . IsLoading == false )
120+ {
121+ Task . Delay ( 10000 ) . ContinueWith ( t =>
122+ {
123+ WebBrowser . Reload ( ) ;
124+ } ) ;
125+ }
126+ } ;
127+ } ) ;
112128
113129 PropertyChanged += OnPropertyChanged ;
114130
Original file line number Diff line number Diff line change 118118 CommandParameter =" {Binding Text, ElementName=ExecuteJavascriptTextBox}" />
119119 </Grid >
120120 </GroupBox >
121- <GroupBox Header =" Execute Javascript (synchronously) " >
121+ <GroupBox Header =" Execute Javascript" >
122122 <Grid Width =" 300" >
123123 <Grid .RowDefinitions>
124124 <RowDefinition Height =" 75" />
147147 CommandParameter =" {Binding Text, ElementName=EvaluateJavascriptTextBox}" />
148148 <TextBlock Grid.Row=" 2"
149149 Margin =" 6" >Result:</TextBlock >
150- <TextBox Grid.Row=" 3"
151- IsReadOnly =" True"
152- Margin =" 6,0,6,6"
153- Text =" {Binding EvaluateJavaScriptResult}" />
154150 </Grid >
155151 </GroupBox >
152+ <GroupBox Header =" Tests" >
153+ <Button HorizontalAlignment =" Left"
154+ Margin =" 6,0"
155+ Padding =" 5,2"
156+ Command =" {Binding JavascriptBindingStressTest}"
157+ Content =" Javascript Binding Stress Test" />
158+ </GroupBox >
156159 </StackPanel >
157160 <StackPanel
158161 Margin =" 6,3"
You can’t perform that action at this time.
0 commit comments