Skip to content

Commit

Permalink
Update window to version 4.2.6 (#75)
Browse files Browse the repository at this point in the history
* Require window@4.2.6

* Set global properties as getters

Some properties will throw an error when accessed in certain conditions. We don't want to throw these errors, by accessing them when we setup the environemnt. Instead we should create getters for all window properties so they can throw the appropriate errors when accessed by user code.

* Update expectedProperties.json for window@4.2.6
  • Loading branch information
lukechilds committed Feb 23, 2019
1 parent 71aed2b commit ffb7083
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"homepage": "https://github.com/lukechilds/browser-env#readme",
"dependencies": {
"window": "4.2.5"
"window": "4.2.6"
},
"devDependencies": {
"ava": "^0.25.0",
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ const browserEnv = function () {

// Copy what's left to the Node.js global scope
.forEach(prop => {
global[prop] = window[prop];
Object.defineProperty(global, prop, {
configurable: true,
get: () => window[prop]
});
});

// Return reference to original window object
Expand Down
108 changes: 108 additions & 0 deletions test/fixtures/expectedProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"HTMLQuoteElement",
"HTMLScriptElement",
"HTMLSelectElement",
"HTMLSlotElement",
"HTMLSourceElement",
"HTMLSpanElement",
"HTMLStyleElement",
Expand All @@ -113,21 +114,28 @@
"HashChangeEvent",
"History",
"Image",
"InputEvent",
"Int16Array",
"Int32Array",
"Int8Array",
"KeyboardEvent",
"Location",
"MediaList",
"MessageEvent",
"MimeType",
"MimeTypeArray",
"MouseEvent",
"MutationObserver",
"MutationRecord",
"NamedNodeMap",
"Node",
"NodeFilter",
"NodeIterator",
"NodeList",
"Option",
"Performance",
"Plugin",
"PluginArray",
"PopStateEvent",
"ProcessingInstruction",
"ProgressEvent",
Expand All @@ -137,7 +145,11 @@
"SVGNumber",
"SVGSVGElement",
"SVGStringList",
"SVGTitleElement",
"Screen",
"ShadowRoot",
"Storage",
"StorageEvent",
"StyleSheet",
"StyleSheetList",
"Text",
Expand All @@ -150,28 +162,42 @@
"Uint32Array",
"Uint8Array",
"Uint8ClampedArray",
"ValidityState",
"WebSocket",
"WheelEvent",
"Window",
"XMLDocument",
"XMLHttpRequest",
"XMLHttpRequestEventTarget",
"XMLHttpRequestUpload",
"XMLSerializer",
"XPathEvaluator",
"XPathException",
"XPathExpression",
"XPathResult",
"__stopAllTimers",
"_commonForOrigin",
"_currentOriginData",
"_document",
"_eventHandlers",
"_frameElement",
"_getEventHandlerFor",
"_getEventHandlerTarget",
"_globalEventChanged",
"_globalProxy",
"_initGlobalEvents",
"_length",
"_localStorage",
"_parent",
"_pretendToBeVisual",
"_proxyWindowEventsToWindow",
"_registeredHandlers",
"_resourceLoader",
"_runScripts",
"_sessionHistory",
"_sessionStorage",
"_setEventHandlerFor",
"_storageQuota",
"_top",
"_virtualConsole",
"addEventListener",
Expand All @@ -197,13 +223,93 @@
"innerHeight",
"innerWidth",
"length",
"localStorage",
"location",
"locationbar",
"menubar",
"moveBy",
"moveTo",
"name",
"navigator",
"onabort",
"onafterprint",
"onautocomplete",
"onautocompleteerror",
"onbeforeprint",
"onbeforeunload",
"onblur",
"oncancel",
"oncanplay",
"oncanplaythrough",
"onchange",
"onclick",
"onclose",
"oncontextmenu",
"oncuechange",
"ondblclick",
"ondrag",
"ondragend",
"ondragenter",
"ondragexit",
"ondragleave",
"ondragover",
"ondragstart",
"ondrop",
"ondurationchange",
"onemptied",
"onended",
"onerror",
"onfocus",
"onhashchange",
"oninput",
"oninvalid",
"onkeydown",
"onkeypress",
"onkeyup",
"onlanguagechange",
"onload",
"onloadeddata",
"onloadedmetadata",
"onloadstart",
"onmessage",
"onmessageerror",
"onmousedown",
"onmouseenter",
"onmouseleave",
"onmousemove",
"onmouseout",
"onmouseover",
"onmouseup",
"onoffline",
"ononline",
"onpagehide",
"onpageshow",
"onpause",
"onplay",
"onplaying",
"onpopstate",
"onprogress",
"onratechange",
"onrejectionhandled",
"onreset",
"onresize",
"onscroll",
"onsecuritypolicyviolation",
"onseeked",
"onseeking",
"onselect",
"onsort",
"onstalled",
"onstorage",
"onsubmit",
"onsuspend",
"ontimeupdate",
"ontoggle",
"onunhandledrejection",
"onunload",
"onvolumechange",
"onwaiting",
"onwheel",
"open",
"outerHeight",
"outerWidth",
Expand Down Expand Up @@ -231,8 +337,10 @@
"scrollY",
"scrollbars",
"self",
"sessionStorage",
"setInterval",
"setTimeout",
"status",
"statusbar",
"stop",
"toolbar",
Expand Down

0 comments on commit ffb7083

Please sign in to comment.