|
66 | 66 | return; |
67 | 67 | } |
68 | 68 |
|
69 | | - debug("Initial readyState and body", document.readyState, document.body); |
| 69 | + debug("Initial document state", document.readyState, document.documentElement, document.head, document.body); // DEV_ONLY |
70 | 70 |
|
71 | | - let mustFreeze = UA.isMozilla |
| 71 | + let mustFreeze = document.head && UA.isMozilla |
72 | 72 | && (!/^(?:image|video|audio)/.test(document.contentType) || document instanceof XMLDocument) |
73 | 73 | && document.readyState !== "complete"; |
74 | 74 |
|
75 | 75 | if (mustFreeze) { |
76 | 76 | // Mozilla has already parsed the <head> element, we must take extra steps... |
77 | | - |
78 | 77 | try { |
79 | 78 | DocumentFreezer.freeze(); |
80 | 79 |
|
|
85 | 84 | debug("Readystate: %s, suppressedScripts = %s, canScript = %s", readyState, DocumentFreezer.suppressedScripts, ns.canScript); |
86 | 85 |
|
87 | 86 | if (!ns.canScript) { |
88 | | - setTimeout(() => DocumentFreezer.unfreeze(), 0); |
| 87 | + queueMicrotask(() => DocumentFreezer.unfreeze()); |
89 | 88 | let normalizeDir = e => { |
90 | 89 | // Chromium does this automatically. We need it to understand we're a directory earlier and allow browser UI scripts. |
91 | 90 | if (document.baseURI === document.URL + "/") { |
|
156 | 155 | DocumentFreezer.unfreeze(); |
157 | 156 | let scripts = [], deferred = []; |
158 | 157 | // push deferred scripts, if any, to the end |
159 | | - for (let s of [...document.querySelectorAll("script")]) { |
| 158 | + for (let s of document.getElementsByTagName("script")) { |
160 | 159 | (s.defer && !s.text ? deferred : scripts).push(s); |
161 | 160 | s.addEventListener("beforescriptexecute", e => { |
162 | 161 | console.debug("Suppressing", script); |
|
0 commit comments