Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03d2535

Browse files
authored
fix: Disable Initialization Script Injection into Subframes on MacOS (#1269)
1 parent 1e65049 commit 03d2535

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wry": patch
3+
---
4+
5+
On macOS, disable initialization script injection into subframes.

src/webkitgtk/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ impl InnerWebView {
601601
if let Some(manager) = self.webview.user_content_manager() {
602602
let script = UserScript::new(
603603
js,
604+
// TODO: feature to allow injecting into subframes
604605
UserContentInjectedFrames::TopFrame,
605606
UserScriptInjectionTime::Start,
606607
&[],

src/webview2/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ impl InnerWebView {
11011101
);
11021102
}
11031103

1104+
// TODO: feature to allow injecting into (specific) subframes
11041105
#[inline]
11051106
fn add_script_to_execute_on_document_created(webview: &ICoreWebView2, js: String) -> Result<()> {
11061107
let webview = webview.clone();

src/wkwebview/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,10 +1085,8 @@ r#"Object.defineProperty(window, 'ipc', {
10851085
unsafe {
10861086
let userscript: id = msg_send![class!(WKUserScript), alloc];
10871087
let script: id =
1088-
// FIXME: We allow subframe injection because webview2 does and cannot be disabled (currently).
1089-
// once webview2 allows disabling all-frame script injection, forMainFrameOnly should be enabled
1090-
// if it does not break anything. (originally added for isolation pattern).
1091-
msg_send![userscript, initWithSource:NSString::new(js) injectionTime:0 forMainFrameOnly:0];
1088+
// TODO: feature to allow injecting into subframes
1089+
msg_send![userscript, initWithSource:NSString::new(js) injectionTime:0 forMainFrameOnly:1];
10921090
let _: () = msg_send![self.manager, addUserScript: script];
10931091
}
10941092
}

0 commit comments

Comments
 (0)