From c5fa113f401c905fd8b1d5dad5fba552cd78db8d Mon Sep 17 00:00:00 2001 From: matthemsteger Date: Thu, 20 Aug 2015 22:07:49 -0400 Subject: [PATCH] Fix Access Denied Errors in IE 11 Fix access denied errors in IE 11 when a cross origin frame tries to use getOwnPropertyNames. Apparently IE has a bug where it uses the function defined in the original window. --- lib/weakmap.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/weakmap.js b/lib/weakmap.js index ed2ddd9..efceb8b 100644 --- a/lib/weakmap.js +++ b/lib/weakmap.js @@ -30,6 +30,7 @@ void function(global, undefined_, undefined){ var getProps = Object.getOwnPropertyNames, + cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [], defProp = Object.defineProperty, toSource = Function.prototype.toString, create = Object.create, @@ -87,7 +88,16 @@ void function(global, undefined_, undefined){ // common per-object storage area made visible by patching getOwnPropertyNames' define(Object, namedFunction('getOwnPropertyNames', function getOwnPropertyNames(obj){ - var props = getProps(obj); + var coercedObj = Object(obj), props; + if (coercedObj.toString() === '[object Window]') { + try { + props = getProps(obj); + } catch (e) { + props = cachedWindowNames; + } + } else { + props = getProps(obj); + } if (hasOwn.call(obj, globalID)) props.splice(props.indexOf(globalID), 1); return props;