summaryrefslogtreecommitdiffstats
path: root/dom/base/nsIDocument.h
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-02-09 08:53:46 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-02-09 08:53:46 +0100
commit8cecf8d5208f3945b35f879bba3015bb1a11bec6 (patch)
tree0926f5c21f9d10cf929e4c35e7d7e8e8c084dbf5 /dom/base/nsIDocument.h
parent8cd777888a40e987ad536ab68421068f5c06d83b (diff)
parent92104eb6828ba026550e1f4a3c6890c5b8254d36 (diff)
downloadUXP-8cecf8d5208f3945b35f879bba3015bb1a11bec6.tar
UXP-8cecf8d5208f3945b35f879bba3015bb1a11bec6.tar.gz
UXP-8cecf8d5208f3945b35f879bba3015bb1a11bec6.tar.lz
UXP-8cecf8d5208f3945b35f879bba3015bb1a11bec6.tar.xz
UXP-8cecf8d5208f3945b35f879bba3015bb1a11bec6.zip
Merge branch 'ported-upstream'
Diffstat (limited to 'dom/base/nsIDocument.h')
-rw-r--r--dom/base/nsIDocument.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h
index 5b10c9914..8f35e9ba5 100644
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -1923,6 +1923,34 @@ public:
return mMarkedCCGeneration;
}
+ /**
+ * Returns whether this document is cookie-averse. See
+ * https://html.spec.whatwg.org/multipage/dom.html#cookie-averse-document-object
+ */
+ bool IsCookieAverse() const
+ {
+ // If we are a document that "has no browsing context."
+ if (!GetInnerWindow()) {
+ return true;
+ }
+
+ // If we are a document "whose URL's scheme is not a network scheme."
+ // NB: Explicitly allow file: URIs to store cookies.
+ nsCOMPtr<nsIURI> codebaseURI;
+ NodePrincipal()->GetURI(getter_AddRefs(codebaseURI));
+
+ if (!codebaseURI) {
+ return true;
+ }
+
+ nsAutoCString scheme;
+ codebaseURI->GetScheme(scheme);
+ return !scheme.EqualsLiteral("http") &&
+ !scheme.EqualsLiteral("https") &&
+ !scheme.EqualsLiteral("ftp") &&
+ !scheme.EqualsLiteral("file");
+ }
+
bool IsLoadedAsData()
{
return mLoadedAsData;