Fixed race condition causing noscript elements not to be rendered sometimes.
This commit is contained in:
parent
54e4671463
commit
7c77a1f913
|
@ -115,7 +115,6 @@ let documentOrigin = new URL(document.URL).origin;
|
|||
window.addEventListener("securitypolicyviolation", e => {
|
||||
if (!e.isTrusted) return;
|
||||
let {violatedDirective, originalPolicy} = e;
|
||||
if (violatedDirective.startsWith(`script-src`) && originalPolicy.includes("script-src 'none'")) onScriptDisabled();
|
||||
|
||||
let type = violatedDirective.split("-", 1)[0]; // e.g. script-src 'none' => script
|
||||
let url = e.blockedURI;
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
function onScriptDisabled() {
|
||||
onScriptDisabled = () => {};
|
||||
|
||||
let emulateNoScriptElement = () => {
|
||||
let emulateNoscriptElement = () => {
|
||||
if (ns.allows("noscript")) {
|
||||
NoscriptElements.emulate(true);
|
||||
}
|
||||
};
|
||||
|
||||
debug("onScriptDisabled", document.readyState, new Error().stack);
|
||||
if (document.readyState === "loading") {
|
||||
window.addEventListener("DOMContentLoaded", emulateNoScriptElement, true);
|
||||
window.addEventListener("DOMContentLoaded", emulateNoscriptElement, true);
|
||||
return;
|
||||
} else {
|
||||
emulateNoScriptElement();
|
||||
emulateNoscriptElement();
|
||||
}
|
||||
|
||||
let eraser = {
|
||||
|
|
Loading…
Reference in New Issue