Skip to content

Conversation

@Simon-Laux
Copy link
Contributor

@Simon-Laux Simon-Laux commented Mar 25, 2025

I need this to disable webrtc in all frames.

try {
window.RTCPeerConnection = ()=>{};
RTCPeerConnection = ()=>{};
} catch (e){console.error("failed to overwrite RTCPeerConnection apis",e)}
try {
    window.webkitRTCPeerConnection = ()=>{};
    webkitRTCPeerConnection = ()=>{};
} catch (e){}

Currently the init script only runs on the main script despite the documentation telling otherwise:

/// Since it runs on all top-level document navigastions (and also child frame page navigations
/// ...
pub fn initialization_script(mut self, script: &str) -> Self {

This pr exposes the argument (run_only_on_main_frame) whether to run in all frames or only on the main frame.

  • add API to run initialisation scripts on all frames
    • WebviewBuilder::initialization_script_on_all_frames
    • WebviewWindowBuilder::initialization_script_on_all_frames
    • WebviewAttributes::initialization_script_on_all_frames

Progress

@github-project-automation github-project-automation bot moved this from 📬Proposal to 🏗 In progress in Roadmap Mar 26, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2025

Package Changes Through a846962

There are 2 changes which include tauri with minor, tauri-runtime with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-runtime 2.5.1 2.6.0
tauri-runtime-wry 2.5.1 2.5.2
tauri 2.4.1 2.5.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@amrbashir
Copy link
Member

amrbashir commented Mar 26, 2025

there is also #11971 , I am fine to go with any just as long as it is not breaking change.

@Simon-Laux Simon-Laux marked this pull request as draft March 26, 2025 20:07
@Simon-Laux
Copy link
Contributor Author

I removed the breaking change making a new api instead. I named it initialization_script_on_all_frames because IMO the initialization_script_for_main_only name from the webkit api is very confusing.
But in the end I'm fine with either this pr or #11971 getting merged, most important is that the feature is accessible.

@Simon-Laux Simon-Laux marked this pull request as ready for review March 26, 2025 20:16
@Simon-Laux Simon-Laux force-pushed the change_initialization_scripts_to_allow_to_run_in_all_frames branch from 25f774b to e2989d1 Compare March 26, 2025 20:17
Simon-Laux and others added 2 commits March 27, 2025 16:18
Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
Copy link
Contributor

@Legend-Master Legend-Master left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good to me, just wait for lucas to confirm if it's ok to modify WebviewAttributes

Copy link
Contributor

@Legend-Master Legend-Master left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patience 🙃

@Legend-Master Legend-Master changed the title api!: expose api to run initialisation scripts on all frames. api: expose api to run initialization scripts on all frames. Apr 2, 2025
@Legend-Master Legend-Master changed the title api: expose api to run initialization scripts on all frames. feat: expose api to run initialization scripts on all frames. Apr 2, 2025
@Legend-Master Legend-Master merged commit 8cf662e into tauri-apps:dev Apr 2, 2025
20 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to 🔎 In audit in Roadmap Apr 2, 2025
kandrelczyk pushed a commit to kandrelczyk/tauri that referenced this pull request Apr 7, 2025
…apps#13076)

* api!: expose api to run initialisation scripts on all frames.

* remove breaking change, add new api instead.

* Update .changes/init-script-on-all-frames.md

Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>

* use struct `InitializationScript` instead of tuple

* Update crates/tauri-runtime/src/webview.rs

Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>

* Apply suggestions from code review

* Update crates/tauri/src/webview/webview_window.rs

---------

Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
kandrelczyk pushed a commit to kandrelczyk/tauri that referenced this pull request Apr 7, 2025
…apps#13076)

* api!: expose api to run initialisation scripts on all frames.

* remove breaking change, add new api instead.

* Update .changes/init-script-on-all-frames.md

Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>

* use struct `InitializationScript` instead of tuple

* Update crates/tauri-runtime/src/webview.rs

Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>

* Apply suggestions from code review

* Update crates/tauri/src/webview/webview_window.rs

---------

Co-authored-by: Tony <68118705+Legend-Master@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 In audit

Development

Successfully merging this pull request may close these issues.

4 participants