You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Replace document.write('<script ...>') with document.createElement('script')Β #9797
Which causes errors when the GWT output JS is used in a Chrome Extension:
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
Inspect the generated GWT Javascript code, you will see doc.write in it.
Known workarounds
I've tested the new template in a custom linker, which avoided document.write in the generated Javascript, hence eliminated such errors in Chrome Extension.
if the script is in the head of the page (document.body doesn't exist yet)
might then break the following lines that walk up the DOM trying to find the currently executing script.
There's definitely room from improvement, and these templates are quite old, but if they don't work for you I'd suggest creating your own linker. But IIRC the xsiframe linker works for browser extensions and shouldn't use document.write.
I was guessing probably document.write was used to guarantee execution order. If we could figure the correct place to inject the script tag, then perhaps we could use the DOM API instead of the document.write to create the script element.
Activity
tbroyer commentedon Jan 30, 2023
If the gwt.xml has
<script>elements, they'll be injected usingdocument.writetoo (IIRC, this is/was to guarantee execution order):gwt/dev/core/src/com/google/gwt/core/ext/linker/impl/ResourceInjectionUtil.java
Lines 78 to 94 in 38cefc3
AFAICT, your proposed change won't work:
document.bodydoesn't exist yet)There's definitely room from improvement, and these templates are quite old, but if they don't work for you I'd suggest creating your own linker. But IIRC the xsiframe linker works for browser extensions and shouldn't use
document.write.jiakuan commentedon Jan 30, 2023
I was guessing probably
document.writewas used to guarantee execution order. If we could figure the correct place to inject thescripttag, then perhaps we could use the DOM API instead of thedocument.writeto create thescriptelement.Avoid document write in single script linker loading
Avoid document write in single script linker loading (gwtproject#9847)