{"action":"created","issue":{"url":"https://api.github.com/repos/tmpvar/jsdom/issues/1623","repository_url":"https://api.github.com/repos/tmpvar/jsdom","labels_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1623/labels{/name}","comments_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1623/comments","events_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1623/events","html_url":"https://github.com/tmpvar/jsdom/issues/1623","id":181242532,"number":1623,"title":"Clean way to get all \"browser\" globals?","user":{"login":"lukechilds","id":2123375,"avatar_url":"https://avatars.githubusercontent.com/u/2123375?v=3","gravatar_id":"","url":"https://api.github.com/users/lukechilds","html_url":"https://github.com/lukechilds","followers_url":"https://api.github.com/users/lukechilds/followers","following_url":"https://api.github.com/users/lukechilds/following{/other_user}","gists_url":"https://api.github.com/users/lukechilds/gists{/gist_id}","starred_url":"https://api.github.com/users/lukechilds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukechilds/subscriptions","organizations_url":"https://api.github.com/users/lukechilds/orgs","repos_url":"https://api.github.com/users/lukechilds/repos","events_url":"https://api.github.com/users/lukechilds/events{/privacy}","received_events_url":"https://api.github.com/users/lukechilds/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2016-10-05T19:21:34Z","updated_at":"2016-10-05T21:32:58Z","closed_at":null,"body":"Is there a clean way to get all variables that would normally be in the global scope in the browser? Basically everything on `window`?\r\n\r\nI'm sure this worked for me before:\r\n\r\n```js\r\nconst jsdom  = require('jsdom').jsdom;\r\nconst window = jsdom('<html><body></body></html>').defaultView;\r\n\r\nconst browserGlobals = Object.keys(window);\r\n```\r\n\r\nHowever it looks like at some point `jsdom` changed to using getters for some things on `window` so `Object.keys(window)` misses a lot of stuff.\r\n\r\nI'm currently using:\r\n\r\n```js\r\nconst jsdom  = require('jsdom').jsdom;\r\nconst window = jsdom('<html><body></body></html>').defaultView;\r\n\r\nconst browserGlobals = Object\r\n                         .keys(window)\r\n                         .concat(Object.keys(window._core))\r\n                         .filter(prop => prop.substring(0, 1) !== '_');\r\n```\r\n\r\nBut it feels a bit hacky, is there a cleaner way exposed by `jsdom` that I've overlooked?"},"comment":{"url":"https://api.github.com/repos/tmpvar/jsdom/issues/comments/251806032","html_url":"https://github.com/tmpvar/jsdom/issues/1623#issuecomment-251806032","issue_url":"https://api.github.com/repos/tmpvar/jsdom/issues/1623","id":251806032,"user":{"login":"vsemozhetbyt","id":10393198,"avatar_url":"https://avatars.githubusercontent.com/u/10393198?v=3","gravatar_id":"","url":"https://api.github.com/users/vsemozhetbyt","html_url":"https://github.com/vsemozhetbyt","followers_url":"https://api.github.com/users/vsemozhetbyt/followers","following_url":"https://api.github.com/users/vsemozhetbyt/following{/other_user}","gists_url":"https://api.github.com/users/vsemozhetbyt/gists{/gist_id}","starred_url":"https://api.github.com/users/vsemozhetbyt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsemozhetbyt/subscriptions","organizations_url":"https://api.github.com/users/vsemozhetbyt/orgs","repos_url":"https://api.github.com/users/vsemozhetbyt/repos","events_url":"https://api.github.com/users/vsemozhetbyt/events{/privacy}","received_events_url":"https://api.github.com/users/vsemozhetbyt/received_events","type":"User","site_admin":false},"created_at":"2016-10-05T21:32:58Z","updated_at":"2016-10-05T21:32:58Z","body":"Sorry for possible noize. Yes, [the env variant](https://gist.github.com/vsemozhetbyt/7c96672ae41ef4e89a1363543d4c1266) with `jsdom.env` gives [the different structure](https://gist.github.com/vsemozhetbyt/6554aeeb4353d60ad6435b09264e92c2)."}}
{"actor":{"display_login":"vsemozhetbyt"}}