<title>Testing Sample Page</title>\r
<script>\r
function submitForm() {\r
- document.getElementById('formContent').submit();\r
+ document.forms[0].submit();\r
}\r
</script>\r
</head>\r
<body>\r
- <h1>Sample HTML</h1>\r
- <p>This is sample html page to be used in test suite when loading of a page is required.</p>\r
- <form id="formContent" action="http://jkorpela.fi/cgi-bin/echo.cgi" method="post">\r
- <P>\r
- Type something:<br>\r
-<textarea rows=5 cols=72 name=Comments>\r
-This is\r
-some text\r
-in several lines.\r
-</textarea>\r
- <p>\r
- <input type="checkbox" name="box" value="yes">Check me!\r
- <P>\r
- <input type="hidden" name="hidden field" value="something">\r
- <input type="submit" value="Send">\r
+ <form action="form_submit_sample.html" method="post">\r
+ <input name="a" value="b">\r
+ <input id="mysubmit" type="submit" name="Submit" value="Submit">\r
</form>\r
</body>\r
-</html>
\ No newline at end of file
+</html>\r
Assert.IsTrue(result, "LoadUrl method failed");
- TaskCompletionSource<bool> tcsEval = new TaskCompletionSource<bool>(false);
- EventHandler onLoadFinishedEval = (s, e) => { tcsEval.TrySetResult(true); };
- EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorEval = (s, e) => { tcsEval.TrySetResult(false); };
+ TaskCompletionSource<bool> tcsSubmit = new TaskCompletionSource<bool>(false);
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ if (e.NavigationType == NavigationType.FormSubmitted)
+ {
+ tcsSubmit.TrySetResult(true);
+ return;
+ }
+ tcsSubmit.TrySetResult(false);
+ };
- _webView.LoadFinished += onLoadFinishedEval;
- _webView.LoadError += onLoadErrorEval;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
_webView.Eval("submitForm()");
- result = await tcsEval.Task;
+ result = await tcsSubmit.Task;
- _webView.LoadFinished -= onLoadFinishedEval;
- _webView.LoadError -= onLoadErrorEval;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
Assert.IsTrue(result, "Eval method failed");
- TaskCompletionSource<bool> tcsGoBack = new TaskCompletionSource<bool>(false);
- EventHandler onLoadFinishedGoBack = (s, e) => { tcsGoBack.TrySetResult(true); };
- EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorGoBack = (s, e) => { tcsGoBack.TrySetResult(false); };
-
- _webView.LoadFinished += onLoadFinishedGoBack;
- _webView.LoadError += onLoadErrorGoBack;
-
- _webView.GoBack();
- result = await tcsGoBack.Task;
-
- _webView.LoadFinished -= onLoadFinishedGoBack;
- _webView.LoadError -= onLoadErrorGoBack;
-
- Assert.IsTrue(result, "GoBack method failed");
-
/* TEST CODE */
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
- EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ onNavigationPolicyDecide = (s, e) =>
{
- Log.Debug("TCT", "NavigationType: " + e.NavigationType.ToString());
if (e.NavigationType == NavigationType.FormResubmitted)
{
tcs.TrySetResult(true);
+ return;
}
+ tcs.TrySetResult(false);
};
_webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
- _webView.GoForward();
+ _webView.Reload();
result = await tcs.Task;
_webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;