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.baidu.com/";
25 private string urlForIndexedDBCreation = $"file://{Tizen.Applications.Application.Current.DirectoryInfo.Resource}webview/webindexeddbcreation.html";
27 private BaseComponents.WebView webview = null;
32 webview = new BaseComponents.WebView()
34 Size = new Size(500, 200),
36 tlog.Info(tag, "Init() is called!");
42 tlog.Info(tag, "Destroy() is being called!");
44 tlog.Info(tag, "Destroy() is called!");
49 [Description("WebContext ProxyUrl.")]
50 [Property("SPEC", "Tizen.NUI.WebContext.ProxyUrl A")]
51 [Property("SPEC_URL", "-")]
52 [Property("CRITERIA", "PRW")]
53 [Property("COVPARAM", "")]
54 [Property("AUTHOR", "guowei.wang@samsung.com")]
55 public void WebContextProxyUrl()
57 tlog.Debug(tag, $"WebContextProxyUrl START");
59 var context = webview.Context;
60 tlog.Debug(tag, "ProxyUrl : " + context.ProxyUrl);
62 context.ProxyUrl = "http://www.baidu.com";
63 tlog.Debug(tag, "ProxyUrl : " + context.ProxyUrl);
65 tlog.Debug(tag, $"WebContextProxyUrl END (OK)");
70 [Description("WebContext CertificateFilePath.")]
71 [Property("SPEC", "Tizen.NUI.WebContext.CertificateFilePath A")]
72 [Property("SPEC_URL", "-")]
73 [Property("CRITERIA", "PRW")]
74 [Property("COVPARAM", "")]
75 [Property("AUTHOR", "guowei.wang@samsung.com")]
76 public void WebContextCertificateFilePath()
78 tlog.Debug(tag, $"WebContextCertificateFilePath START");
80 var context = webview.Context;
81 tlog.Debug(tag, "CertificateFilePath : " + context.CertificateFilePath);
83 context.CertificateFilePath = "/opt/data/cert/vdca.pem";
84 tlog.Debug(tag, "CertificateFilePath : " + context.CertificateFilePath);
86 tlog.Debug(tag, $"WebContextCertificateFilePath END (OK)");
91 [Description("WebContext CacheEnabled.")]
92 [Property("SPEC", "Tizen.NUI.WebContext.CacheEnabled A")]
93 [Property("SPEC_URL", "-")]
94 [Property("CRITERIA", "PRW")]
95 [Property("COVPARAM", "")]
96 [Property("AUTHOR", "guowei.wang@samsung.com")]
97 public void WebContextCacheEnabled()
99 tlog.Debug(tag, $"WebContextCacheEnabled START");
101 var context = webview.Context;
102 tlog.Debug(tag, "CacheEnabled : " + context.CacheEnabled);
104 context.CacheEnabled = true;
105 tlog.Debug(tag, "CacheEnabled : " + context.CacheEnabled);
107 context.CacheEnabled = false;
108 tlog.Debug(tag, "CacheEnabled : " + context.CacheEnabled);
110 tlog.Debug(tag, $"WebContextCertificateFilePath END (OK)");
115 [Description("WebContext AppId.")]
116 [Property("SPEC", "Tizen.NUI.WebContext.AppId A")]
117 [Property("SPEC_URL", "-")]
118 [Property("CRITERIA", "PRW")]
119 [Property("COVPARAM", "")]
120 [Property("AUTHOR", "guowei.wang@samsung.com")]
121 public void WebContextAppId()
123 tlog.Debug(tag, $"WebContextAppId START");
125 var context = webview.Context;
126 tlog.Debug(tag, "AppId : " + context.AppId);
128 context.AppId = "WebContextAppId";
129 tlog.Debug(tag, "AppId : " + context.AppId);
131 tlog.Debug(tag, $"WebContextAppId END (OK)");
136 [Description("WebContext AppVersion.")]
137 [Property("SPEC", "Tizen.NUI.WebContext.AppVersion A")]
138 [Property("SPEC_URL", "-")]
139 [Property("CRITERIA", "PRW")]
140 [Property("COVPARAM", "")]
141 [Property("AUTHOR", "guowei.wang@samsung.com")]
142 public void WebContextAppVersion()
144 tlog.Debug(tag, $"WebContextAppVersion START");
146 var context = webview.Context;
147 tlog.Debug(tag, "AppVersion : " + context.AppVersion);
149 context.AppVersion = "1.0";
150 tlog.Debug(tag, "AppVersion : " + context.AppVersion);
152 tlog.Debug(tag, $"WebContextAppVersion END (OK)");
157 [Description("WebContext AppType.")]
158 [Property("SPEC", "Tizen.NUI.WebContext.AppType A")]
159 [Property("SPEC_URL", "-")]
160 [Property("CRITERIA", "PRW")]
161 [Property("COVPARAM", "")]
162 [Property("AUTHOR", "guowei.wang@samsung.com")]
163 public void WebContextAppType()
165 tlog.Debug(tag, $"WebContextAppType START");
167 var context = webview.Context;
168 tlog.Debug(tag, "AppType : " + context.AppType);
170 context.AppType = WebContext.ApplicationType.WebBrowser;
171 tlog.Debug(tag, "AppType : " + context.AppType);
173 tlog.Debug(tag, $"WebContextAppType END (OK)");
178 [Description("WebContext TimeOffset.")]
179 [Property("SPEC", "Tizen.NUI.WebContext.TimeOffset A")]
180 [Property("SPEC_URL", "-")]
181 [Property("CRITERIA", "PRW")]
182 [Property("COVPARAM", "")]
183 [Property("AUTHOR", "guowei.wang@samsung.com")]
184 public void WebContextTimeOffset()
186 tlog.Debug(tag, $"WebContextTimeOffset START");
188 var context = webview.Context;
189 tlog.Debug(tag, "TimeOffset : " + context.TimeOffset);
191 context.TimeOffset = 0.3f;
192 tlog.Debug(tag, "TimeOffset : " + context.TimeOffset);
194 tlog.Debug(tag, $"WebContextAppType END (OK)");
199 [Description("WebContext DefaultZoomFactor.")]
200 [Property("SPEC", "Tizen.NUI.WebContext.DefaultZoomFactor A")]
201 [Property("SPEC_URL", "-")]
202 [Property("CRITERIA", "PRW")]
203 [Property("COVPARAM", "")]
204 [Property("AUTHOR", "guowei.wang@samsung.com")]
205 public void WebContextDefaultZoomFactor()
207 tlog.Debug(tag, $"WebContextDefaultZoomFactor START");
209 var context = webview.Context;
210 tlog.Debug(tag, "DefaultZoomFactor : " + context.DefaultZoomFactor);
212 context.DefaultZoomFactor = 0.3f;
213 tlog.Debug(tag, "DefaultZoomFactor : " + context.DefaultZoomFactor);
215 tlog.Debug(tag, $"WebContextDefaultZoomFactor END (OK)");
220 [Description("WebContext ContextProxy.")]
221 [Property("SPEC", "Tizen.NUI.WebContext.ContextProxy A")]
222 [Property("SPEC_URL", "-")]
223 [Property("CRITERIA", "PRO")]
224 [Property("COVPARAM", "")]
225 [Property("AUTHOR", "guowei.wang@samsung.com")]
226 public void WebContextContextProxy()
228 tlog.Debug(tag, $"WebContextContextProxy START");
230 var context = webview.Context;
231 tlog.Debug(tag, "ContextProxy : " + context.ContextProxy);
233 tlog.Debug(tag, $"WebContextContextProxy END (OK)");
238 [Description("WebContext ProxyBypassRule.")]
239 [Property("SPEC", "Tizen.NUI.WebContext.ProxyBypassRule A")]
240 [Property("SPEC_URL", "-")]
241 [Property("CRITERIA", "PRO")]
242 [Property("COVPARAM", "")]
243 [Property("AUTHOR", "guowei.wang@samsung.com")]
244 public void WebContextProxyBypassRule()
246 tlog.Debug(tag, $"WebContextProxyBypassRule START");
248 var context = webview.Context;
249 tlog.Debug(tag, "ProxyBypassRule : " + context.ProxyBypassRule);
251 tlog.Debug(tag, $"WebContextProxyBypassRule END (OK)");
256 [Description("WebContext SetDefaultProxyAuth.")]
257 [Property("SPEC", "Tizen.NUI.WebContext.SetDefaultProxyAuth M")]
258 [Property("SPEC_URL", "-")]
259 [Property("CRITERIA", "MR")]
260 [Property("COVPARAM", "")]
261 [Property("AUTHOR", "guowei.wang@samsung.com")]
262 public async Task WebContextSetDefaultProxyAuth()
264 tlog.Debug(tag, $"WebContextSetDefaultProxyAuth START");
266 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
267 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
269 tcs.TrySetResult(true);
271 webview.PageLoadFinished += onLoadFinished;
273 webview.LoadUrl(url);
274 var result = await tcs.Task;
275 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
277 // Make current thread (CPU) sleep...
280 var context_ = webview.Context;
281 context_.SetDefaultProxyAuth("tizen", "samsung");
283 webview.PageLoadFinished -= onLoadFinished;
285 tlog.Debug(tag, $"WebContextSetDefaultProxyAuth END (OK)");
290 [Description("WebContext DeleteAllWebDatabase.")]
291 [Property("SPEC", "Tizen.NUI.WebContext.DeleteAllWebDatabase M")]
292 [Property("SPEC_URL", "-")]
293 [Property("CRITERIA", "MR")]
294 [Property("COVPARAM", "")]
295 [Property("AUTHOR", "guowei.wang@samsung.com")]
296 public async Task WebContextDeleteAllWebDatabase()
298 tlog.Debug(tag, $"WebContextDeleteAllWebDatabase START");
300 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
301 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
303 tcs.TrySetResult(true);
305 webview.PageLoadFinished += onLoadFinished;
307 webview.LoadUrl(urlForDatabase);
308 var result = await tcs.Task;
309 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
311 // Make current thread (CPU) sleep...
315 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
316 WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
318 tcs2.TrySetResult(list.Count);
320 var context = webview.Context;
321 context.GetWebDatabaseOrigins(cb2);
323 var result2 = await tcs2.Task;
324 Assert.Greater(result2, 0, "GetWebDatabaseOrigins should be called.");
326 // Make current thread (CPU) sleep...
329 // Delete all web db.
330 context.DeleteAllWebDatabase();
333 TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
334 WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
336 tcs3.TrySetResult(list.Count);
339 context.GetWebDatabaseOrigins(cb3);
341 var result3 = await tcs3.Task;
342 Assert.AreEqual(result3, 0, "GetWebDatabaseOrigins should be called.");
344 // Make current thread (CPU) sleep...
347 webview.PageLoadFinished -= onLoadFinished;
349 tlog.Debug(tag, $"WebContextDeleteAllWebDatabase END (OK)");
354 [Description("WebContext GetWebDatabaseOrigins.")]
355 [Property("SPEC", "Tizen.NUI.WebContext.GetWebDatabaseOrigins M")]
356 [Property("SPEC_URL", "-")]
357 [Property("CRITERIA", "MR")]
358 [Property("COVPARAM", "")]
359 [Property("AUTHOR", "guowei.wang@samsung.com")]
360 public async Task WebContextGetWebDatabaseOrigins()
362 tlog.Debug(tag, $"WebContextGetWebDatabaseOrigins START");
364 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
365 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
367 tcs.TrySetResult(true);
369 webview.PageLoadFinished += onLoadFinished;
371 webview.LoadUrl(urlForDatabase);
372 var result = await tcs.Task;
373 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
375 // Make current thread (CPU) sleep...
378 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
379 WebContext.SecurityOriginListAcquiredCallback cb = (list) =>
381 tcs2.TrySetResult(list.Count);
383 var context = webview.Context;
384 context.GetWebDatabaseOrigins(cb);
386 var result2 = await tcs2.Task;
387 Assert.Greater(result2, 0, "GetWebDatabaseOrigins should be called.");
389 // Make current thread (CPU) sleep...
392 webview.PageLoadFinished -= onLoadFinished;
394 tlog.Debug(tag, $"WebContextGetWebDatabaseOrigins END (OK)");
399 [Description("WebContext DeleteWebDatabase.")]
400 [Property("SPEC", "Tizen.NUI.WebContext.DeleteWebDatabase M")]
401 [Property("SPEC_URL", "-")]
402 [Property("CRITERIA", "MR")]
403 [Property("COVPARAM", "")]
404 [Property("AUTHOR", "guowei.wang@samsung.com")]
405 public async Task WebContextDeleteWebDatabase()
407 tlog.Debug(tag, $"WebContextDeleteWebDatabase START");
409 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
410 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
412 tcs.TrySetResult(true);
414 webview.PageLoadFinished += onLoadFinished;
416 webview.LoadUrl(urlForDatabase);
417 var result = await tcs.Task;
418 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
420 // Make current thread (CPU) sleep...
423 WebSecurityOrigin seo = null;
424 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
425 WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
431 tcs2.TrySetResult(list.Count);
433 var context = webview.Context;
434 context.GetWebDatabaseOrigins(cb2);
436 var result2 = await tcs2.Task;
437 Assert.Greater(result2, 0, "GetWebDatabaseOrigins should be called.");
439 // Make current thread (CPU) sleep...
442 // Delete db by security origin.
443 tlog.Info(tag, $"WebContextDeleteWebDatabase, Host: {seo?.Host}");
444 tlog.Info(tag, $"WebContextDeleteWebDatabase Protocol: {seo?.Protocol}");
447 context.DeleteWebDatabase(seo);
450 TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
451 WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
453 tcs3.TrySetResult(list.Count);
455 context.GetWebDatabaseOrigins(cb3);
457 var result3 = await tcs3.Task;
458 //TODO...Result is not correct!!!!
459 //Assert.AreEqual(result3, 0, "GetWebDatabaseOrigins should be called.");
461 // Make current thread (CPU) sleep...
464 webview.PageLoadFinished -= onLoadFinished;
466 tlog.Debug(tag, $"WebContextDeleteWebDatabase END (OK)");
469 ////TODO... Web engine blocks!!!!!!
472 //[Description("WebContext GetWebStorageOrigins.")]
473 //[Property("SPEC", "Tizen.NUI.WebContext.GetWebStorageUsageForOrigin M")]
474 //[Property("SPEC_URL", "-")]
475 //[Property("CRITERIA", "MR")]
476 //[Property("COVPARAM", "")]
477 //[Property("AUTHOR", "guowei.wang@samsung.com")]
478 //public async Task WebContextGetWebStorageUsageForOrigin()
480 // tlog.Debug(tag, $"WebContextGetWebStorageUsageForOrigin START");
482 // TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
483 // EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
485 // tcs.TrySetResult(true);
487 // webview_.PageLoadFinished += onLoadFinished;
489 // webview_.LoadUrl(urlForStorage);
490 // var result = await tcs.Task;
491 // Assert.IsTrue(result, "PageLoadFinished event should be invoked");
493 // // Make current thread (CPU) sleep...
494 // await Task.Delay(1);
496 // // Get web storage.
497 // WebSecurityOrigin seo = null;
498 // TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
499 // WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
501 // if (list.Count > 0)
505 // tcs2.TrySetResult(list.Count);
507 // var context = webview_.Context;
508 // context.GetWebStorageOrigins(cb2);
510 // var result2 = await tcs2.Task;
511 // Assert.AreEqual(result2, 1, "GetWebStorageOrigins should be called.");
513 // // Make current thread (CPU) sleep...
514 // await Task.Delay(1);
518 // TaskCompletionSource<ulong> tcs3 = new TaskCompletionSource<ulong>(0);
519 // WebContext.StorageUsageAcquiredCallback cb3 = (usage) =>
521 // tcs3.TrySetResult(usage);
523 // context.GetWebStorageUsageForOrigin(seo, cb3);
524 // var result3 = await tcs3.Task;
525 // Assert.Greater(result3, 0, "GetWebStorageUsageForOrigin should be called.");
527 // // Make current thread (CPU) sleep...
528 // await Task.Delay(1);
531 // webview_.PageLoadFinished -= onLoadFinished;
533 // tlog.Debug(tag, $"WebContextGetWebStorageUsageForOrigin END (OK)");
536 ////TODO... Web engine blocks!!!!!!
539 //[Description("WebContext DeleteAllWebStorage.")]
540 //[Property("SPEC", "Tizen.NUI.WebContext.DeleteAllWebStorage M")]
541 //[Property("SPEC_URL", "-")]
542 //[Property("CRITERIA", "MR")]
543 //[Property("COVPARAM", "")]
544 //[Property("AUTHOR", "guowei.wang@samsung.com")]
545 //public async Task WebContextDeleteAllWebStorage()
547 // tlog.Debug(tag, $"WebContextDeleteAllWebStorage START");
549 // TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
550 // EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
552 // tcs.TrySetResult(true);
554 // webview_.PageLoadFinished += onLoadFinished;
556 // webview_.LoadUrl(urlForStorage);
557 // var result = await tcs.Task;
558 // Assert.IsTrue(result, "PageLoadFinished event should be invoked");
560 // // Make current thread (CPU) sleep...
561 // await Task.Delay(1);
563 // // Check list count.
564 // TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
565 // WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
567 // tcs2.TrySetResult(list.Count);
570 // var context = webview_.Context;
571 // context.GetWebStorageOrigins(cb2);
573 // var result2 = await tcs2.Task;
574 // Assert.Greater(result2, 0, "GetWebStorageOrigins should be called.");
576 // // Make current thread (CPU) sleep...
577 // await Task.Delay(1);
579 // // Delete all web storage.
580 // context.DeleteAllWebStorage();
582 // // Check list count.
583 // TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
584 // WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
586 // tcs3.TrySetResult(list.Count);
589 // context.GetWebStorageOrigins(cb3);
591 // var result3 = await tcs3.Task;
592 // Assert.AreEqual(result3, 0, "GetWebStorageOrigins should be called.");
594 // // Make current thread (CPU) sleep...
595 // await Task.Delay(1);
597 // webview_.PageLoadFinished -= onLoadFinished;
599 // tlog.Debug(tag, $"WebContextDeleteAllWebStorage END (OK)");
602 ////TODO... Web engine blocks!!!!!!
605 //[Description("WebContext DeleteAllWebStorage.")]
606 //[Property("SPEC", "Tizen.NUI.WebContext.DeleteWebStorage M")]
607 //[Property("SPEC_URL", "-")]
608 //[Property("CRITERIA", "MR")]
609 //[Property("COVPARAM", "")]
610 //[Property("AUTHOR", "guowei.wang@samsung.com")]
611 //public async Task WebContextDeleteWebStorage()
613 // tlog.Debug(tag, $"WebContextDeleteAllWebStorage START");
615 // TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
616 // EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
618 // tcs.TrySetResult(true);
620 // webview_.PageLoadFinished += onLoadFinished;
622 // webview_.LoadUrl(urlForStorage);
623 // var result = await tcs.Task;
624 // Assert.IsTrue(result, "PageLoadFinished event should be invoked");
626 // // Make current thread (CPU) sleep...
627 // await Task.Delay(1);
629 // // Check list count.
630 // WebSecurityOrigin seo = null;
631 // TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
632 // WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
635 // tcs2.TrySetResult(list.Count);
638 // var context = webview_.Context;
639 // context.GetWebStorageOrigins(cb2);
641 // var result2 = await tcs2.Task;
642 // Assert.Greater(result2, 0, "GetWebStorageOrigins should be called.");
644 // // Make current thread (CPU) sleep...
645 // await Task.Delay(1);
647 // // Delete web storage.
648 // context.DeleteWebStorage(seo);
650 // // Check list count.
651 // TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
652 // WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
654 // tcs3.TrySetResult(list.Count);
657 // context.GetWebStorageOrigins(cb3);
659 // var result3 = await tcs3.Task;
660 // Assert.AreEqual(result3, 0, "GetWebStorageOrigins should be called.");
662 // // Make current thread (CPU) sleep...
663 // await Task.Delay(1);
665 // webview_.PageLoadFinished -= onLoadFinished;
667 // tlog.Debug(tag, $"WebContextDeleteAllWebStorage END (OK)");
672 [Description("WebContext DeleteLocalFileSystem.")]
673 [Property("SPEC", "Tizen.NUI.WebContext.DeleteLocalFileSystem M")]
674 [Property("SPEC_URL", "-")]
675 [Property("CRITERIA", "MR")]
676 [Property("COVPARAM", "")]
677 [Property("AUTHOR", "guowei.wang@samsung.com")]
678 public async Task WebContextDeleteLocalFileSystem()
680 tlog.Debug(tag, $"WebContextDeleteLocalFileSystem START");
682 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
683 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
685 tcs.TrySetResult(true);
687 webview.PageLoadFinished += onLoadFinished;
689 webview.LoadUrl(urlForLocalFileSystem);
690 var result = await tcs.Task;
691 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
693 // Make current thread (CPU) sleep...
696 // Delete all web local file system.
697 var context = webview.Context;
698 context.DeleteLocalFileSystem();
699 // TODO...list count need be checked, but query API is not wrapped.
701 webview.PageLoadFinished -= onLoadFinished;
703 tlog.Debug(tag, $"WebContextDeleteLocalFileSystem END (OK)");
708 [Description("WebContext GetFormPasswordList.")]
709 [Property("SPEC", "Tizen.NUI.WebContext.GetFormPasswordList M")]
710 [Property("SPEC_URL", "-")]
711 [Property("CRITERIA", "MR")]
712 [Property("COVPARAM", "")]
713 [Property("AUTHOR", "guowei.wang@samsung.com")]
714 public async Task WebContextGetFormPasswordList()
716 tlog.Debug(tag, $"WebContextGetFormPasswordList START");
718 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
719 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
721 tcs.TrySetResult(true);
723 webview.PageLoadFinished += onLoadFinished;
725 webview.LoadUrl(urlForFormPassword);
726 var result = await tcs.Task;
727 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
729 // Make current thread (CPU) sleep...
734 WebPasswordData pd = null;
735 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
736 WebContext.PasswordDataListAcquiredCallback cb2 = (list) =>
742 tcs2.TrySetResult(list.Count);
745 var context = webview.Context;
746 context.GetFormPasswordList(cb2);
748 var result2 = await tcs2.Task;
749 Assert.AreEqual(result2, 0, "GetFormPasswordList should be called.");
751 // Make current thread (CPU) sleep...
754 tlog.Info(tag, $"WebContextGetFormPasswordList, url: {pd?.Url}");
755 tlog.Info(tag, $"WebContextGetFormPasswordList, FingerprintUsed: {pd?.FingerprintUsed}");
757 webview.PageLoadFinished -= onLoadFinished;
759 tlog.Debug(tag, $"WebContextGetFormPasswordList END (OK)");
764 [Description("WebContext DeleteAllFormPasswordData.")]
765 [Property("SPEC", "Tizen.NUI.WebContext.DeleteAllFormPasswordData M")]
766 [Property("SPEC_URL", "-")]
767 [Property("CRITERIA", "MR")]
768 [Property("COVPARAM", "")]
769 [Property("AUTHOR", "guowei.wang@samsung.com")]
770 public async Task WebContextDeleteAllFormPasswordData()
772 tlog.Debug(tag, $"WebContextDeleteAllFormPasswordData START");
774 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
775 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
777 tcs.TrySetResult(true);
779 webview.PageLoadFinished += onLoadFinished;
781 webview.LoadUrl(urlForFormPassword);
782 var result = await tcs.Task;
783 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
785 // Make current thread (CPU) sleep...
789 List<string> pl = new List<string>();
790 TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
791 WebContext.PasswordDataListAcquiredCallback cb2 = (list) =>
797 tcs2.TrySetResult(list.Count);
800 var context = webview.Context;
801 context.GetFormPasswordList(cb2);
803 var result2 = await tcs2.Task;
804 Assert.AreEqual(result2, 0, "GetFormPasswordList should be called.");
806 // Make current thread (CPU) sleep...
809 // Delete web storage.
810 context.DeleteFormPasswordDataList(pl.ToArray()); //TODO... This API seems not correct.
811 context.DeleteAllFormPasswordData();
812 context.DeleteAllFormCandidateData();
815 TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
816 WebContext.PasswordDataListAcquiredCallback cb3 = (list) =>
818 tcs3.TrySetResult(list.Count);
821 context.GetFormPasswordList(cb3);
823 var result3 = await tcs3.Task;
824 Assert.AreEqual(result3, 0, "GetFormPasswordList should be called.");
826 // Make current thread (CPU) sleep...
829 webview.PageLoadFinished -= onLoadFinished;
831 tlog.Debug(tag, $"WebContextDeleteAllFormPasswordData END (OK)");
836 [Description("WebContext RegisterDownloadStartedCallback.")]
837 [Property("SPEC", "Tizen.NUI.WebContext.RegisterDownloadStartedCallback M")]
838 [Property("SPEC_URL", "-")]
839 [Property("CRITERIA", "MR")]
840 [Property("COVPARAM", "")]
841 [Property("AUTHOR", "guowei.wang@samsung.com")]
842 public async Task WebContextRegisterDownloadStartedCallback()
844 tlog.Debug(tag, $"WebContextRegisterDownloadStartedCallback START");
846 // Check if download or not.
847 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
848 WebContext.DownloadStartedCallback dcb = (url) =>
850 tcs.TrySetResult(true);
853 var context = webview.Context;
854 context.RegisterDownloadStartedCallback(dcb);
856 webview.LoadUrl(urlForDownload);
857 var result = await tcs.Task;
858 Assert.IsTrue(result, "DownloadStartedCallback should be invoked");
860 // Make current thread (CPU) sleep...
863 context.RegisterDownloadStartedCallback(null);
865 tlog.Debug(tag, $"WebContextRegisterDownloadStartedCallback END (OK)");
870 [Description("WebContext RegisterMimeOverriddenCallback.")]
871 [Property("SPEC", "Tizen.NUI.WebContext.RegisterMimeOverriddenCallback M")]
872 [Property("SPEC_URL", "-")]
873 [Property("CRITERIA", "MR")]
874 [Property("COVPARAM", "")]
875 [Property("AUTHOR", "guowei.wang@samsung.com")]
876 public async Task WebContextRegisterMimeOverriddenCallback()
878 tlog.Debug(tag, $"WebContextRegisterMimeOverriddenCallback START");
880 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
881 WebContext.MimeOverriddenCallback onMimeWrittenCallback = (string url, string currentMime, out string newMime) =>
883 tlog.Info(tag, "onMimeWrittenCallback is called!");
885 tcs.TrySetResult(true);
888 var context = webview.Context;
889 context.RegisterMimeOverriddenCallback(onMimeWrittenCallback);
891 webview.LoadUrl(url);
892 var result = await tcs.Task;
893 Assert.IsTrue(result, "MimeOverriddenCallback event should be invoked");
895 // Make current thread (CPU) sleep...
898 context.RegisterMimeOverriddenCallback(null);
900 tlog.Debug(tag, $"WebContextRegisterMimeOverriddenCallback END (OK)");
905 [Description("WebContext SetTimeZoneOffset.")]
906 [Property("SPEC", "Tizen.NUI.WebContext.SetTimeZoneOffset M")]
907 [Property("SPEC_URL", "-")]
908 [Property("CRITERIA", "MR")]
909 [Property("COVPARAM", "")]
910 [Property("AUTHOR", "guowei.wang@samsung.com")]
911 public async Task WebContextSetTimeZoneOffset()
913 tlog.Debug(tag, $"WebContextSetTimeZoneOffset START");
915 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
916 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
918 tcs.TrySetResult(true);
920 webview.PageLoadFinished += onLoadFinished;
922 webview.LoadUrl(url);
923 var result = await tcs.Task;
924 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
926 // Make current thread (CPU) sleep...
929 var context = webview.Context;
930 context.SetTimeZoneOffset(0.3f, 1.0f);
932 webview.PageLoadFinished -= onLoadFinished;
934 tlog.Debug(tag, $"WebContextSetTimeZoneOffset END (OK)");
939 [Description("WebContext SetContextTimeZoneOffset.")]
940 [Property("SPEC", "Tizen.NUI.WebContext.SetContextTimeZoneOffset M")]
941 [Property("SPEC_URL", "-")]
942 [Property("CRITERIA", "MR")]
943 [Property("COVPARAM", "")]
944 [Property("AUTHOR", "guowei.wang@samsung.com")]
945 public async Task WebContextSetContextTimeZoneOffset()
947 tlog.Debug(tag, $"WebContextSetContextTimeZoneOffset START");
949 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
950 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
952 tcs.TrySetResult(true);
954 webview.PageLoadFinished += onLoadFinished;
956 webview.LoadUrl(url);
957 var result = await tcs.Task;
958 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
960 // Make current thread (CPU) sleep...
963 var context = webview.Context;
964 context.SetContextTimeZoneOffset(0.3f, 1.0f);
966 webview.PageLoadFinished -= onLoadFinished;
968 tlog.Debug(tag, $"WebContextSetContextTimeZoneOffset END (OK)");
973 [Description("WebContext DeleteAllApplicationCache.")]
974 [Property("SPEC", "Tizen.NUI.WebContext.DeleteAllApplicationCache M")]
975 [Property("SPEC_URL", "-")]
976 [Property("CRITERIA", "MR")]
977 [Property("COVPARAM", "")]
978 [Property("AUTHOR", "guowei.wang@samsung.com")]
979 public async Task WebContextDeleteAllApplicationCache()
981 tlog.Debug(tag, $"WebContextDeleteAllApplicationCache START");
983 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
984 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
986 tcs.TrySetResult(true);
988 webview.PageLoadFinished += onLoadFinished;
990 webview.LoadUrl(urlForApplicatonCache);
991 var result = await tcs.Task;
992 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
994 // Make current thread (CPU) sleep...
997 // Delete all web applicaton cache.
998 var context = webview.Context;
999 context.DeleteAllApplicationCache();
1000 // TODO...list count need be checked, but query API is not wrapped.
1002 webview.PageLoadFinished -= onLoadFinished;
1004 tlog.Debug(tag, $"WebContextDeleteAllApplicationCache END (OK)");
1009 [Description("WebContext DeleteAllWebIndexedDatabase.")]
1010 [Property("SPEC", "Tizen.NUI.WebContext.DeleteAllWebIndexedDatabase M")]
1011 [Property("SPEC_URL", "-")]
1012 [Property("CRITERIA", "MR")]
1013 [Property("COVPARAM", "")]
1014 [Property("AUTHOR", "guowei.wang@samsung.com")]
1015 public async Task WebContextDeleteAllWebIndexedDatabase()
1017 tlog.Debug(tag, $"WebContextDeleteAllWebIndexedDatabase START");
1019 // Load url to check db exists.
1020 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
1021 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
1023 tcs.TrySetResult(true);
1025 webview.PageLoadFinished += onLoadFinished;
1027 webview.LoadUrl(urlForIndexedDBCreation);
1028 var result = await tcs.Task;
1029 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
1031 // Make current thread (CPU) sleep...
1032 await Task.Delay(1);
1034 // Delete all web indexed db.
1035 var context = webview.Context;
1036 context.DeleteAllWebIndexedDatabase();
1038 //TODO... how to check if title is changed.
1040 webview.PageLoadFinished -= onLoadFinished;
1042 tlog.Debug(tag, $"WebContextDeleteAllWebIndexedDatabase END (OK)");
1047 [Description("WebContext FreeUnusedMemory.")]
1048 [Property("SPEC", "Tizen.NUI.WebContext.FreeUnusedMemory M")]
1049 [Property("SPEC_URL", "-")]
1050 [Property("CRITERIA", "MR")]
1051 [Property("COVPARAM", "")]
1052 [Property("AUTHOR", "guowei.wang@samsung.com")]
1053 public async Task WebContextFreeUnusedMemory()
1055 tlog.Debug(tag, $"WebContextFreeUnusedMemory START");
1057 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
1058 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
1060 tcs.TrySetResult(true);
1062 webview.PageLoadFinished += onLoadFinished;
1064 webview.LoadUrl(urlForApplicatonCache);
1065 var result = await tcs.Task;
1066 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
1068 // Make current thread (CPU) sleep...
1069 await Task.Delay(1);
1071 // Free unused memory if low memory.
1072 var context = webview.Context;
1073 context.FreeUnusedMemory();
1075 webview.PageLoadFinished -= onLoadFinished;
1077 tlog.Debug(tag, $"WebContextFreeUnusedMemory END (OK)");