Bug 543435 Comment 190 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #188)
> I guess you mean that we don't get it as part of https://searchfox.org/mozilla-central/rev/a9824b3ffc2efea7a317f114bc3192ccdffa0ef7/dom/ipc/WindowGlobalTypes.ipdlh#20,26 ?

Right.

`CreateBrowser` sets `aWindowInit.principal()` to `nsOpenWindowInfo::PrincipalToInheritForAboutBlank()`, which is sent to the child and thereby cloned. The principal has a `const mOriginSuffix`, which contains the `firstPartyDomain`.

From `RecvConstructBrowser`, we call `BrowserChild::Init`, `nsWebBrowser::Create`, `nsDocShell::InitWindow`, `Initialize`, `EnsureDocumentViewer`, `CreateAboutBlankDocumentViewer`, `nsContentDLF::CreateBlankDocument`, `nsHTMLDocument::ResetToURI`, `Document::ResetToURI`, and finally `Document::SetPrincipals`.

From what I see, the `firstPartyDomain` is usually set up in `nsDocShellLoadState::SetupInheritingPrincipal()` and needs an URI, which we don't have during browser construction. But at the end of it, the Document principal is set, so this is where we would have to create a new Principal.
(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #188)
> I guess you mean that we don't get it as part of https://searchfox.org/mozilla-central/rev/a9824b3ffc2efea7a317f114bc3192ccdffa0ef7/dom/ipc/WindowGlobalTypes.ipdlh#20,26 ?

Right.

`CreateBrowser` sets `aWindowInit.principal()` to `nsOpenWindowInfo::PrincipalToInheritForAboutBlank()`, which is sent to the child and thereby cloned. The principal has a `const mOriginSuffix`, which contains the `firstPartyDomain`. For this `PrincipalToInheritForAboutBlank`, `mFirstPartyDomain` is empty.

From `RecvConstructBrowser`, we call `BrowserChild::Init`, `nsWebBrowser::Create`, `nsDocShell::InitWindow`, `Initialize`, `EnsureDocumentViewer`, `CreateAboutBlankDocumentViewer`, `nsContentDLF::CreateBlankDocument`, `nsHTMLDocument::ResetToURI`, `Document::ResetToURI`, and finally `Document::SetPrincipals`.

From what I see, the `firstPartyDomain` is usually set up in `nsDocShellLoadState::SetupInheritingPrincipal()` and needs an URI, which we don't have during browser construction. But at the end of it, the Document principal is set, so this is where we would have to create a new Principal.
(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #188)
> I guess you mean that we don't get it as part of https://searchfox.org/mozilla-central/rev/a9824b3ffc2efea7a317f114bc3192ccdffa0ef7/dom/ipc/WindowGlobalTypes.ipdlh#20,26 ?

Right.

`CreateBrowser` sets `aWindowInit.principal()` to `nsOpenWindowInfo::PrincipalToInheritForAboutBlank()`, which is sent to the child and thereby cloned. For this principal, the `firstPartyDomain` is empty and `const`.

From `RecvConstructBrowser`, we call `BrowserChild::Init`, `nsWebBrowser::Create`, `nsDocShell::InitWindow`, `Initialize`, `EnsureDocumentViewer`, `CreateAboutBlankDocumentViewer`, `nsContentDLF::CreateBlankDocument`, `nsHTMLDocument::ResetToURI`, `Document::ResetToURI`, and finally `Document::SetPrincipals`.

From what I see, the `firstPartyDomain` is usually set up in `nsDocShellLoadState::SetupInheritingPrincipal()` and needs an URI, which we don't have during browser construction. But at the end of it, the Document principal is set, so this is where we would have to create a new Principal.
(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #188)
> I guess you mean that we don't get it as part of https://searchfox.org/mozilla-central/rev/a9824b3ffc2efea7a317f114bc3192ccdffa0ef7/dom/ipc/WindowGlobalTypes.ipdlh#20,26 ?

Right.

`CreateBrowser` sets `aWindowInit.principal()` to `nsOpenWindowInfo::PrincipalToInheritForAboutBlank()`, which is sent to the child and thereby cloned. For this principal, the `firstPartyDomain` is empty and `const`.

From `RecvConstructBrowser`, we call `BrowserChild::Init`, `nsWebBrowser::Create`, `nsDocShell::InitWindow`, `Initialize`, `EnsureDocumentViewer`, `CreateAboutBlankDocumentViewer`, `nsContentDLF::CreateBlankDocument`, `nsHTMLDocument::ResetToURI`, `Document::ResetToURI`, and finally `Document::SetPrincipals`.

From what I see, the `firstPartyDomain` is usually set up in `nsDocShellLoadState::SetupInheritingPrincipal()` and needs an URI, which we don't have during browser construction. But at the end of browser creation, the Document principal is set, so this is where we would have to create a new principal.

Back to Bug 543435 Comment 190