Test cases for script injection when opening a new window and navigating to a URL (incl. POST navigation).
The project loads an embedded web page with buttons and links. When any of them are clicked a new window should appear containing a WebView2 instance that:
- Has scripts added (via a call to
CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync
). - This can be verified using the automatically opened DevTools window that should show the "script injected - before setting NewWindow" line in the console.
Script injection is expected to work with any value of the rel
attribute of the <a>
and <form>
elements used to open the new window.
I.e., it must not be required to set rel="noopener"
.
The new window should display the DuckDuckGo search page.
The new window should display a button (Open Tab1) and the text "This content is generated purely by javascript"
The new window should display the DuckDuckGo search page.
The main window should display the Lite version of the DDG search page with a search box containing "test" and a Search button. The new window should display the search result page with actual results and the text box at the top should contain "test".
Case 1 and Case 2 are OK.
Case 3 and Case 4: the line "script injected - before setting NewWindow" is not shown, which means that script injection is not working.
This project requires:
- .NET6 SDK
- WebView2 canary version. To test you need to install Edge Canary.