MicrosoftEdge / MicrosoftEdge/WebView2Feedback

ScriptToExecuteOnDocumentCreated not added after GetDeferral in NewWindowRequested

Open
#2,557 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

This issue seems to still be relevant in 2022. Why was it closed? There is a workaround, yes - but people will keep wasting time on this problem until it is fixed.

Edit: I just re-read the documentation of NewWindowRequested and found this sentence If a deferral is taken, then scripts are blocked until the deferral is completed..

It wasn't clear to me that ScriptToExecuteOnDocumentCreated would also be affected seeing as it doesn't imply any immediate script execution.

It might be good to mention ScriptToExecuteOnDocumentCreated explicitly in the remarks for NewWindowRequested

Even better would IMO be to throw an exception if methods are invoked at a time where the webview isn't in a suitable state yet.

Originally posted by @lsim in https://github.com/MicrosoftEdge/WebView2Feedback/issues/448#issuecomment-1168447338

AB#40224310

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the NewWindowRequested documentation and the issue's discussion about GetDeferral and ScriptToExecuteOnDocumentCreated. Update the remarks to state explicitly that scripts added with ScriptToExecuteOnDocumentCreated are affected while a deferral is active; the documentation should clearly explain this behavior.

Written by the indexing model from the issue text.

Assessment

Domain
api, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.