[NUI] Update webview TCs.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / WebView / TSWebContext.cs
1 using global::System;
2 using NUnit.Framework;
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;
8
9 namespace Tizen.NUI.Devel.Tests
10 {
11     using tlog = Tizen.Log;
12
13     [TestFixture]
14     [Description("internal/WebView/WebContext")]
15     public class InternalWebContextTest
16     {
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";
26
27         private BaseComponents.WebView webview = null;
28
29         [SetUp]
30         public void Init()
31         {
32             webview = new BaseComponents.WebView()
33             {
34                 Size = new Size(500, 200),
35             };
36             tlog.Info(tag, "Init() is called!");
37         }
38
39         [TearDown]
40         public void Destroy()
41         {
42             tlog.Info(tag, "Destroy() is being called!");
43             webview.Dispose();
44             tlog.Info(tag, "Destroy() is called!");
45         }
46
47         [Test]
48         [Category("P1")]
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()
56         {
57             tlog.Debug(tag, $"WebContextProxyUrl START");
58
59             var context = webview.Context;
60             tlog.Debug(tag, "ProxyUrl : " + context.ProxyUrl);
61
62             context.ProxyUrl = "http://www.baidu.com";
63             tlog.Debug(tag, "ProxyUrl : " + context.ProxyUrl);
64
65             tlog.Debug(tag, $"WebContextProxyUrl END (OK)");
66         }
67
68         [Test]
69         [Category("P1")]
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()
77         {
78             tlog.Debug(tag, $"WebContextCertificateFilePath START");
79
80             var context = webview.Context;
81             tlog.Debug(tag, "CertificateFilePath : " + context.CertificateFilePath);
82
83             context.CertificateFilePath = "/opt/data/cert/vdca.pem";
84             tlog.Debug(tag, "CertificateFilePath : " + context.CertificateFilePath);
85
86             tlog.Debug(tag, $"WebContextCertificateFilePath END (OK)");
87         }
88
89         [Test]
90         [Category("P1")]
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()
98         {
99             tlog.Debug(tag, $"WebContextCacheEnabled START");
100
101             var context = webview.Context;
102             tlog.Debug(tag, "CacheEnabled : " + context.CacheEnabled);
103
104             context.CacheEnabled = true;
105             tlog.Debug(tag, "CacheEnabled : " + context.CacheEnabled);
106
107             context.CacheEnabled = false;
108             tlog.Debug(tag, "CacheEnabled : " + context.CacheEnabled);
109
110             tlog.Debug(tag, $"WebContextCertificateFilePath END (OK)");
111         }
112
113         [Test]
114         [Category("P1")]
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()
122         {
123             tlog.Debug(tag, $"WebContextAppId START");
124
125             var context = webview.Context;
126             tlog.Debug(tag, "AppId : " + context.AppId);
127
128             context.AppId = "WebContextAppId";
129             tlog.Debug(tag, "AppId : " + context.AppId);
130
131             tlog.Debug(tag, $"WebContextAppId END (OK)");
132         }
133
134         [Test]
135         [Category("P1")]
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()
143         {
144             tlog.Debug(tag, $"WebContextAppVersion START");
145
146             var context = webview.Context;
147             tlog.Debug(tag, "AppVersion : " + context.AppVersion);
148
149             context.AppVersion = "1.0";
150             tlog.Debug(tag, "AppVersion : " + context.AppVersion);
151
152             tlog.Debug(tag, $"WebContextAppVersion END (OK)");
153         }
154
155         [Test]
156         [Category("P1")]
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()
164         {
165             tlog.Debug(tag, $"WebContextAppType START");
166
167             var context = webview.Context;
168             tlog.Debug(tag, "AppType : " + context.AppType);
169
170             context.AppType = WebContext.ApplicationType.WebBrowser;
171             tlog.Debug(tag, "AppType : " + context.AppType);
172
173             tlog.Debug(tag, $"WebContextAppType END (OK)");
174         }
175
176         [Test]
177         [Category("P1")]
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()
185         {
186             tlog.Debug(tag, $"WebContextTimeOffset START");
187
188             var context = webview.Context;
189             tlog.Debug(tag, "TimeOffset : " + context.TimeOffset);
190
191             context.TimeOffset = 0.3f;
192             tlog.Debug(tag, "TimeOffset : " + context.TimeOffset);
193
194             tlog.Debug(tag, $"WebContextAppType END (OK)");
195         }
196
197         [Test]
198         [Category("P1")]
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()
206         {
207             tlog.Debug(tag, $"WebContextDefaultZoomFactor START");
208
209             var context = webview.Context;
210             tlog.Debug(tag, "DefaultZoomFactor : " + context.DefaultZoomFactor);
211
212             context.DefaultZoomFactor = 0.3f;
213             tlog.Debug(tag, "DefaultZoomFactor : " + context.DefaultZoomFactor);
214
215             tlog.Debug(tag, $"WebContextDefaultZoomFactor END (OK)");
216         }
217
218         [Test]
219         [Category("P1")]
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()
227         {
228             tlog.Debug(tag, $"WebContextContextProxy START");
229
230             var context = webview.Context;
231             tlog.Debug(tag, "ContextProxy : " + context.ContextProxy);
232
233             tlog.Debug(tag, $"WebContextContextProxy END (OK)");
234         }
235
236         [Test]
237         [Category("P1")]
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()
245         {
246             tlog.Debug(tag, $"WebContextProxyBypassRule START");
247
248             var context = webview.Context;
249             tlog.Debug(tag, "ProxyBypassRule : " + context.ProxyBypassRule);
250
251             tlog.Debug(tag, $"WebContextProxyBypassRule END (OK)");
252         }
253
254         [Test]
255         [Category("P1")]
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()
263         {
264             tlog.Debug(tag, $"WebContextSetDefaultProxyAuth START");
265
266             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
267             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
268             {
269                 tcs.TrySetResult(true);
270             };
271             webview.PageLoadFinished += onLoadFinished;
272
273             webview.LoadUrl(url);
274             var result = await tcs.Task;
275             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
276
277             // Make current thread (CPU) sleep...
278             await Task.Delay(1);
279
280             var context_ = webview.Context;
281             context_.SetDefaultProxyAuth("tizen", "samsung");
282
283             webview.PageLoadFinished -= onLoadFinished;
284
285             tlog.Debug(tag, $"WebContextSetDefaultProxyAuth END (OK)");
286         }
287
288         [Test]
289         [Category("P1")]
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()
297         {
298             tlog.Debug(tag, $"WebContextDeleteAllWebDatabase START");
299
300             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
301             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
302             {
303                 tcs.TrySetResult(true);
304             };
305             webview.PageLoadFinished += onLoadFinished;
306
307             webview.LoadUrl(urlForDatabase);
308             var result = await tcs.Task;
309             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
310
311             // Make current thread (CPU) sleep...
312             await Task.Delay(1);
313
314             // Check list count.
315             TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
316             WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
317             {
318                 tcs2.TrySetResult(list.Count);
319             };
320             var context = webview.Context;
321             context.GetWebDatabaseOrigins(cb2);
322
323             var result2 = await tcs2.Task;
324             Assert.Greater(result2, 0, "GetWebDatabaseOrigins should be called.");
325
326             // Make current thread (CPU) sleep...
327             await Task.Delay(1);
328
329             // Delete all web db.
330             context.DeleteAllWebDatabase();
331
332             // Check list count.
333             TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
334             WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
335             {
336                 tcs3.TrySetResult(list.Count);
337             };
338
339             context.GetWebDatabaseOrigins(cb3);
340
341             var result3 = await tcs3.Task;
342             Assert.AreEqual(result3, 0, "GetWebDatabaseOrigins should be called.");
343
344             // Make current thread (CPU) sleep...
345             await Task.Delay(1);
346
347             webview.PageLoadFinished -= onLoadFinished;
348
349             tlog.Debug(tag, $"WebContextDeleteAllWebDatabase END (OK)");
350         }
351
352         [Test]
353         [Category("P1")]
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()
361         {
362             tlog.Debug(tag, $"WebContextGetWebDatabaseOrigins START");
363
364             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
365             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
366             {
367                 tcs.TrySetResult(true);
368             };
369             webview.PageLoadFinished += onLoadFinished;
370
371             webview.LoadUrl(urlForDatabase);
372             var result = await tcs.Task;
373             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
374
375             // Make current thread (CPU) sleep...
376             await Task.Delay(1);
377
378             TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
379             WebContext.SecurityOriginListAcquiredCallback cb = (list) =>
380             {
381                 tcs2.TrySetResult(list.Count);
382             };
383             var context = webview.Context;
384             context.GetWebDatabaseOrigins(cb);
385
386             var result2 = await tcs2.Task;
387             Assert.Greater(result2, 0, "GetWebDatabaseOrigins should be called.");
388
389             // Make current thread (CPU) sleep...
390             await Task.Delay(1);
391
392             webview.PageLoadFinished -= onLoadFinished;
393
394             tlog.Debug(tag, $"WebContextGetWebDatabaseOrigins END (OK)");
395         }
396
397         [Test]
398         [Category("P1")]
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()
406         {
407             tlog.Debug(tag, $"WebContextDeleteWebDatabase START");
408
409             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
410             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
411             {
412                 tcs.TrySetResult(true);
413             };
414             webview.PageLoadFinished += onLoadFinished;
415
416             webview.LoadUrl(urlForDatabase);
417             var result = await tcs.Task;
418             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
419
420             // Make current thread (CPU) sleep...
421             await Task.Delay(1);
422
423             WebSecurityOrigin seo = null;
424             TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
425             WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
426             {
427                 if (list.Count > 0)
428                 {
429                     seo = list[0];
430                 }
431                 tcs2.TrySetResult(list.Count);
432             };
433             var context = webview.Context;
434             context.GetWebDatabaseOrigins(cb2);
435
436             var result2 = await tcs2.Task;
437             Assert.Greater(result2, 0, "GetWebDatabaseOrigins should be called.");
438
439             // Make current thread (CPU) sleep...
440             await Task.Delay(1);
441
442             // Delete db by security origin.
443             tlog.Info(tag, $"WebContextDeleteWebDatabase, Host: {seo?.Host}");
444             tlog.Info(tag, $"WebContextDeleteWebDatabase Protocol: {seo?.Protocol}");
445             if (seo != null)
446             {
447                 context.DeleteWebDatabase(seo);
448             }
449
450             TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
451             WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
452             {
453                 tcs3.TrySetResult(list.Count);
454             };
455             context.GetWebDatabaseOrigins(cb3);
456
457             var result3 = await tcs3.Task;
458             //TODO...Result is not correct!!!!
459             //Assert.AreEqual(result3, 0, "GetWebDatabaseOrigins should be called.");
460
461             // Make current thread (CPU) sleep...
462             await Task.Delay(1);
463
464             webview.PageLoadFinished -= onLoadFinished;
465
466             tlog.Debug(tag, $"WebContextDeleteWebDatabase END (OK)");
467         }
468
469         ////TODO... Web engine blocks!!!!!!
470         //[Test]
471         //[Category("P1")]
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()
479         //{
480         //    tlog.Debug(tag, $"WebContextGetWebStorageUsageForOrigin START");
481
482         //    TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
483         //    EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
484         //    {
485         //        tcs.TrySetResult(true);
486         //    };
487         //    webview_.PageLoadFinished += onLoadFinished;
488
489         //    webview_.LoadUrl(urlForStorage);
490         //    var result = await tcs.Task;
491         //    Assert.IsTrue(result, "PageLoadFinished event should be invoked");
492
493         //    // Make current thread (CPU) sleep...
494         //    await Task.Delay(1);
495
496         //    // Get web storage.
497         //    WebSecurityOrigin seo = null;
498         //    TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
499         //    WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
500         //    {
501         //        if (list.Count > 0)
502         //        {
503         //            seo = list[0];
504         //        }
505         //        tcs2.TrySetResult(list.Count);
506         //    };
507         //    var context = webview_.Context;
508         //    context.GetWebStorageOrigins(cb2);
509
510         //    var result2 = await tcs2.Task;
511         //    Assert.AreEqual(result2, 1, "GetWebStorageOrigins should be called.");
512
513         //    // Make current thread (CPU) sleep...
514         //    await Task.Delay(1);
515
516         //    if (seo != null)
517         //    {
518         //        TaskCompletionSource<ulong> tcs3 = new TaskCompletionSource<ulong>(0);
519         //        WebContext.StorageUsageAcquiredCallback cb3 = (usage) =>
520         //        {
521         //            tcs3.TrySetResult(usage);
522         //        };
523         //        context.GetWebStorageUsageForOrigin(seo, cb3);
524         //        var result3 = await tcs3.Task;
525         //        Assert.Greater(result3, 0, "GetWebStorageUsageForOrigin should be called.");
526
527         //        // Make current thread (CPU) sleep...
528         //        await Task.Delay(1);
529         //    }
530
531         //    webview_.PageLoadFinished -= onLoadFinished;
532
533         //    tlog.Debug(tag, $"WebContextGetWebStorageUsageForOrigin END (OK)");
534         //}
535
536         ////TODO... Web engine blocks!!!!!!
537         //[Test]
538         //[Category("P1")]
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()
546         //{
547         //    tlog.Debug(tag, $"WebContextDeleteAllWebStorage START");
548
549         //    TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
550         //    EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
551         //    {
552         //        tcs.TrySetResult(true);
553         //    };
554         //    webview_.PageLoadFinished += onLoadFinished;
555
556         //    webview_.LoadUrl(urlForStorage);
557         //    var result = await tcs.Task;
558         //    Assert.IsTrue(result, "PageLoadFinished event should be invoked");
559
560         //    // Make current thread (CPU) sleep...
561         //    await Task.Delay(1);
562
563         //    // Check list count.
564         //    TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
565         //    WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
566         //    {
567         //        tcs2.TrySetResult(list.Count);
568         //    };
569
570         //    var context = webview_.Context;
571         //    context.GetWebStorageOrigins(cb2);
572
573         //    var result2 = await tcs2.Task;
574         //    Assert.Greater(result2, 0, "GetWebStorageOrigins should be called.");
575
576         //    // Make current thread (CPU) sleep...
577         //    await Task.Delay(1);
578
579         //    // Delete all web storage.
580         //    context.DeleteAllWebStorage();
581
582         //    // Check list count.
583         //    TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
584         //    WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
585         //    {
586         //        tcs3.TrySetResult(list.Count);
587         //    };
588
589         //    context.GetWebStorageOrigins(cb3);
590
591         //    var result3 = await tcs3.Task;
592         //    Assert.AreEqual(result3, 0, "GetWebStorageOrigins should be called.");
593
594         //    // Make current thread (CPU) sleep...
595         //    await Task.Delay(1);
596
597         //    webview_.PageLoadFinished -= onLoadFinished;
598
599         //    tlog.Debug(tag, $"WebContextDeleteAllWebStorage END (OK)");
600         //}
601
602         ////TODO... Web engine blocks!!!!!!
603         //[Test]
604         //[Category("P1")]
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()
612         //{
613         //    tlog.Debug(tag, $"WebContextDeleteAllWebStorage START");
614
615         //    TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
616         //    EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
617         //    {
618         //        tcs.TrySetResult(true);
619         //    };
620         //    webview_.PageLoadFinished += onLoadFinished;
621
622         //    webview_.LoadUrl(urlForStorage);
623         //    var result = await tcs.Task;
624         //    Assert.IsTrue(result, "PageLoadFinished event should be invoked");
625
626         //    // Make current thread (CPU) sleep...
627         //    await Task.Delay(1);
628
629         //    // Check list count.
630         //    WebSecurityOrigin seo = null;
631         //    TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
632         //    WebContext.SecurityOriginListAcquiredCallback cb2 = (list) =>
633         //    {
634         //        seo = list[0];
635         //        tcs2.TrySetResult(list.Count);
636         //    };
637
638         //    var context = webview_.Context;
639         //    context.GetWebStorageOrigins(cb2);
640
641         //    var result2 = await tcs2.Task;
642         //    Assert.Greater(result2, 0, "GetWebStorageOrigins should be called.");
643
644         //    // Make current thread (CPU) sleep...
645         //    await Task.Delay(1);
646
647         //    // Delete web storage.
648         //    context.DeleteWebStorage(seo);
649
650         //    // Check list count.
651         //    TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
652         //    WebContext.SecurityOriginListAcquiredCallback cb3 = (list) =>
653         //    {
654         //        tcs3.TrySetResult(list.Count);
655         //    };
656
657         //    context.GetWebStorageOrigins(cb3);
658
659         //    var result3 = await tcs3.Task;
660         //    Assert.AreEqual(result3, 0, "GetWebStorageOrigins should be called.");
661
662         //    // Make current thread (CPU) sleep...
663         //    await Task.Delay(1);
664
665         //    webview_.PageLoadFinished -= onLoadFinished;
666
667         //    tlog.Debug(tag, $"WebContextDeleteAllWebStorage END (OK)");
668         //}
669
670         [Test]
671         [Category("P1")]
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()
679         {
680             tlog.Debug(tag, $"WebContextDeleteLocalFileSystem START");
681
682             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
683             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
684             {
685                 tcs.TrySetResult(true);
686             };
687             webview.PageLoadFinished += onLoadFinished;
688
689             webview.LoadUrl(urlForLocalFileSystem);
690             var result = await tcs.Task;
691             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
692
693             // Make current thread (CPU) sleep...
694             await Task.Delay(1);
695
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.
700
701             webview.PageLoadFinished -= onLoadFinished;
702
703             tlog.Debug(tag, $"WebContextDeleteLocalFileSystem END (OK)");
704         }
705
706         [Test]
707         [Category("P1")]
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()
715         {
716             tlog.Debug(tag, $"WebContextGetFormPasswordList START");
717
718             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
719             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
720             {
721                 tcs.TrySetResult(true);
722             };
723             webview.PageLoadFinished += onLoadFinished;
724
725             webview.LoadUrl(urlForFormPassword);
726             var result = await tcs.Task;
727             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
728
729             // Make current thread (CPU) sleep...
730             await Task.Delay(1);
731
732             // Check list count.
733             // Check list count.
734             WebPasswordData pd = null;
735             TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
736             WebContext.PasswordDataListAcquiredCallback cb2 = (list) =>
737             {
738                 if (list.Count > 0)
739                 {
740                     pd = list[0];
741                 }
742                 tcs2.TrySetResult(list.Count);
743             };
744
745             var context = webview.Context;
746             context.GetFormPasswordList(cb2);
747
748             var result2 = await tcs2.Task;
749             Assert.AreEqual(result2, 0, "GetFormPasswordList should be called.");
750
751             // Make current thread (CPU) sleep...
752             await Task.Delay(1);
753
754             tlog.Info(tag, $"WebContextGetFormPasswordList, url: {pd?.Url}");
755             tlog.Info(tag, $"WebContextGetFormPasswordList, FingerprintUsed: {pd?.FingerprintUsed}");
756
757             webview.PageLoadFinished -= onLoadFinished;
758
759             tlog.Debug(tag, $"WebContextGetFormPasswordList END (OK)");
760         }
761
762         [Test]
763         [Category("P1")]
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()
771         {
772             tlog.Debug(tag, $"WebContextDeleteAllFormPasswordData START");
773
774             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
775             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
776             {
777                 tcs.TrySetResult(true);
778             };
779             webview.PageLoadFinished += onLoadFinished;
780
781             webview.LoadUrl(urlForFormPassword);
782             var result = await tcs.Task;
783             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
784
785             // Make current thread (CPU) sleep...
786             await Task.Delay(1);
787
788             // Check list count.
789             List<string> pl = new List<string>();
790             TaskCompletionSource<int> tcs2 = new TaskCompletionSource<int>(0);
791             WebContext.PasswordDataListAcquiredCallback cb2 = (list) =>
792             {
793                 if (list.Count > 0)
794                 {
795                     pl.Add(list[0].Url);
796                 }
797                 tcs2.TrySetResult(list.Count);
798             };
799
800             var context = webview.Context;
801             context.GetFormPasswordList(cb2);
802
803             var result2 = await tcs2.Task;
804             Assert.AreEqual(result2, 0, "GetFormPasswordList should be called.");
805
806             // Make current thread (CPU) sleep...
807             await Task.Delay(1);
808
809             // Delete web storage.
810             context.DeleteFormPasswordDataList(pl.ToArray()); //TODO... This API seems not correct.
811             context.DeleteAllFormPasswordData();
812             context.DeleteAllFormCandidateData();
813
814             // Check list count.
815             TaskCompletionSource<int> tcs3 = new TaskCompletionSource<int>(0);
816             WebContext.PasswordDataListAcquiredCallback cb3 = (list) =>
817             {
818                 tcs3.TrySetResult(list.Count);
819             };
820
821             context.GetFormPasswordList(cb3);
822
823             var result3 = await tcs3.Task;
824             Assert.AreEqual(result3, 0, "GetFormPasswordList should be called.");
825
826             // Make current thread (CPU) sleep...
827             await Task.Delay(1);
828
829             webview.PageLoadFinished -= onLoadFinished;
830
831             tlog.Debug(tag, $"WebContextDeleteAllFormPasswordData END (OK)");
832         }
833
834         [Test]
835         [Category("P1")]
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()
843         {
844             tlog.Debug(tag, $"WebContextRegisterDownloadStartedCallback START");
845
846             // Check if download or not.
847             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
848             WebContext.DownloadStartedCallback dcb = (url) =>
849             {
850                 tcs.TrySetResult(true);
851             };
852
853             var context = webview.Context;
854             context.RegisterDownloadStartedCallback(dcb);
855
856             webview.LoadUrl(urlForDownload);
857             var result = await tcs.Task;
858             Assert.IsTrue(result, "DownloadStartedCallback should be invoked");
859
860             // Make current thread (CPU) sleep...
861             await Task.Delay(1);
862
863             context.RegisterDownloadStartedCallback(null);
864
865             tlog.Debug(tag, $"WebContextRegisterDownloadStartedCallback END (OK)");
866         }
867
868         [Test]
869         [Category("P1")]
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()
877         {
878             tlog.Debug(tag, $"WebContextRegisterMimeOverriddenCallback START");
879
880             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
881             WebContext.MimeOverriddenCallback onMimeWrittenCallback = (string url, string currentMime, out string newMime) =>
882             {
883                 tlog.Info(tag, "onMimeWrittenCallback is called!");
884                 newMime = null;
885                 tcs.TrySetResult(true);
886                 return false;
887             };
888             var context = webview.Context;
889             context.RegisterMimeOverriddenCallback(onMimeWrittenCallback);
890
891             webview.LoadUrl(url);
892             var result = await tcs.Task;
893             Assert.IsTrue(result, "MimeOverriddenCallback event should be invoked");
894
895             // Make current thread (CPU) sleep...
896             await Task.Delay(1);
897
898             context.RegisterMimeOverriddenCallback(null);
899
900             tlog.Debug(tag, $"WebContextRegisterMimeOverriddenCallback END (OK)");
901         }
902
903         [Test]
904         [Category("P1")]
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()
912         {
913             tlog.Debug(tag, $"WebContextSetTimeZoneOffset START");
914
915             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
916             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
917             {
918                 tcs.TrySetResult(true);
919             };
920             webview.PageLoadFinished += onLoadFinished;
921
922             webview.LoadUrl(url);
923             var result = await tcs.Task;
924             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
925
926             // Make current thread (CPU) sleep...
927             await Task.Delay(1);
928
929             var context = webview.Context;
930             context.SetTimeZoneOffset(0.3f, 1.0f);
931
932             webview.PageLoadFinished -= onLoadFinished;
933
934             tlog.Debug(tag, $"WebContextSetTimeZoneOffset END (OK)");
935         }
936
937         [Test]
938         [Category("P1")]
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()
946         {
947             tlog.Debug(tag, $"WebContextSetContextTimeZoneOffset START");
948
949             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
950             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
951             {
952                 tcs.TrySetResult(true);
953             };
954             webview.PageLoadFinished += onLoadFinished;
955
956             webview.LoadUrl(url);
957             var result = await tcs.Task;
958             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
959
960             // Make current thread (CPU) sleep...
961             await Task.Delay(1);
962
963             var context = webview.Context;
964             context.SetContextTimeZoneOffset(0.3f, 1.0f);
965
966             webview.PageLoadFinished -= onLoadFinished;
967
968             tlog.Debug(tag, $"WebContextSetContextTimeZoneOffset END (OK)");
969         }
970
971         [Test]
972         [Category("P1")]
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()
980         {
981             tlog.Debug(tag, $"WebContextDeleteAllApplicationCache START");
982
983             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
984             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
985             {
986                 tcs.TrySetResult(true);
987             };
988             webview.PageLoadFinished += onLoadFinished;
989
990             webview.LoadUrl(urlForApplicatonCache);
991             var result = await tcs.Task;
992             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
993
994             // Make current thread (CPU) sleep...
995             await Task.Delay(1);
996
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.
1001
1002             webview.PageLoadFinished -= onLoadFinished;
1003
1004             tlog.Debug(tag, $"WebContextDeleteAllApplicationCache END (OK)");
1005         }
1006
1007         [Test]
1008         [Category("P1")]
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()
1016         {
1017             tlog.Debug(tag, $"WebContextDeleteAllWebIndexedDatabase START");
1018
1019             // Load url to check db exists.
1020             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
1021             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
1022             {
1023                 tcs.TrySetResult(true);
1024             };
1025             webview.PageLoadFinished += onLoadFinished;
1026
1027             webview.LoadUrl(urlForIndexedDBCreation);
1028             var result = await tcs.Task;
1029             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
1030
1031             // Make current thread (CPU) sleep...
1032             await Task.Delay(1);
1033
1034             // Delete all web indexed db.
1035             var context = webview.Context;
1036             context.DeleteAllWebIndexedDatabase();
1037
1038             //TODO... how to check if title is changed.
1039
1040             webview.PageLoadFinished -= onLoadFinished;
1041
1042             tlog.Debug(tag, $"WebContextDeleteAllWebIndexedDatabase END (OK)");
1043         }
1044
1045         [Test]
1046         [Category("P1")]
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()
1054         {
1055             tlog.Debug(tag, $"WebContextFreeUnusedMemory START");
1056
1057             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
1058             EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
1059             {
1060                 tcs.TrySetResult(true);
1061             };
1062             webview.PageLoadFinished += onLoadFinished;
1063
1064             webview.LoadUrl(urlForApplicatonCache);
1065             var result = await tcs.Task;
1066             Assert.IsTrue(result, "PageLoadFinished event should be invoked");
1067
1068             // Make current thread (CPU) sleep...
1069             await Task.Delay(1);
1070
1071             // Free unused memory if low memory.
1072             var context = webview.Context;
1073             context.FreeUnusedMemory();
1074
1075             webview.PageLoadFinished -= onLoadFinished;
1076
1077             tlog.Debug(tag, $"WebContextFreeUnusedMemory END (OK)");
1078         }
1079     }
1080 }