{"action":"created","issue":{"url":"https://api.github.com/repos/mafredri/cdp/issues/45","repository_url":"https://api.github.com/repos/mafredri/cdp","labels_url":"https://api.github.com/repos/mafredri/cdp/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/mafredri/cdp/issues/45/comments","events_url":"https://api.github.com/repos/mafredri/cdp/issues/45/events","html_url":"https://github.com/mafredri/cdp/issues/45","id":297295932,"node_id":"MDU6SXNzdWUyOTcyOTU5MzI=","number":45,"title":"Geolocation","user":{"login":"zfLQ2qx2","id":31103058,"node_id":"MDQ6VXNlcjMxMTAzMDU4","avatar_url":"https://avatars3.githubusercontent.com/u/31103058?v=4","gravatar_id":"","url":"https://api.github.com/users/zfLQ2qx2","html_url":"https://github.com/zfLQ2qx2","followers_url":"https://api.github.com/users/zfLQ2qx2/followers","following_url":"https://api.github.com/users/zfLQ2qx2/following{/other_user}","gists_url":"https://api.github.com/users/zfLQ2qx2/gists{/gist_id}","starred_url":"https://api.github.com/users/zfLQ2qx2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zfLQ2qx2/subscriptions","organizations_url":"https://api.github.com/users/zfLQ2qx2/orgs","repos_url":"https://api.github.com/users/zfLQ2qx2/repos","events_url":"https://api.github.com/users/zfLQ2qx2/events{/privacy}","received_events_url":"https://api.github.com/users/zfLQ2qx2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-02-15T00:41:03Z","updated_at":"2018-08-24T14:15:44Z","closed_at":null,"author_association":"NONE","body":"Do you have any advice how to do geolocation on headless chrome?\r\n\r\nOn regular chrome I can run this in the console:\r\n  navigator.geolocation.getCurrentPosition(function (position) { console.log(position); });\r\n\r\nAnd it will pop up a dialog asking for permission, then print the coordinates in the console.\r\n\r\nOn headless chrome I don't get any indication of a dialog box opening and I never receive a response.\r\n\r\nI tried adding an emulated position thinking that maybe by default headless chrome doesn't have a position:\r\n\r\n```\r\n        err = c.Emulation.SetGeolocationOverride(ctx, emulation.NewSetGeolocationOverrideArgs().SetLatitude(11.0).SetLongitude(12.0).SetAccuracy(13.0))\r\n        if err != nil {\r\n                log.Fatal(err)\r\n        }\r\n```\r\n\r\nAnd I don't receive any errors, however again when I try to query the geolocation I don't get any indication of a dialog box, and there is never a response to my query.\r\n"},"comment":{"url":"https://api.github.com/repos/mafredri/cdp/issues/comments/415772125","html_url":"https://github.com/mafredri/cdp/issues/45#issuecomment-415772125","issue_url":"https://api.github.com/repos/mafredri/cdp/issues/45","id":415772125,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNTc3MjEyNQ==","user":{"login":"mafredri","id":147409,"node_id":"MDQ6VXNlcjE0NzQwOQ==","avatar_url":"https://avatars2.githubusercontent.com/u/147409?v=4","gravatar_id":"","url":"https://api.github.com/users/mafredri","html_url":"https://github.com/mafredri","followers_url":"https://api.github.com/users/mafredri/followers","following_url":"https://api.github.com/users/mafredri/following{/other_user}","gists_url":"https://api.github.com/users/mafredri/gists{/gist_id}","starred_url":"https://api.github.com/users/mafredri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mafredri/subscriptions","organizations_url":"https://api.github.com/users/mafredri/orgs","repos_url":"https://api.github.com/users/mafredri/repos","events_url":"https://api.github.com/users/mafredri/events{/privacy}","received_events_url":"https://api.github.com/users/mafredri/received_events","type":"User","site_admin":false},"created_at":"2018-08-24T14:15:44Z","updated_at":"2018-08-24T14:15:44Z","author_association":"OWNER","body":"Looks like chrome has finally received methods for this (still doesn't work in headless, though!). But if you use the new API to grant access before accessing geolocation, it will work:\r\n\r\n```go\r\nerr = c.Browser.GrantPermissions(ctx,\r\n\tbrowser.NewGrantPermissionsArgs(\"https://www.google.com\", []browser.PermissionType{\r\n\t\tbrowser.PermissionTypeGeolocation,\r\n\t}),\r\n)\r\n```\r\n\r\nTested with latest cdp (v0.18.7) and Chrome Canary (70.0.3532.0).\r\n\r\n(Note: getting the `origin` right is important. Neither `*` nor `google.com` etc worked in my tests).\r\n\r\nPS. I've updated the gist above with a working sample."}}
{"actor":{"display_login":"mafredri"}}