From 73ed896a855610d5eae578f68e4b69697fd38f74 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 12 May 2015 08:22:05 -0400 Subject: [PATCH] this fixes browser history quirk on Chromium --- src/js/contentscript-end.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 836dcbc..4563ffa 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -184,7 +184,7 @@ var collapser = (function() { var collapse = response.collapse; var placeholders = response.placeholders; var i = requests.length; - var request, entry, target, tagName; + var request, entry, target, tagName, docurl; while ( i-- ) { request = requests[i]; if ( pendingRequests.hasOwnProperty(request.id) === false ) { @@ -211,12 +211,14 @@ var collapser = (function() { // Special case: iframe if ( tagName === 'iframe' ) { - target.setAttribute( - 'src', - 'data:text/html,' + encodeURIComponent( - placeholders.iframe.replace(reURLplaceholder, request.url) - ) - ); + docurl = 'data:text/html,' + encodeURIComponent(placeholders.iframe.replace(reURLplaceholder, request.url)); + // Using contentWindow.location prevent tainting browser + // history -- i.e. breaking back button (seen on Chromium). + if ( target.contentWindow ) { + target.contentWindow.location.replace(docurl); + } else { + target.setAttribute('src', docurl); + } continue; }