Create an Engine
instance:
engine = EngineFactory.Create(new EngineOptions.Builder
{
RenderingMode = RenderingMode.HardwareAccelerated,
UserDataDirectory = folderBrowser,
LicenseKey = lic,
UserAgent = UA,
GoogleApiKey = "input key",
GoogleDefaultClientId = "put client id",
GoogleDefaultClientSecret = "put secret"
}
.Build());
Grant permission for all permission requests:
engine.Permissions.RequestPermissionHandler =
new Handler<RequestPermissionParameters, RequestPermissionResponse>(p =>
{
return RequestPermissionResponse.Grant();
});
When I check geolocation in https://browserleaks.com/geo or https://geolocation.com/
I see that the geolocation permissions are granted and I see my actual coordinates:
But if I open other web site like https://google.com or https://yandex.ru - I see that permission - denied and geolocation does not work. To check permission I create the following JS:
string perm = @"
var res;
var test = function(e){res=e};
navigator.permissions.query({ name: 'geolocation' }).then(result => {
test(result.state)
})
res
";
When the Google or Yandex pages are downloaded, I execute this JS for check so:
string permiss = I.ActiveTab.browser.MainFrame.ExecuteJavaScript<string>(perm).Result;
string res = I.ActiveTab.browser.MainFrame.ExecuteJavaScript<string>("res").Result;
For https://browserleaks.com/geo or https://geolocation.com/ I have the "res" variable all time granted, but in Google or Yandex - I have "res" all time denied.
Why so? If I do not create filtr
for URL when I create "engine.Permissions.RequestPermissionHandler".
I see that navigate not to page https://browserleaks.com/geo, DotNetBrowser does not go inside this code:
new Handler<RequestPermissionParameters, RequestPermissionResponse>(p =>
{
return RequestPermissionResponse.Grant();
});
and in page all permissions are denied.
What do I need to do to go into RequestPermissionHandler
every time for every web page?