From 2f01fcda54246693f5378fab03a08adeb18a8fa2 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 21 Dec 2016 11:44:03 -0500 Subject: [PATCH] fix #2256 --- platform/firefox/vapi-client.js | 14 ++++++++++++++ src/js/contentscript.js | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/platform/firefox/vapi-client.js b/platform/firefox/vapi-client.js index b34f2183a..90c46334d 100644 --- a/platform/firefox/vapi-client.js +++ b/platform/firefox/vapi-client.js @@ -510,6 +510,20 @@ if ( self.injectCSS ) { /******************************************************************************/ +// https://bugzilla.mozilla.org/show_bug.cgi?id=444165 +// https://github.com/gorhill/uBlock/issues/2256 +// Not the prettiest solution, but that's the safest/simplest I can think +// of at this point. If/when bugzilla issue above is solved, we will need +// version detection to decide whether the patch needs to be applied. + +vAPI.iframeLoadEventPatch = function(target) { + if ( target.localName === 'iframe' ) { + target.dispatchEvent(new Event('load')); + } +}; + +/******************************************************************************/ + // No need to have vAPI client linger around after shutdown if // we are not a top window (because element picker can still // be injected in top window). diff --git a/src/js/contentscript.js b/src/js/contentscript.js index d297caaa2..91ef518a9 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -947,6 +947,8 @@ vAPI.domCollapser = (function() { netSelectorCacheCountMax = response.netSelectorCacheCountMax, aa = [ null ], request, key, entry, target, value; + // https://github.com/gorhill/uBlock/issues/2256 + var iframeLoadEventPatch = vAPI.iframeLoadEventPatch; // Important: process in chronological order -- this ensures the // cached selectors are the most useful ones. for ( var i = 0, ni = requests.length; i < ni; i++ ) { @@ -980,6 +982,7 @@ vAPI.domCollapser = (function() { selectors.push(request.tag + '[' + request.attr + '="' + value + '"]'); netSelectorCacheCount += 1; } + if ( iframeLoadEventPatch ) { iframeLoadEventPatch(target); } } } if ( selectors.length !== 0 ) { @@ -1030,9 +1033,6 @@ vAPI.domCollapser = (function() { } }; - // If needed eventually, we could listen to `src` attribute changes - // for iframes. - var add = function(target) { var tag = target.localName; var prop = src1stProps[tag];