Bug 1476612 - AntiTracking should use nsIDocument::Get/SetUserHasInteracted instead of UserGestureActivation, r=cpearce
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 19 Jul 2018 13:14:27 +0200
changeset 427269 694089774911b78e06ab2f784278400a76155582
parent 427268 17dd12ac3d4e9c1d5a13da773cc88a9c143955ec
child 427270 8a66951dd403316aba45f36c3502df83cc5ed5f1
push id105429
push useramarchesini@mozilla.com
push dateThu, 19 Jul 2018 11:14:50 +0000
treeherdermozilla-inbound@694089774911 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1476612
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1476612 - AntiTracking should use nsIDocument::Get/SetUserHasInteracted instead of UserGestureActivation, r=cpearce
dom/base/nsDocument.cpp
dom/html/nsHTMLDocument.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -12425,30 +12425,33 @@ nsIDocument::ReportHasScrollLinkedEffect
 }
 
 void
 nsIDocument::SetUserHasInteracted(bool aUserHasInteracted)
 {
   MOZ_LOG(gUserInteractionPRLog, LogLevel::Debug,
           ("Document %p has been interacted by user.", this));
   mUserHasInteracted = aUserHasInteracted;
+
+  if (aUserHasInteracted) {
+    MaybeAllowStorageForOpener();
+  }
 }
 
 void
 nsIDocument::NotifyUserGestureActivation()
 {
   // Activate this document and all documents up to the top level
   // content document.
   nsIDocument* doc = this;
   while (doc && !doc->mUserGestureActivated) {
     MOZ_LOG(gUserInteractionPRLog,
             LogLevel::Debug,
             ("Document %p has been activated by user.", this));
     doc->mUserGestureActivated = true;
-    doc->MaybeAllowStorageForOpener();
     doc = doc->GetSameTypeParentDocument();
   }
 }
 
 void
 nsIDocument::MaybeAllowStorageForOpener()
 {
   if (!StaticPrefs::privacy_restrict3rdpartystorage_enabled()) {
@@ -12465,17 +12468,17 @@ nsIDocument::MaybeAllowStorageForOpener(
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> outer = inner->GetOuterWindow();
   if (NS_WARN_IF(!outer)) {
     return;
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> outerOpener = outer->GetOpener();
-  if (NS_WARN_IF(!outerOpener)) {
+  if (!outerOpener) {
     return;
   }
 
   nsPIDOMWindowInner* openerInner = outerOpener->GetCurrentInnerWindow();
   if (NS_WARN_IF(!openerInner)) {
     return;
   }
 
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -3416,10 +3416,12 @@ nsHTMLDocument::GetFormsAndFormControls(
 
   NS_ADDREF(*aFormList = holder->mFormList);
   NS_ADDREF(*aFormControlList = holder->mFormControlList);
 }
 
 void
 nsHTMLDocument::UserInteractionForTesting()
 {
-  NotifyUserGestureActivation();
+  if (!UserHasInteracted()) {
+    SetUserHasInteracted(true);
+  }
 }