fix(core): unique WebContext for each window when TAURI_AUTOMATION unset
@@ -2388,6 +2388,7 @@ fn create_webview(
webview_builder = webview_builder.with_initialization_script(&script);
}
+ let webview = if let Ok("true") = std::env::var("TAURI_AUTOMATION").as_deref() {
let mut web_context = web_context.lock().expect("poisoned WebContext store");
let is_first_context = web_context.is_empty();
let web_context = match web_context.entry(webview_attributes.data_directory) {
@@ -2401,11 +2402,17 @@ fn create_webview(
vacant.insert(web_context)
}
};
-
- let webview = webview_builder
+ webview_builder
.with_web_context(web_context)
.build()
- .map_err(|e| Error::CreateWebview(Box::new(e)))?;
+ .map_err(|e| Error::CreateWebview(Box::new(e)))?
+ } else {
+ let mut context = WebContext::new(webview_attributes.data_directory.clone());
+ webview_builder
+ .with_web_context(&mut context)
+ .build()
+ .map_err(|e| Error::CreateWebview(Box::new(e)))?
+ };
Ok(WindowWrapper {
label,
