diff --git a/lib/frame.js b/lib/frame.js index a9b31a9..c5c9d00 100644 --- a/lib/frame.js +++ b/lib/frame.js @@ -81,10 +81,6 @@ var interceptedWindows = new WeakMap(); function interceptWindow(window){ - if (!enabled || interceptedWindows.get(window)){ - return false; - } - try { var href = window.location.href; } @@ -95,6 +91,10 @@ return false; } + if (!enabled || interceptedWindows.get(getWrapped(window))){ + return false; + } + message("intercepting window", window); intercept( {subject: window}, @@ -112,7 +112,9 @@ configureable: true, get: exportFunction(function(){ var window = oldContentWindowGetter.call(this); - interceptWindow(window); + if (window){ + interceptWindow(window); + } return window; }, window) } @@ -126,14 +128,16 @@ configureable: true, get: exportFunction(function(){ var document = oldContentDocumentGetter.call(this); - interceptWindow(document.defaultView); + if (document){ + interceptWindow(document.defaultView); + } return document; }, window) } ); }); - interceptedWindows.set(window, true); + interceptedWindows.set(getWrapped(window), true); return true; }