Skip to content

Commit 57d60e9

Browse files
committed
WPF - Add basic JavascriptBindingStressTest command
Loads JSB test page and then reloads every 10 seconds
1 parent b9e4c4f commit 57d60e9

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

CefSharp.Wpf.Example/ViewModels/BrowserTabViewModel.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Windows.Input;
1010
using GalaSoft.MvvmLight;
1111
using GalaSoft.MvvmLight.Command;
12+
using System.Threading.Tasks;
1213

1314
namespace 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

CefSharp.Wpf.Example/Views/BrowserTabView.xaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
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" />
@@ -147,12 +147,15 @@
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"

0 commit comments

Comments
 (0)