Bug 1498369 - Ensure the promise returned from Document.hasStorageAccess() will propagate user activation r=baku

Differential Revision: https://phabricator.services.mozilla.com/D9011

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2018-10-17 17:51:45 +00:00
Родитель fbfee407a0
Коммит 9d62cd6360
2 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -13653,7 +13653,8 @@ nsIDocument::HasStorageAccess(mozilla::ErrorResult& aRv)
return nullptr;
}
RefPtr<Promise> promise = Promise::Create(global, aRv);
RefPtr<Promise> promise = Promise::Create(global, aRv,
Promise::ePropagateUserInteraction);
if (aRv.Failed()) {
return nullptr;
}

Просмотреть файл

@ -10,6 +10,20 @@ AntiTracking.runTest("Storage Access API returns promises that maintain user act
});
ok(!threw, "requestStorageAccess should not throw");
ok(!rejected, "requestStorageAccess should be available");
let dwu = SpecialPowers.getDOMWindowUtils(window);
let helper = dwu.setHandlingUserInput(true);
let promise;
try {
promise = document.hasStorageAccess();
} finally {
helper.destruct();
}
await promise.then(_ => {
ok(dwu.isHandlingUserInput,
"Promise handler must run as if we're handling user input");
});
},
null, // non-blocking callback