|
4 | 4 |
|
5 | 5 | using System;
|
6 | 6 | using System.IO;
|
| 7 | +using System.Threading.Tasks; |
| 8 | +using CefSharp.Enums; |
| 9 | +using CefSharp.Example; |
| 10 | +using CefSharp.Internals; |
7 | 11 | using Xunit;
|
8 | 12 |
|
9 | 13 | namespace CefSharp.Test.Framework
|
@@ -31,5 +35,55 @@ public void IsSharingWith()
|
31 | 35 |
|
32 | 36 | Assert.True(ctx1.IsSharingWith(ctx2));
|
33 | 37 | }
|
| 38 | + |
| 39 | + [Fact] |
| 40 | + public void CanGetContentSetting() |
| 41 | + { |
| 42 | + var ctx = RequestContext.Configure() |
| 43 | + .WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache1")) |
| 44 | + .Create(); |
| 45 | + |
| 46 | + var actual = ctx.GetContentSetting(CefExample.DefaultUrl, null, ContentSettingTypes.Autoplay); |
| 47 | + |
| 48 | + Assert.Equal(ContentSettingValues.Default, actual); |
| 49 | + } |
| 50 | + |
| 51 | + [Fact] |
| 52 | + public async Task CanSetContentSetting() |
| 53 | + { |
| 54 | + var ctx = RequestContext.Configure() |
| 55 | + .WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache1")) |
| 56 | + .Create(); |
| 57 | + |
| 58 | + var actual = ContentSettingValues.Default; |
| 59 | + |
| 60 | + await CefThread.ExecuteOnUiThread(() => |
| 61 | + { |
| 62 | + ctx.SetContentSetting(CefExample.DefaultUrl, null, ContentSettingTypes.Autoplay, ContentSettingValues.Block); |
| 63 | + |
| 64 | + actual = ctx.GetContentSetting(CefExample.DefaultUrl, null, ContentSettingTypes.Autoplay); |
| 65 | + }); |
| 66 | + |
| 67 | + Assert.Equal(ContentSettingValues.Block, actual); |
| 68 | + } |
| 69 | + |
| 70 | + [Fact] |
| 71 | + public async Task CanSetWebsiteSetting() |
| 72 | + { |
| 73 | + var ctx = RequestContext.Configure() |
| 74 | + .WithCachePath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\TempCache1")) |
| 75 | + .Create(); |
| 76 | + |
| 77 | + object actual = ContentSettingValues.Default; |
| 78 | + |
| 79 | + await CefThread.ExecuteOnUiThread(() => |
| 80 | + { |
| 81 | + ctx.SetWebsiteSetting(CefExample.DefaultUrl, null, ContentSettingTypes.Popups, (int)ContentSettingValues.Allow); |
| 82 | + |
| 83 | + actual = ctx.GetWebsiteSetting(CefExample.DefaultUrl, null, ContentSettingTypes.Popups); |
| 84 | + }); |
| 85 | + |
| 86 | + Assert.Equal(ContentSettingValues.Allow, (ContentSettingValues)actual); |
| 87 | + } |
34 | 88 | }
|
35 | 89 | }
|
0 commit comments