An XML document can be a valid HTML document. Try to instanciate
a HTMLDivElement to find out whether we are dealing with an actual
HTML document or not.
This commit is contained in:
gorhill 2015-08-28 10:33:58 -04:00
parent 3dd19b7708
commit 1a380f0959
2 changed files with 14 additions and 4 deletions

View File

@ -33,8 +33,13 @@
// https://github.com/chrisaljoudi/uBlock/issues/464 // https://github.com/chrisaljoudi/uBlock/issues/464
if ( document instanceof HTMLDocument === false ) { if ( document instanceof HTMLDocument === false ) {
//console.debug('contentscript-end.js > not a HTLMDocument'); // https://github.com/chrisaljoudi/uBlock/issues/1528
if (
document instanceof XMLDocument === false ||
document.createElement('div') instanceof HTMLDivElement === false
) {
return; return;
}
} }
// I've seen this happens on Firefox // I've seen this happens on Firefox

View File

@ -36,8 +36,13 @@
// https://github.com/chrisaljoudi/uBlock/issues/464 // https://github.com/chrisaljoudi/uBlock/issues/464
if ( document instanceof HTMLDocument === false ) { if ( document instanceof HTMLDocument === false ) {
//console.debug('contentscript-start.js > not a HTLMDocument'); // https://github.com/chrisaljoudi/uBlock/issues/1528
if (
document instanceof XMLDocument === false ||
document.createElement('div') instanceof HTMLDivElement === false
) {
return; return;
}
} }
// This can happen // This can happen