Prevent set-constant properties from being overtaken

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/156#issuecomment-707095193

Additionally, while investigating the issue I removed
code which is no longer needed since content scripts
are now injected in `about:blank` frames since 1.29.0.
This commit is contained in:
Raymond Hill 2020-10-12 10:08:51 -04:00
parent 422e3f676f
commit 6e010ecc0f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 4 additions and 62 deletions

View File

@ -754,7 +754,7 @@
} }
} }
Object.defineProperty(owner, prop, { Object.defineProperty(owner, prop, {
configurable: true, configurable: false,
get() { get() {
if ( prevGetter !== undefined ) { if ( prevGetter !== undefined ) {
prevGetter(); prevGetter();

View File

@ -94,64 +94,6 @@
} }
}; };
injectScriptlets(document); injectScriptlets(document);
const processIFrame = function(iframe) {
const src = iframe.src;
if ( /^https?:\/\//.test(src) === false ) {
injectScriptlets(iframe.contentDocument);
}
};
let observerTimer,
observerLists = [];
const observerAsync = function() {
for ( const nodelist of observerLists ) {
for ( const node of nodelist ) {
if ( node.nodeType !== 1 ) { continue; }
if ( node.parentElement === null ) { continue; }
if ( node.localName === 'iframe' ) {
processIFrame(node);
}
if ( node.childElementCount === 0 ) { continue; }
let iframes = node.querySelectorAll('iframe');
for ( const iframe of iframes ) {
processIFrame(iframe);
}
}
}
observerLists = [];
observerTimer = undefined;
};
const ready = function(ev) {
if ( ev !== undefined ) {
window.removeEventListener(ev.type, ready);
}
const iframes = document.getElementsByTagName('iframe');
if ( iframes.length !== 0 ) {
observerLists.push(iframes);
observerTimer = setTimeout(observerAsync, 1);
}
const observer = new MutationObserver(function(mutations) {
for ( const mutation of mutations ) {
if ( mutation.addedNodes.length !== 0 ) {
observerLists.push(mutation.addedNodes);
}
}
if (
observerLists.length !== 0 &&
observerTimer === undefined
) {
observerTimer = setTimeout(observerAsync, 1);
}
});
observer.observe(
document.documentElement,
{ childList: true, subtree: true }
);
};
if ( document.readyState === 'loading' ) {
window.addEventListener('DOMContentLoaded', ready);
} else {
ready();
}
}.toString(), }.toString(),
')(', ')(',
'"', 'hostname-slot', '", ', '"', 'hostname-slot', '", ',
@ -457,10 +399,10 @@
code = 'debugger;\n' + code; code = 'debugger;\n' + code;
} }
vAPI.tabs.executeScript(details.tabId, { vAPI.tabs.executeScript(details.tabId, {
code: code, code,
frameId: details.frameId, frameId: details.frameId,
matchAboutBlank: false, matchAboutBlank: true,
runAt: 'document_start' runAt: 'document_start',
}); });
}; };