Skip to content

Commit cfc01c2

Browse files
authored
Update AdditionalAllowedFrameAncestors.md
1 parent 00ed069 commit cfc01c2

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

specs/AdditionalAllowedFrameAncestors.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ To embed other sites in an trusted page with modified allowed frame ancestors
1616
- Set AdditionalAllowedFrameAncestors property of the NavigationStartingEventArgs to a list additional allowed frame ancestors using the same syntax for the source list of [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors). Basically, it is a space delimited list. All source syntax of Content-Security-Policy frame-ancestors directive are supported.
1717

1818
The list should normally only contain the origin of the top page.
19-
If you are embedding other sites through nested iframes and the origins of some of the intermediate iframes are different from the origin of the top page and those origins might not be allowed by the site's original policies, the list should also include those origins. As an example, if you owns the content on https://example.com and https://www.example.com and uses them on top page and some intermediate iframes, you should set the list as "https://example.com https://www.example.com".
19+
If you are embedding other sites through nested iframes and the origins of some of the intermediate iframes are different from the origin of the top page and those origins might not be allowed by the site's original policies, the list should also include those origins. As an example, if you owns the content on `https://example.com` and `https://www.example.com` and uses them on top page and some intermediate iframes, you should set the list as `https://example.com https://www.example.com`.
2020

21-
You should only add an origin to the list if it is fully trusted. When possible, you should try to limit the usage of the API to the targetted app scenarios. For example, we can set a specific name attribute to the iframe that is used to embed sites (something like `<iframe name="my_site_embedding_frame">`) and then detect the embedding scenario when the trusted page is navigated to and the embedding iframe is created.
21+
You should only add an origin to the list if it is fully trusted. When possible, you should try to limit the usage of the API to the targetted app scenarios. For example, you can use an iframe with a specific name attribute to embed sites (something like `<iframe name="my_site_embedding_frame">`) and then detect the embedding scenario is active when the trusted page is navigated to and the embedding iframe is created.
2222

2323
# Examples
2424
## Win32 C++
@@ -78,8 +78,8 @@ void MyApp::HandleEmbeddedSites()
7878
{
7979
// We are on trusted pages. Now check whether it is the iframe we plan
8080
// to embed other sites.
81-
// We are know that on the page, we are using an
82-
// <iframe name="my_site_embedding_frame"> to embed other sites.
81+
// We know that our trusted page is using <iframe name="my_site_embedding_frame">
82+
// element to embed other sites.
8383
const std::wstring siteEmbeddingFrameName = L"my_site_embedding_frame";
8484
wil::com_ptr<ICoreWebView2Frame> webviewFrame;
8585
CHECK_FAILURE(args->get_Frame(&webviewFrame));
@@ -105,6 +105,7 @@ void MyApp::HandleEmbeddedSites()
105105
})
106106
.Get(),
107107
nullptr));
108+
108109
// Using FrameNavigationStarting event instead of NavigationStarting event of CoreWebViewFrame
109110
// to cover all possible nested iframes inside the embedded site as CoreWebViewFrame
110111
// object currently only support first level iframes in the top page.
@@ -162,7 +163,7 @@ void MyApp::HandleEmbeddedSites()
162163
// The result is recorded in m_embeddingSite.
163164
private void CoreWebView2_FrameCreated(CoreWebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2FrameCreatedEventArgs args)
164165
{
165-
// We are know that our trusted page is using <iframe name="my_site_embedding_frame"> element to embed other sites.
166+
// We know that our trusted page is using <iframe name="my_site_embedding_frame"> element to embed other sites.
166167
// We are embedding sites when we are on trusted pages and the embedding iframe is created.
167168
const string siteEmbeddingFrameName = "my_site_embedding_frame";
168169
if (IsAppContentUri(sender.Source) && (args.Frame.Name == siteEmbeddingFrameName))
@@ -207,12 +208,13 @@ interface ICoreWebView2NavigationStartingEventArgs_2 : ICoreWebView2NavigationSt
207208
/// The app may set this property to allow a frame to be embedded by certain additional ancestors besides what is allowed by
208209
/// http header [X-Frame-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options)
209210
/// and [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors).
210-
/// If set, a frame ancestor is allowed if it is allowed by the additional allowed frame ancestoers or original http header from the site.
211+
/// If set, a frame ancestor is allowed if it is allowed by the additional allowed frame
212+
/// ancestoers or original http header from the site.
211213
/// Whether an ancestor is allowed by the additional allowed frame ancestoers is done the same way as if the site provided
212214
/// it as the source list of the Content-Security-Policy frame-ancestors directive.
213-
/// For example, if https://example.com and https://www.example.com are the origins of the top
214-
/// page and intemediate iframes for a nested iframe that is embedding a site, and you fully trust
215-
/// those origins, you should set thus property to "https://example.com https://www.example.com".
215+
/// For example, if `https://example.com` and `https://www.example.com` are the origins of the top
216+
/// page and intemediate iframes that embed a nested site embedding iframe, and you fully trust
217+
/// those origins, you should set thus property to `https://example.com https://www.example.com`.
216218
/// This property gives the app the ability to use iframe to embed sites that otherwise
217219
/// could not be embedded in an iframe in trusted app pages.
218220
/// This could potentially subject the embedded sites to [Clickjacking](https://en.wikipedia.org/wiki/Clickjacking)
@@ -222,9 +224,9 @@ interface ICoreWebView2NavigationStartingEventArgs_2 : ICoreWebView2NavigationSt
222224
/// frames instead of wildcard characters for this property.
223225
/// This API is to provide limited support for app scenarios that used to be supported by
224226
/// `<webview>` element in other solutions like JavaScript UWP apps and Electron.
225-
/// You should limit the usage of this property to trusted pages, and if possible, to specific iframe and
226-
/// specific navigation target url, by checking the `Source` of the WebView2, the `Name`
227-
/// of the ICoreWebView2Frame and `Uri` of the event args.
227+
/// You should limit the usage of this property to trusted pages, and specific navigation
228+
/// target url, by checking the `Source` of the WebView2, and `Uri` of the event args.
229+
///
228230
/// This property is ignored for top level document navigation.
229231
///
230232
[propput] HRESULT AdditionalAllowedFrameAncestors([in] LPCWSTR value);

0 commit comments

Comments
 (0)