|
107 | 107 | #include "nsICaptivePortalService.h" |
108 | 108 | #include "nsIChannel.h" |
109 | 109 | #include "nsIChannelEventSink.h" |
| 110 | +#include "nsIClassifiedChannel.h" |
110 | 111 | #include "nsIClassOfService.h" |
111 | 112 | #include "nsIConsoleReportCollector.h" |
112 | 113 | #include "nsIContent.h" |
@@ -4133,6 +4134,8 @@ nsresult nsDocShell::ReloadDocument(nsDocShell* aDocShell, Document* aDocument, |
4133 | 4134 | uint32_t triggeringSandboxFlags = aDocument->GetSandboxFlags(); |
4134 | 4135 | uint64_t triggeringWindowId = aDocument->InnerWindowID(); |
4135 | 4136 | bool triggeringStorageAccess = aDocument->UsingStorageAccess(); |
| 4137 | + net::ClassificationFlags triggeringClassificationFlags = |
| 4138 | + aDocument->GetScriptTrackingFlags(); |
4136 | 4139 |
|
4137 | 4140 | nsAutoString contentTypeHint; |
4138 | 4141 | aDocument->GetContentType(contentTypeHint); |
@@ -4181,6 +4184,7 @@ nsresult nsDocShell::ReloadDocument(nsDocShell* aDocShell, Document* aDocument, |
4181 | 4184 | loadState->SetTriggeringSandboxFlags(triggeringSandboxFlags); |
4182 | 4185 | loadState->SetTriggeringWindowId(triggeringWindowId); |
4183 | 4186 | loadState->SetTriggeringStorageAccess(triggeringStorageAccess); |
| 4187 | + loadState->SetTriggeringClassificationFlags(triggeringClassificationFlags); |
4184 | 4188 | loadState->SetPrincipalToInherit(triggeringPrincipal); |
4185 | 4189 | loadState->SetCsp(csp); |
4186 | 4190 | loadState->SetInternalLoadFlags(flags); |
@@ -5163,6 +5167,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, |
5163 | 5167 | loadState->SetTriggeringSandboxFlags(doc->GetSandboxFlags()); |
5164 | 5168 | loadState->SetTriggeringWindowId(doc->InnerWindowID()); |
5165 | 5169 | loadState->SetTriggeringStorageAccess(doc->UsingStorageAccess()); |
| 5170 | + loadState->SetTriggeringClassificationFlags(doc->GetScriptTrackingFlags()); |
5166 | 5171 |
|
5167 | 5172 | loadState->SetPrincipalIsExplicit(true); |
5168 | 5173 |
|
@@ -6770,6 +6775,19 @@ nsresult nsDocShell::CreateAboutBlankDocumentViewer( |
6770 | 6775 | // after being set here. |
6771 | 6776 | blankDoc->SetSandboxFlags(sandboxFlags); |
6772 | 6777 |
|
| 6778 | + // We inherit the classification flags from the parent document if the |
| 6779 | + // principal matches. |
| 6780 | + nsCOMPtr<nsIDocShellTreeItem> parentItem; |
| 6781 | + GetInProcessSameTypeParent(getter_AddRefs(parentItem)); |
| 6782 | + if (parentItem) { |
| 6783 | + RefPtr<Document> parentDocument = parentItem->GetDocument(); |
| 6784 | + if (parentDocument && principal && |
| 6785 | + principal->Equals(parentDocument->NodePrincipal())) { |
| 6786 | + blankDoc->SetClassificationFlags( |
| 6787 | + parentDocument->GetClassificationFlags()); |
| 6788 | + } |
| 6789 | + } |
| 6790 | + |
6773 | 6791 | // create a content viewer for us and the new document |
6774 | 6792 | docFactory->CreateInstanceForDocument( |
6775 | 6793 | NS_ISUPPORTS_CAST(nsIDocShell*, this), blankDoc, "view", |
@@ -7971,6 +7989,19 @@ nsresult nsDocShell::CreateDocumentViewer(const nsACString& aContentType, |
7971 | 7989 | nullptr, nullptr, nullptr, true, false); |
7972 | 7990 | } |
7973 | 7991 |
|
| 7992 | + // We inherit the classification flags from the parent document if the |
| 7993 | + // document is about:blank and the principal matches. |
| 7994 | + nsCOMPtr<nsIDocShellTreeItem> parentItem; |
| 7995 | + GetInProcessSameTypeParent(getter_AddRefs(parentItem)); |
| 7996 | + if (parentItem && finalURI && NS_IsAboutBlank(finalURI)) { |
| 7997 | + RefPtr<Document> doc = viewer->GetDocument(); |
| 7998 | + RefPtr<Document> parentDocument = parentItem->GetDocument(); |
| 7999 | + if (parentDocument && doc && |
| 8000 | + doc->NodePrincipal()->Equals(parentDocument->NodePrincipal())) { |
| 8001 | + doc->SetClassificationFlags(parentDocument->GetClassificationFlags()); |
| 8002 | + } |
| 8003 | + } |
| 8004 | + |
7974 | 8005 | // let's try resetting the load group if we need to... |
7975 | 8006 | nsCOMPtr<nsILoadGroup> currentLoadGroup; |
7976 | 8007 | NS_ENSURE_SUCCESS( |
@@ -8573,6 +8604,8 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) { |
8573 | 8604 | loadState->SetTriggeringWindowId(aLoadState->TriggeringWindowId()); |
8574 | 8605 | loadState->SetTriggeringStorageAccess( |
8575 | 8606 | aLoadState->TriggeringStorageAccess()); |
| 8607 | + loadState->SetTriggeringClassificationFlags( |
| 8608 | + aLoadState->TriggeringClassificationFlags()); |
8576 | 8609 | loadState->SetCsp(aLoadState->Csp()); |
8577 | 8610 | loadState->SetInheritPrincipal(aLoadState->HasInternalLoadFlags( |
8578 | 8611 | INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL)); |
@@ -10775,6 +10808,9 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState, |
10775 | 10808 | loadInfo->SetTriggeringWindowId(aLoadState->TriggeringWindowId()); |
10776 | 10809 | loadInfo->SetTriggeringStorageAccess(aLoadState->TriggeringStorageAccess()); |
10777 | 10810 | loadInfo->SetTriggeringSandboxFlags(aLoadState->TriggeringSandboxFlags()); |
| 10811 | + net::ClassificationFlags flags = aLoadState->TriggeringClassificationFlags(); |
| 10812 | + loadInfo->SetTriggeringFirstPartyClassificationFlags(flags.firstPartyFlags); |
| 10813 | + loadInfo->SetTriggeringThirdPartyClassificationFlags(flags.thirdPartyFlags); |
10778 | 10814 | loadInfo->SetIsMetaRefresh(aLoadState->IsMetaRefresh()); |
10779 | 10815 |
|
10780 | 10816 | uint32_t cacheKey = 0; |
@@ -13239,6 +13275,8 @@ nsresult nsDocShell::OnLinkClick( |
13239 | 13275 | ownerDoc->ConsumeTextDirectiveUserActivation() || |
13240 | 13276 | hasValidUserGestureActivation); |
13241 | 13277 | loadState->SetUserNavigationInvolvement(aUserInvolvement); |
| 13278 | + loadState->SetTriggeringClassificationFlags( |
| 13279 | + ownerDoc->GetScriptTrackingFlags()); |
13242 | 13280 |
|
13243 | 13281 | nsCOMPtr<nsIRunnable> ev = new OnLinkClickEvent( |
13244 | 13282 | this, aContent, loadState, noOpenerImplied, aTriggeringPrincipal); |
|
0 commit comments