3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Threading.Tasks;
7 using System.Collections.Generic;
9 namespace Tizen.NUI.Devel.Tests
11 using tlog = Tizen.Log;
14 [Description("internal/WebView/WebContext")]
15 public class InternalWebContextTest
17 private const string tag = "NUITEST";
18 private string url = $"file://{Tizen.Applications.Application.Current.DirectoryInfo.Resource}webview/index.html";
19 private string urlForDatabase = $"file://{Tizen.Applications.Application.Current.DirectoryInfo.Resource}webview/webdb.html";
20 private string urlForStorage = $"file://{Tizen.Applications.Application.Current.DirectoryInfo.Resource}webview/webstorage.html";
21 private string urlForLocalFileSystem = $"file://{Tizen.Applications.Application.Current.DirectoryInfo.Resource}webview/weblocalfilesystem.html";
22 private string urlForFormPassword = $"file://{Tizen.Applications.Application.Current.DirectoryInfo.Resource}webview/webformpasword.html";
23 private string urlForDownload = "https://codeload.github.com/Samsung/TizenFX/zip/refs/heads/master";
24 private string urlForApplicatonCache = "https://www.google.com/";
26 private BaseComponents.WebView webview_ = null;
28 private bool MimeWrittenCallback(string url, string currentMime, out string newMime)
37 webview_ = new BaseComponents.WebView()
39 Size = new Size(500, 200),
41 tlog.Info(tag, "Init() is called!");
47 tlog.Info(tag, "Destroy() is being called!");
49 tlog.Info(tag, "Destroy() is called!");
54 [Description("WebContext ProxyUrl.")]
55 [Property("SPEC", "Tizen.NUI.WebContext.ProxyUrl A")]
56 [Property("SPEC_URL", "-")]
57 [Property("CRITERIA", "PRW")]
58 [Property("COVPARAM", "")]
59 [Property("AUTHOR", "guowei.wang@samsung.com")]
60 public void WebContextProxyUrl()
62 tlog.Debug(tag, $"WebContextProxyUrl START");
64 var context = webview_.Context;
65 tlog.Debug(tag, "ProxyUrl : " + context.ProxyUrl);
67 context.ProxyUrl = "http://www.baidu.com";
68 tlog.Debug(tag, "ProxyUrl : " + context.ProxyUrl);
72 tlog.Debug(tag, $"WebContextProxyUrl END (OK)");
77 [Description("WebContext CertificateFilePath.")]
78 [Property("SPEC", "Tizen.NUI.WebContext.CertificateFilePath A")]
79 [Property("SPEC_URL", "-")]
80 [Property("CRITERIA", "PRW")]
81 [Property("COVPARAM", "")]
82 [Property("AUTHOR", "guowei.wang@samsung.com")]
83 public void WebContextCertificateFilePath()
85 tlog.Debug(tag, $"WebContextCertificateFilePath START");
87 var context = webview_.Context;
88 tlog.Debug(tag, "CertificateFilePath : " + context.CertificateFilePath);
90 context.CertificateFilePath = url;
91 tlog.Debug(tag, "CertificateFilePath : " + context.CertificateFilePath);
95 tlog.Debug(tag, $"WebContextCertificateFilePath END (OK)");
100 [Description("WebContext CacheEnabled.")]
101 [Property("SPEC", "Tizen.NUI.WebContext.CacheEnabled A")]
102 [Property("SPEC_URL", "-")]
103 [Property("CRITERIA", "PRW")]
104 [Property("COVPARAM", "")]
105 [Property("AUTHOR", "guowei.wang@samsung.com")]
106 public void WebContextCacheEnabled()
108 tlog.Debug(tag, $"WebContextCacheEnabled START");
110 var context = webview_.Context;
111 tlog.Debug(tag, "CacheEnabled : " + context.CacheEnabled);
113 context.CacheEnabled = true;
114 tlog.Debug(tag, "CacheEnabled : " + context.CacheEnabled);
116 context.CacheEnabled = false;
117 tlog.Debug(tag, "CacheEnabled : " + context.CacheEnabled);
121 tlog.Debug(tag, $"WebContextCertificateFilePath END (OK)");
126 [Description("WebContext AppId.")]
127 [Property("SPEC", "Tizen.NUI.WebContext.AppId A")]
128 [Property("SPEC_URL", "-")]
129 [Property("CRITERIA", "PRW")]
130 [Property("COVPARAM", "")]
131 [Property("AUTHOR", "guowei.wang@samsung.com")]
132 public void WebContextAppId()
134 tlog.Debug(tag, $"WebContextAppId START");
136 var context = webview_.Context;
137 tlog.Debug(tag, "AppId : " + context.AppId);
139 context.AppId = "WebContextAppId";
140 tlog.Debug(tag, "AppId : " + context.AppId);
144 tlog.Debug(tag, $"WebContextAppId END (OK)");
149 [Description("WebContext AppVersion.")]
150 [Property("SPEC", "Tizen.NUI.WebContext.AppVersion A")]
151 [Property("SPEC_URL", "-")]
152 [Property("CRITERIA", "PRW")]
153 [Property("COVPARAM", "")]
154 [Property("AUTHOR", "guowei.wang@samsung.com")]
155 public void WebContextAppVersion()
157 tlog.Debug(tag, $"WebContextAppVersion START");
159 var context = webview_.Context;
160 tlog.Debug(tag, "AppVersion : " + context.AppVersion);
162 context.AppVersion = "1.0";
163 tlog.Debug(tag, "AppVersion : " + context.AppVersion);
167 tlog.Debug(tag, $"WebContextAppVersion END (OK)");
172 [Description("WebContext AppType.")]
173 [Property("SPEC", "Tizen.NUI.WebContext.AppType A")]
174 [Property("SPEC_URL", "-")]
175 [Property("CRITERIA", "PRW")]
176 [Property("COVPARAM", "")]
177 [Property("AUTHOR", "guowei.wang@samsung.com")]
178 public void WebContextAppType()
180 tlog.Debug(tag, $"WebContextAppType START");
182 var context = webview_.Context;
183 tlog.Debug(tag, "AppType : " + context.AppType);
185 context.AppType = WebContext.ApplicationType.WebBrowser;
186 tlog.Debug(tag, "AppType : " + context.AppType);
190 tlog.Debug(tag, $"WebContextAppType END (OK)");
195 [Description("WebContext TimeOffset.")]
196 [Property("SPEC", "Tizen.NUI.WebContext.TimeOffset A")]
197 [Property("SPEC_URL", "-")]
198 [Property("CRITERIA", "PRW")]
199 [Property("COVPARAM", "")]
200 [Property("AUTHOR", "guowei.wang@samsung.com")]
201 public void WebContextTimeOffset()
203 tlog.Debug(tag, $"WebContextTimeOffset START");
205 var context = webview_.Context;
206 tlog.Debug(tag, "TimeOffset : " + context.TimeOffset);
208 context.TimeOffset = 0.3f;
209 tlog.Debug(tag, "TimeOffset : " + context.TimeOffset);
213 tlog.Debug(tag, $"WebContextAppType END (OK)");
218 [Description("WebContext DefaultZoomFactor.")]
219 [Property("SPEC", "Tizen.NUI.WebContext.DefaultZoomFactor A")]
220 [Property("SPEC_URL", "-")]
221 [Property("CRITERIA", "PRW")]
222 [Property("COVPARAM", "")]
223 [Property("AUTHOR", "guowei.wang@samsung.com")]
224 public void WebContextDefaultZoomFactor()
226 tlog.Debug(tag, $"WebContextDefaultZoomFactor START");
228 var context = webview_.Context;
229 tlog.Debug(tag, "DefaultZoomFactor : " + context.DefaultZoomFactor);
231 context.DefaultZoomFactor = 0.3f;
232 tlog.Debug(tag, "DefaultZoomFactor : " + context.DefaultZoomFactor);
236 tlog.Debug(tag, $"WebContextDefaultZoomFactor END (OK)");
241 [Description("WebContext ContextProxy.")]
242 [Property("SPEC", "Tizen.NUI.WebContext.ContextProxy A")]
243 [Property("SPEC_URL", "-")]
244 [Property("CRITERIA", "PRO")]
245 [Property("COVPARAM", "")]
246 [Property("AUTHOR", "guowei.wang@samsung.com")]
247 public void WebContextContextProxy()
249 tlog.Debug(tag, $"WebContextContextProxy START");
251 var context = webview_.Context;
252 tlog.Debug(tag, "ContextProxy : " + context.ContextProxy);
256 tlog.Debug(tag, $"WebContextContextProxy END (OK)");
261 [Description("WebContext ProxyBypassRule.")]
262 [Property("SPEC", "Tizen.NUI.WebContext.ProxyBypassRule A")]
263 [Property("SPEC_URL", "-")]
264 [Property("CRITERIA", "PRO")]
265 [Property("COVPARAM", "")]
266 [Property("AUTHOR", "guowei.wang@samsung.com")]
267 public void WebContextProxyBypassRule()
269 tlog.Debug(tag, $"WebContextProxyBypassRule START");
271 var context = webview_.Context;
272 tlog.Debug(tag, "ProxyBypassRule : " + context.ProxyBypassRule);
276 tlog.Debug(tag, $"WebContextProxyBypassRule END (OK)");
279 //TODO...API would block. Its doc in web engine proposes to avoid using this API.
282 //[Description("WebContext SetDefaultProxyAuth.")]
283 //[Property("SPEC", "Tizen.NUI.WebContext.SetDefaultProxyAuth M")]
284 //[Property("SPEC_URL", "-")]
285 //[Property("CRITERIA", "MR")]
286 //[Property("COVPARAM", "")]
287 //[Property("AUTHOR", "guowei.wang@samsung.com")]
288 //public async Task WebContextSetDefaultProxyAuth()
290 // tlog.Debug(tag, $"WebContextSetDefaultProxyAuth START");
292 // var context = webview_.Context;
293 // context.SetDefaultProxyAuth("tizen", "samsung");
295 // TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
296 // EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
298 // tcs.TrySetResult(true);
300 // webview_.PageLoadFinished += onLoadFinished;
302 // webview_.LoadUrl(url);
303 // var result = await tcs.Task;
304 // Assert.IsTrue(result, "PageLoadFinished event should be invoked");
306 // webview_.PageLoadFinished -= onLoadFinished;
307 // context.Dispose();
309 // tlog.Debug(tag, $"WebContextSetDefaultProxyAuth END (OK)");
314 [Description("WebContext DeleteAllWebDatabase.")]
315 [Property("SPEC", "Tizen.NUI.WebContext.DeleteAllWebDatabase M")]
316 [Property("SPEC_URL", "-")]
317 [Property("CRITERIA", "MR")]
318 [Property("COVPARAM", "")]
319 [Property("AUTHOR", "guowei.wang@samsung.com")]
320 public async Task WebContextDeleteAllWebDatabase()
322 tlog.Debug(tag, $"WebContextDeleteAllWebDatabase START");
324 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
325 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
327 tcs.TrySetResult(true);
329 webview_.PageLoadFinished += onLoadFinished;
331 webview_.LoadUrl(urlForDatabase);
332 var result = await tcs.Task;
333 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
336 var context = webview_.Context;
338 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
339 WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
341 tcs2.TrySetResult(list.Count);
343 context.GetWebDatabaseOrigins(cb2);
345 var result2 = await tcs2.Task;
346 Assert.AreEqual(result2, 0, "GetWebDatabaseOrigins should be called."); //TODO... result2 is 1?
348 // Delete all web db.
349 context.DeleteAllWebDatabase();
352 TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
353 WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
355 tcs3.TrySetResult(list.Count);
358 context.GetWebDatabaseOrigins(cb3);
360 var result3 = await tcs3.Task;
361 Assert.AreEqual(result3, 0, "GetWebDatabaseOrigins should be called.");
363 webview_.PageLoadFinished -= onLoadFinished;
367 tlog.Debug(tag, $"WebContextDeleteAllWebDatabase END (OK)");
372 [Description("WebContext GetWebDatabaseOrigins.")]
373 [Property("SPEC", "Tizen.NUI.WebContext.GetWebDatabaseOrigins M")]
374 [Property("SPEC_URL", "-")]
375 [Property("CRITERIA", "MR")]
376 [Property("COVPARAM", "")]
377 [Property("AUTHOR", "guowei.wang@samsung.com")]
378 public async Task WebContextGetWebDatabaseOrigins()
380 tlog.Debug(tag, $"WebContextGetWebDatabaseOrigins START");
382 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
383 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
385 tcs.TrySetResult(true);
387 webview_.PageLoadFinished += onLoadFinished;
389 webview_.LoadUrl(urlForDatabase);
390 var result = await tcs.Task;
391 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
393 var context = webview_.Context;
394 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
395 WebContext.SecurityOriginListAcquiredCallback cb = (list) =>
397 tcs2.TrySetResult(list.Count);
399 context.GetWebDatabaseOrigins(cb);
401 var result2 = await tcs2.Task;
402 Assert.AreEqual(result2, 0, "GetWebDatabaseOrigins should be called."); //TODO... result2 is 1?
405 webview_.PageLoadFinished -= onLoadFinished;
407 tlog.Debug(tag, $"WebContextGetWebDatabaseOrigins END (OK)");
412 [Description("WebContext DeleteWebDatabase.")]
413 [Property("SPEC", "Tizen.NUI.WebContext.DeleteWebDatabase M")]
414 [Property("SPEC_URL", "-")]
415 [Property("CRITERIA", "MR")]
416 [Property("COVPARAM", "")]
417 [Property("AUTHOR", "guowei.wang@samsung.com")]
418 public async Task WebContextDeleteWebDatabase()
420 tlog.Debug(tag, $"WebContextDeleteWebDatabase START");
422 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
423 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
425 tcs.TrySetResult(true);
427 webview_.PageLoadFinished += onLoadFinished;
429 webview_.LoadUrl(urlForDatabase);
430 var result = await tcs.Task;
431 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
433 var context = webview_.Context;
434 WebSecurityOrigin seo = null;
435 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
436 WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
442 tcs2.TrySetResult(list.Count);
444 context.GetWebDatabaseOrigins(cb2);
446 var result2 = await tcs2.Task;
447 Assert.AreEqual(result2, 0, "GetWebDatabaseOrigins should be called."); //TODO... result2 is 1?
449 // Delete db by security origin.
450 tlog.Debug(tag, $"WebContextDeleteWebDatabase, Host: {seo?.Host}");
451 tlog.Debug(tag, $"WebContextDeleteWebDatabase Protocol: {seo?.Protocol}");
454 context.DeleteWebDatabase(seo);
457 TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
458 WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
460 tcs3.TrySetResult(list.Count);
462 context.GetWebDatabaseOrigins(cb3);
464 var result3 = await tcs3.Task;
465 Assert.AreEqual(result3, 0, "GetWebDatabaseOrigins should be called.");
468 webview_.PageLoadFinished -= onLoadFinished;
470 tlog.Debug(tag, $"WebContextDeleteWebDatabase END (OK)");
473 //TODO... Web engine blocks!!!!!!
476 [Description("WebContext GetWebStorageOrigins.")]
477 [Property("SPEC", "Tizen.NUI.WebContext.GetWebStorageUsageForOrigin M")]
478 [Property("SPEC_URL", "-")]
479 [Property("CRITERIA", "MR")]
480 [Property("COVPARAM", "")]
481 [Property("AUTHOR", "guowei.wang@samsung.com")]
482 public async Task WebContextGetWebStorageUsageForOrigin()
484 tlog.Debug(tag, $"WebContextGetWebStorageUsageForOrigin START");
486 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
487 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
489 tcs.TrySetResult(true);
491 webview_.PageLoadFinished += onLoadFinished;
493 webview_.LoadUrl(urlForStorage);
494 var result = await tcs.Task;
495 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
498 var context = webview_.Context;
499 WebSecurityOrigin seo = null;
500 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
501 WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
507 tcs2.TrySetResult(list.Count);
509 context.GetWebStorageOrigins(cb2);
511 var result2 = await tcs2.Task;
512 Assert.AreEqual(result2, 1, "GetWebStorageOrigins should be called.");
516 TaskCompletionSource<ulong> tcs3 = new TaskCompletionSource<ulong>(0);
517 WebContext.StorageUsageAcquiredCallback cb3 = (usage) =>
519 tcs3.TrySetResult(usage);
521 context.GetWebStorageUsageForOrigin(seo, cb3);
522 var result3 = await tcs3.Task;
523 Assert.Greater(result3, 0, "GetWebStorageUsageForOrigin should be called.");
527 webview_.PageLoadFinished -= onLoadFinished;
529 tlog.Debug(tag, $"WebContextGetWebStorageUsageForOrigin END (OK)");
532 //TODO... Web engine blocks!!!!!!
535 [Description("WebContext DeleteAllWebStorage.")]
536 [Property("SPEC", "Tizen.NUI.WebContext.DeleteAllWebStorage M")]
537 [Property("SPEC_URL", "-")]
538 [Property("CRITERIA", "MR")]
539 [Property("COVPARAM", "")]
540 [Property("AUTHOR", "guowei.wang@samsung.com")]
541 public async Task WebContextDeleteAllWebStorage()
543 tlog.Debug(tag, $"WebContextDeleteAllWebStorage START");
545 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
546 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
548 tcs.TrySetResult(true);
550 webview_.PageLoadFinished += onLoadFinished;
552 webview_.LoadUrl(urlForStorage);
553 var result = await tcs.Task;
554 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
556 var context = webview_.Context;
559 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
560 WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
562 tcs2.TrySetResult(list.Count);
565 context.GetWebStorageOrigins(cb2);
567 var result2 = await tcs2.Task;
568 Assert.Greater(result2, 0, "GetWebStorageOrigins should be called.");
570 // Delete all web storage.
571 context.DeleteAllWebStorage();
574 TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
575 WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
577 tcs3.TrySetResult(list.Count);
580 context.GetWebStorageOrigins(cb3);
582 var result3 = await tcs3.Task;
583 Assert.AreEqual(result3, 0, "GetWebStorageOrigins should be called.");
585 webview_.PageLoadFinished -= onLoadFinished;
588 tlog.Debug(tag, $"WebContextDeleteAllWebStorage END (OK)");
591 //TODO... Web engine blocks!!!!!!
594 [Description("WebContext DeleteAllWebStorage.")]
595 [Property("SPEC", "Tizen.NUI.WebContext.DeleteWebStorage M")]
596 [Property("SPEC_URL", "-")]
597 [Property("CRITERIA", "MR")]
598 [Property("COVPARAM", "")]
599 [Property("AUTHOR", "guowei.wang@samsung.com")]
600 public async Task WebContextDeleteWebStorage()
602 tlog.Debug(tag, $"WebContextDeleteAllWebStorage START");
604 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
605 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
607 tcs.TrySetResult(true);
609 webview_.PageLoadFinished += onLoadFinished;
611 webview_.LoadUrl(urlForStorage);
612 var result = await tcs.Task;
613 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
615 var context = webview_.Context;
618 WebSecurityOrigin seo = null;
619 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
620 WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
623 tcs2.TrySetResult(list.Count);
626 context.GetWebStorageOrigins(cb2);
628 var result2 = await tcs2.Task;
629 Assert.Greater(result2, 0, "GetWebStorageOrigins should be called.");
631 // Delete web storage.
632 context.DeleteWebStorage(seo);
635 TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
636 WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
638 tcs3.TrySetResult(list.Count);
641 context.GetWebStorageOrigins(cb3);
643 var result3 = await tcs3.Task;
644 Assert.AreEqual(result3, 0, "GetWebStorageOrigins should be called.");
646 webview_.PageLoadFinished -= onLoadFinished;
649 tlog.Debug(tag, $"WebContextDeleteAllWebStorage END (OK)");
654 [Description("WebContext DeleteLocalFileSystem.")]
655 [Property("SPEC", "Tizen.NUI.WebContext.DeleteLocalFileSystem M")]
656 [Property("SPEC_URL", "-")]
657 [Property("CRITERIA", "MR")]
658 [Property("COVPARAM", "")]
659 [Property("AUTHOR", "guowei.wang@samsung.com")]
660 public async Task WebContextDeleteLocalFileSystem()
662 tlog.Debug(tag, $"WebContextDeleteLocalFileSystem START");
664 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
665 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
667 tcs.TrySetResult(true);
669 webview_.PageLoadFinished += onLoadFinished;
671 webview_.LoadUrl(urlForLocalFileSystem);
672 var result = await tcs.Task;
673 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
675 var context = webview_.Context;
677 // Delete all web local file system.
678 context.DeleteLocalFileSystem();
679 // TODO...list count need be checked, but query API is not wrapped.
681 webview_.PageLoadFinished -= onLoadFinished;
684 tlog.Debug(tag, $"WebContextDeleteLocalFileSystem END (OK)");
689 [Description("WebContext GetFormPasswordList.")]
690 [Property("SPEC", "Tizen.NUI.WebContext.GetFormPasswordList M")]
691 [Property("SPEC_URL", "-")]
692 [Property("CRITERIA", "MR")]
693 [Property("COVPARAM", "")]
694 [Property("AUTHOR", "guowei.wang@samsung.com")]
695 public async Task WebContextGetFormPasswordList()
697 tlog.Debug(tag, $"WebContextGetFormPasswordList START");
699 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
700 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
702 tcs.TrySetResult(true);
704 webview_.PageLoadFinished += onLoadFinished;
706 webview_.LoadUrl(urlForFormPassword);
707 var result = await tcs.Task;
708 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
710 var context = webview_.Context;
714 WebPasswordData pd = null;
715 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
716 WebContext.PasswordDataListAcquiredCallback cb2 = (list) =>
722 tcs2.TrySetResult(list.Count);
725 context.GetFormPasswordList(cb2);
727 var result2 = await tcs2.Task;
728 Assert.AreEqual(result2, 0, "GetFormPasswordList should be called.");
730 tlog.Info(tag, $"WebContextGetFormPasswordList, url: {pd?.Url}");
731 tlog.Info(tag, $"WebContextGetFormPasswordList, FingerprintUsed: {pd?.FingerprintUsed}");
733 webview_.PageLoadFinished -= onLoadFinished;
736 tlog.Debug(tag, $"WebContextGetFormPasswordList END (OK)");
741 [Description("WebContext DeleteAllFormPasswordData.")]
742 [Property("SPEC", "Tizen.NUI.WebContext.DeleteAllFormPasswordData M")]
743 [Property("SPEC_URL", "-")]
744 [Property("CRITERIA", "MR")]
745 [Property("COVPARAM", "")]
746 [Property("AUTHOR", "guowei.wang@samsung.com")]
747 public async Task WebContextDeleteAllFormPasswordData()
749 tlog.Debug(tag, $"WebContextDeleteAllFormPasswordData START");
751 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
752 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
754 tcs.TrySetResult(true);
756 webview_.PageLoadFinished += onLoadFinished;
758 webview_.LoadUrl(urlForFormPassword);
759 var result = await tcs.Task;
760 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
762 var context = webview_.Context;
765 List<string> pl = new List<string>();
766 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
767 WebContext.PasswordDataListAcquiredCallback cb2 = (list) =>
773 tcs2.TrySetResult(list.Count);
776 context.GetFormPasswordList(cb2);
778 var result2 = await tcs2.Task;
779 Assert.AreEqual(result2, 0, "GetFormPasswordList should be called.");
781 // Delete web storage.
782 context.DeleteFormPasswordDataList(pl.ToArray()); //TODO... This API seems not correct.
783 context.DeleteAllFormPasswordData();
784 context.DeleteAllFormCandidateData();
787 TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
788 WebContext.PasswordDataListAcquiredCallback cb3 = (list) =>
790 tcs3.TrySetResult(list.Count);
793 context.GetFormPasswordList(cb3);
795 var result3 = await tcs3.Task;
796 Assert.AreEqual(result3, 0, "GetFormPasswordList should be called.");
798 webview_.PageLoadFinished -= onLoadFinished;
801 tlog.Debug(tag, $"WebContextDeleteAllFormPasswordData END (OK)");
806 [Description("WebContext RegisterDownloadStartedCallback.")]
807 [Property("SPEC", "Tizen.NUI.WebContext.RegisterDownloadStartedCallback M")]
808 [Property("SPEC_URL", "-")]
809 [Property("CRITERIA", "MR")]
810 [Property("COVPARAM", "")]
811 [Property("AUTHOR", "guowei.wang@samsung.com")]
812 public async Task WebContextRegisterDownloadStartedCallback()
814 tlog.Debug(tag, $"WebContextRegisterDownloadStartedCallback START");
816 // Check if download or not.
817 var context = webview_.Context;
818 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
819 WebContext.DownloadStartedCallback dcb = (url) =>
821 tcs.TrySetResult(true);
823 context.RegisterDownloadStartedCallback(dcb);
825 webview_.LoadUrl(urlForDownload);
826 var result = await tcs.Task;
827 Assert.IsTrue(result, "DownloadStartedCallback should be invoked");
831 tlog.Debug(tag, $"WebContextRegisterDownloadStartedCallback END (OK)");
836 [Description("WebContext RegisterMimeOverriddenCallback.")]
837 [Property("SPEC", "Tizen.NUI.WebContext.RegisterMimeOverriddenCallback M")]
838 [Property("SPEC_URL", "-")]
839 [Property("CRITERIA", "MR")]
840 [Property("COVPARAM", "")]
841 [Property("AUTHOR", "guowei.wang@samsung.com")]
842 public async Task WebContextRegisterMimeOverriddenCallback()
844 tlog.Debug(tag, $"WebContextRegisterMimeOverriddenCallback START");
846 var context = webview_.Context;
847 context.RegisterMimeOverriddenCallback(MimeWrittenCallback); //TODO... how to test it?
849 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
850 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
852 tcs.TrySetResult(true);
854 webview_.PageLoadFinished += onLoadFinished;
856 webview_.LoadUrl(url);
857 var result = await tcs.Task;
858 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
860 webview_.PageLoadFinished -= onLoadFinished;
863 tlog.Debug(tag, $"WebContextRegisterMimeOverriddenCallback END (OK)");
868 [Description("WebContext SetTimeZoneOffset.")]
869 [Property("SPEC", "Tizen.NUI.WebContext.SetTimeZoneOffset M")]
870 [Property("SPEC_URL", "-")]
871 [Property("CRITERIA", "MR")]
872 [Property("COVPARAM", "")]
873 [Property("AUTHOR", "guowei.wang@samsung.com")]
874 public async Task WebContextSetTimeZoneOffset()
876 tlog.Debug(tag, $"WebContextSetTimeZoneOffset START");
878 var context = webview_.Context;
879 context.SetTimeZoneOffset(0.3f, 1.0f);
881 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
882 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
884 tcs.TrySetResult(true);
886 webview_.PageLoadFinished += onLoadFinished;
888 webview_.LoadUrl(url);
889 var result = await tcs.Task;
890 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
892 webview_.PageLoadFinished -= onLoadFinished;
895 tlog.Debug(tag, $"WebContextSetTimeZoneOffset END (OK)");
900 [Description("WebContext SetContextTimeZoneOffset.")]
901 [Property("SPEC", "Tizen.NUI.WebContext.SetContextTimeZoneOffset M")]
902 [Property("SPEC_URL", "-")]
903 [Property("CRITERIA", "MR")]
904 [Property("COVPARAM", "")]
905 [Property("AUTHOR", "guowei.wang@samsung.com")]
906 public async Task WebContextSetContextTimeZoneOffset()
908 tlog.Debug(tag, $"WebContextSetContextTimeZoneOffset START");
910 var context = webview_.Context;
911 context.SetContextTimeZoneOffset(0.3f, 1.0f);
913 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
914 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
916 tcs.TrySetResult(true);
918 webview_.PageLoadFinished += onLoadFinished;
920 webview_.LoadUrl(url);
921 var result = await tcs.Task;
922 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
924 webview_.PageLoadFinished -= onLoadFinished;
927 tlog.Debug(tag, $"WebContextSetContextTimeZoneOffset END (OK)");
932 [Description("WebContext DeleteAllApplicationCache.")]
933 [Property("SPEC", "Tizen.NUI.WebContext.DeleteAllApplicationCache M")]
934 [Property("SPEC_URL", "-")]
935 [Property("CRITERIA", "MR")]
936 [Property("COVPARAM", "")]
937 [Property("AUTHOR", "guowei.wang@samsung.com")]
938 public async Task WebContextDeleteAllApplicationCache()
940 tlog.Debug(tag, $"WebContextDeleteAllApplicationCache START");
942 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
943 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
945 tcs.TrySetResult(true);
947 webview_.PageLoadFinished += onLoadFinished;
949 webview_.LoadUrl(urlForApplicatonCache);
950 var result = await tcs.Task;
951 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
953 var context = webview_.Context;
955 // Delete all web applicaton cache.
956 context.DeleteAllApplicationCache();
957 // TODO...list count need be checked, but query API is not wrapped.
959 webview_.PageLoadFinished -= onLoadFinished;
962 tlog.Debug(tag, $"WebContextDeleteAllApplicationCache END (OK)");
967 [Description("WebContext DeleteAllWebIndexedDatabase.")]
968 [Property("SPEC", "Tizen.NUI.WebContext.DeleteAllWebIndexedDatabase M")]
969 [Property("SPEC_URL", "-")]
970 [Property("CRITERIA", "MR")]
971 [Property("COVPARAM", "")]
972 [Property("AUTHOR", "guowei.wang@samsung.com")]
973 public async Task WebContextDeleteAllWebIndexedDatabase()
975 tlog.Debug(tag, $"WebContextDeleteAllWebIndexedDatabase START");
977 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
978 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
980 tcs.TrySetResult(true);
982 webview_.PageLoadFinished += onLoadFinished;
984 webview_.LoadUrl(urlForApplicatonCache);
985 var result = await tcs.Task;
986 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
988 var context = webview_.Context;
990 // Delete all web indexed db.
991 context.DeleteAllWebIndexedDatabase();
992 // TODO...list count need be checked, but query API is not wrapped.
994 webview_.PageLoadFinished -= onLoadFinished;
997 tlog.Debug(tag, $"WebContextDeleteAllWebIndexedDatabase END (OK)");
1002 [Description("WebContext FreeUnusedMemory.")]
1003 [Property("SPEC", "Tizen.NUI.WebContext.FreeUnusedMemory M")]
1004 [Property("SPEC_URL", "-")]
1005 [Property("CRITERIA", "MR")]
1006 [Property("COVPARAM", "")]
1007 [Property("AUTHOR", "guowei.wang@samsung.com")]
1008 public async Task WebContextFreeUnusedMemory()
1010 tlog.Debug(tag, $"WebContextFreeUnusedMemory START");
1012 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
1013 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
1015 tcs.TrySetResult(true);
1017 webview_.PageLoadFinished += onLoadFinished;
1019 webview_.LoadUrl(urlForApplicatonCache);
1020 var result = await tcs.Task;
1021 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
1023 var context = webview_.Context;
1025 // Free unused memory if low memory.
1026 context.FreeUnusedMemory();
1028 webview_.PageLoadFinished -= onLoadFinished;
1031 tlog.Debug(tag, $"WebContextFreeUnusedMemory END (OK)");