Browse Source

fix uncaught exception

pull/2/head
gorhill 8 years ago
parent
commit
4ccb9bd0d4
  1. 10
      src/js/contentscript-end.js

10
src/js/contentscript-end.js

@ -155,7 +155,7 @@ var collapser = (function() {
var collapse = response.collapse; var collapse = response.collapse;
var placeholders = response.placeholders; var placeholders = response.placeholders;
var i = requests.length; var i = requests.length;
var request, entry, target, tagName, docurl;
var request, entry, target, tagName, docurl, replaced;
while ( i-- ) { while ( i-- ) {
request = requests[i]; request = requests[i];
if ( pendingRequests.hasOwnProperty(request.id) === false ) { if ( pendingRequests.hasOwnProperty(request.id) === false ) {
@ -183,11 +183,17 @@ var collapser = (function() {
// Special case: iframe // Special case: iframe
if ( tagName === 'iframe' ) { if ( tagName === 'iframe' ) {
docurl = 'data:text/html,' + encodeURIComponent(placeholders.iframe.replace(reURLplaceholder, request.url)); docurl = 'data:text/html,' + encodeURIComponent(placeholders.iframe.replace(reURLplaceholder, request.url));
replaced = false;
// Using contentWindow.location prevent tainting browser // Using contentWindow.location prevent tainting browser
// history -- i.e. breaking back button (seen on Chromium). // history -- i.e. breaking back button (seen on Chromium).
if ( target.contentWindow ) { if ( target.contentWindow ) {
try {
target.contentWindow.location.replace(docurl); target.contentWindow.location.replace(docurl);
} else {
replaced = true;
} catch(ex) {
}
}
if ( !replaced ) {
target.setAttribute('src', docurl); target.setAttribute('src', docurl);
} }
continue; continue;

Loading…
Cancel
Save