Bug 1498466 - Ensure that hasStorageAccess() returns a sensible value with cookieBehavior set to accept all cookies r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 15 Oct 2018 10:36:48 +0000
changeset 499739 7b24c0c835bf54698cf49b5a21538bddd616642b
parent 499738 8efab497c2e6f710481d215e360650b220865269
child 499740 bb057b527690f626ad617828044c96cd113d4122
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1498466
milestone64.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 1498466 - Ensure that hasStorageAccess() returns a sensible value with cookieBehavior set to accept all cookies r=baku Differential Revision: https://phabricator.services.mozilla.com/D8584
dom/base/nsDocument.cpp
toolkit/components/antitracking/test/browser/storageAccessAPIHelpers.js
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -13801,16 +13801,17 @@ nsIDocument::RequestStorageAccess(mozill
                  outer->SetHasStorageAccess(true);
                  promise->MaybeResolveWithUndefined();
                },
                [outer, promise] (bool) {
                  outer->SetHasStorageAccess(false);
                  promise->MaybeRejectWithUndefined();
                });
     } else {
+      outer->SetHasStorageAccess(true);
       promise->MaybeResolveWithUndefined();
     }
   }
   return promise.forget();
 }
 
 void
 nsIDocument::RecordNavigationTiming(ReadyState aReadyState)
--- a/toolkit/components/antitracking/test/browser/storageAccessAPIHelpers.js
+++ b/toolkit/components/antitracking/test/browser/storageAccessAPIHelpers.js
@@ -57,17 +57,17 @@ async function callRequestStorageAccess(
       }
     } catch (e) {
       success = false;
     } finally {
       helper.destruct();
     }
     ok(success, "Should not have thrown");
 
-    await noStorageAccessInitially();
+    await hasStorageAccessInitially();
 
     await interactWithTracker();
 
     helper = dwu.setHandlingUserInput(true);
   }
 
   let p;
   let threw = false;
@@ -84,21 +84,21 @@ async function callRequestStorageAccess(
       await p.then(_ => callback(dwu));
     } else {
       await p;
     }
   } catch (e) {
     rejected = true;
   }
 
-  success = rejectTrackers && !threw && !rejected;
+  success = !threw && !rejected;
   let hasAccess = await document.hasStorageAccess();
   is(hasAccess, success,
      "Should " + (success ? "" : "not ") + "have storage access now");
-  if (success) {
+  if (success && rejectTrackers) {
     // Wait until the permission is visible in our process to avoid race
     // conditions.
     await waitUntilPermission("http://example.net/browser/toolkit/components/antitracking/test/browser/page.html",
                               "3rdPartyStorage^https://tracking.example.org");
   }
 
   return [threw, rejected];
 }