fix(windows): fix init scripts running twicec#1418
Conversation
closes #2051
Package Changes Through bc976b0There are 1 changes which include wry with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
| webview.add_ContentLoading( | ||
| &ContentLoadingEventHandler::create(Box::new(move |webview, _| { | ||
| let Some(webview) = webview else { | ||
| return Ok(()); | ||
| }; | ||
|
|
||
| for (script, _) in scripts.iter().filter(|(_, for_main)| *for_main) { | ||
| Self::execute_script(&webview, script.clone(), |_| ())?; | ||
| } | ||
|
|
||
| Ok(()) | ||
| })), | ||
| token, | ||
| )?; |
There was a problem hiding this comment.
This looks fine but actually it sometimes injects the script at the wrong timing, for example, currently Tauri's helloworld example will throw an error saying window.__TAURI__ is undefined but works if you reload the page or use AddScriptToExecuteOnDocumentCreated
@amrbashir I'm not sure if we want to keep this or just don't support injecting to main page only on Windows
There was a problem hiding this comment.
I guess we should revert? I mean we always injected into all frames, so I don't think it should be harmful, or do we still need this @tweidinger
There was a problem hiding this comment.
We moved to selective injection due to security issues like GHSA-57fm-592m-34r7 - windows was always a bit of a special case since it allows injection into same origin but afaik we did not want this Auto injection behavior.
closes tauri-apps/plugins-workspace#2051