From e686b1410691964a2b2d15759cd45a58ac253757 Mon Sep 17 00:00:00 2001 From: kkapsner Date: Tue, 10 Oct 2017 21:11:50 +0200 Subject: [PATCH] Improved window intercepting. --- lib/frame.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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; }