Bug 1548034 - Remove Clear-Site-Data 'executionContexts' feature, r=annevk,smaug

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2019-05-08 13:12:59 +00:00
Родитель 72aecadbca
Коммит 7ccddfedc4
9 изменённых файлов: 9 добавлений и 142 удалений

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

@ -888,10 +888,6 @@ nsGlobalWindowInner::nsGlobalWindowInner(nsGlobalWindowOuter* aOuterWindow)
os->AddObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC, false);
os->AddObserver(mObserver, MEMORY_PRESSURE_OBSERVER_TOPIC, false);
if (aOuterWindow->IsTopLevelWindow()) {
os->AddObserver(mObserver, "clear-site-data-reload-needed", false);
}
}
Preferences::AddStrongObserver(mObserver, "intl.accept_languages");
@ -1200,11 +1196,6 @@ void nsGlobalWindowInner::FreeInnerObjects() {
if (os) {
os->RemoveObserver(mObserver, NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
os->RemoveObserver(mObserver, MEMORY_PRESSURE_OBSERVER_TOPIC);
if (GetOuterWindowInternal() &&
GetOuterWindowInternal()->IsTopLevelWindow()) {
os->RemoveObserver(mObserver, "clear-site-data-reload-needed");
}
}
RefPtr<StorageNotifierService> sns = StorageNotifierService::GetOrCreate();
@ -4814,13 +4805,6 @@ nsresult nsGlobalWindowInner::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
}
if (!nsCRT::strcmp(aTopic, "clear-site-data-reload-needed")) {
// The reload is propagated from the top-level window only.
NS_ConvertUTF16toUTF8 otherOrigin(aData);
PropagateClearSiteDataReload(otherOrigin);
return NS_OK;
}
if (!nsCRT::strcmp(aTopic, "offline-cache-update-added")) {
if (mApplicationCache) return NS_OK;
@ -6938,42 +6922,6 @@ void nsPIDOMWindowInner::MaybeCreateDoc() {
}
}
void nsGlobalWindowInner::PropagateClearSiteDataReload(
const nsACString& aOrigin) {
if (!IsCurrentInnerWindow()) {
return;
}
nsIPrincipal* principal = GetPrincipal();
if (!principal) {
return;
}
nsAutoCString origin;
nsresult rv = principal->GetOrigin(origin);
NS_ENSURE_SUCCESS_VOID(rv);
// If the URL of this window matches, let's refresh this window only.
// We don't need to traverse the DOM tree.
if (origin.Equals(aOrigin)) {
nsCOMPtr<nsIDocShell> docShell = GetDocShell();
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
if (NS_WARN_IF(!webNav)) {
return;
}
// We don't need any special reload flags, because this notification is
// dispatched by Clear-Site-Data header, which should have already cleaned
// up all the needed data.
rv = webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
NS_ENSURE_SUCCESS_VOID(rv);
return;
}
CallOnChildren(&nsGlobalWindowInner::PropagateClearSiteDataReload, aOrigin);
}
mozilla::dom::DocGroup* nsPIDOMWindowInner::GetDocGroup() const {
Document* doc = GetExtantDoc();
if (doc) {

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

@ -244,9 +244,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
}
// nsIGlobalObject
JSObject* GetGlobalJSObject() final {
return GetWrapper();
}
JSObject* GetGlobalJSObject() final { return GetWrapper(); }
JSObject* GetGlobalJSObjectPreserveColor() const final {
return GetWrapperPreserveColor();
}
@ -916,8 +914,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
bool ShouldReportForServiceWorkerScope(const nsAString& aScope);
void PropagateClearSiteDataReload(const nsACString& aOrigin);
already_AddRefed<mozilla::dom::InstallTriggerImpl> GetInstallTrigger();
nsIDOMWindowUtils* GetWindowUtils(mozilla::ErrorResult& aRv);

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

@ -2531,17 +2531,6 @@ mozilla::ipc::IPCResult ContentChild::RecvUpdateRequestedLocales(
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvClearSiteDataReloadNeeded(
const nsString& aOrigin) {
// Rebroadcast "clear-site-data-reload-needed".
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(nullptr, "clear-site-data-reload-needed",
aOrigin.get());
}
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvAddPermission(
const IPC::Permission& permission) {
nsCOMPtr<nsIPermissionManager> permissionManagerIface =

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

@ -388,9 +388,6 @@ class ContentChild final : public PContentChild,
mozilla::ipc::IPCResult RecvUpdateRequestedLocales(
nsTArray<nsCString>&& aRequestedLocales);
mozilla::ipc::IPCResult RecvClearSiteDataReloadNeeded(
const nsString& aOrigin);
mozilla::ipc::IPCResult RecvAddPermission(const IPC::Permission& permission);
mozilla::ipc::IPCResult RecvRemoveAllPermissions();

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

@ -614,7 +614,6 @@ static const char* sObserverTopics[] = {
"intl:requested-locales-changed",
"cookie-changed",
"private-cookie-changed",
"clear-site-data-reload-needed",
NS_NETWORK_LINK_TYPE_TOPIC,
};
@ -3123,9 +3122,6 @@ ContentParent::Observe(nsISupports* aSubject, const char* aTopic,
(!nsCRT::strcmp(aData, u"changed"))) {
cs->AddCookie(xpcCookie);
}
} else if (!strcmp(aTopic, "clear-site-data-reload-needed")) {
// Rebroadcast "clear-site-data-reload-needed".
Unused << SendClearSiteDataReloadNeeded(nsString(aData));
} else if (!strcmp(aTopic, NS_NETWORK_LINK_TYPE_TOPIC)) {
UpdateNetworkLinkType();
}

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

@ -513,8 +513,6 @@ child:
async UpdateAppLocales(nsCString[] appLocales);
async UpdateRequestedLocales(nsCString[] requestedLocales);
async ClearSiteDataReloadNeeded(nsString origin);
async RegisterStringBundles(StringBundleDescriptor[] stringBundles);
async UpdateSharedData(FileDescriptor mapFile, uint32_t aSize,

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

@ -0,0 +1,7 @@
[executionContexts.sub.html]
expected: TIMEOUT
[executionContexts triggers the reload of contexts]
expected: TIMEOUT
[* triggers the reload of contexts]
expected: NOTRUN

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

@ -51,12 +51,6 @@ class ClearSiteData::PendingCleanupHolder final : public nsIClearDataCallback {
return NS_OK;
}
// This method must be called after any Start() call.
void BrowsingContextsReloadNeeded(const nsACString& aOrigin) {
mContextsReloadOrigin = aOrigin;
MaybeBrowsingContextsReload();
}
// nsIClearDataCallback interface
NS_IMETHOD
@ -67,7 +61,6 @@ class ClearSiteData::PendingCleanupHolder final : public nsIClearDataCallback {
mChannel->Resume();
mChannel = nullptr;
MaybeBrowsingContextsReload();
return NS_OK;
}
@ -78,25 +71,8 @@ class ClearSiteData::PendingCleanupHolder final : public nsIClearDataCallback {
}
}
void MaybeBrowsingContextsReload() {
if (mPendingOp || mContextsReloadOrigin.IsEmpty()) {
return;
}
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (NS_WARN_IF(!obs)) {
return;
}
NS_ConvertUTF8toUTF16 origin(mContextsReloadOrigin);
nsresult rv = obs->NotifyObservers(nullptr, "clear-site-data-reload-needed",
origin.get());
Unused << NS_WARN_IF(NS_FAILED(rv));
}
nsCOMPtr<nsIHttpChannel> mChannel;
bool mPendingOp;
nsCString mContextsReloadOrigin;
};
NS_INTERFACE_MAP_BEGIN(ClearSiteData::PendingCleanupHolder)
@ -243,20 +219,6 @@ void ClearSiteData::ClearDataFromChannel(nsIHttpChannel* aChannel) {
return;
}
}
// We consider eExecutionContexts only for 2xx response status.
if (flags & eExecutionContexts) {
uint32_t status;
rv = aChannel->GetResponseStatus(&status);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
if (status >= 200 && status < 300) {
LogOpToConsole(aChannel, uri, eExecutionContexts);
BrowsingContextsReload(holder, principal);
}
}
}
uint32_t ClearSiteData::ParseHeader(nsIHttpChannel* aChannel,
@ -292,13 +254,8 @@ uint32_t ClearSiteData::ParseHeader(nsIHttpChannel* aChannel,
continue;
}
if (value.EqualsLiteral("\"executionContexts\"")) {
flags |= eExecutionContexts;
continue;
}
if (value.EqualsLiteral("\"*\"")) {
flags = eCache | eCookies | eStorage | eExecutionContexts;
flags = eCache | eCookies | eStorage;
break;
}
@ -379,26 +336,11 @@ void ClearSiteData::TypeToString(Type aType, nsAString& aStr) const {
aStr.AssignLiteral("storage");
break;
case eExecutionContexts:
aStr.AssignLiteral("executionContexts");
break;
default:
MOZ_CRASH("Unknown type.");
}
}
void ClearSiteData::BrowsingContextsReload(PendingCleanupHolder* aHolder,
nsIPrincipal* aPrincipal) const {
nsAutoCString origin;
nsresult rv = aPrincipal->GetOrigin(origin);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
aHolder->BrowsingContextsReloadNeeded(origin);
}
NS_INTERFACE_MAP_BEGIN(ClearSiteData)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsIObserver)

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

@ -42,7 +42,6 @@ class ClearSiteData final : public nsIObserver {
eCache = 0x01,
eCookies = 0x02,
eStorage = 0x04,
eExecutionContexts = 0x08,
};
// This method writes a console message when a cleanup operation is going to
@ -59,11 +58,6 @@ class ClearSiteData final : public nsIObserver {
// This method converts a Type to the corrisponding string format.
void TypeToString(Type aType, nsAString& aStr) const;
// When called, after the cleanup, PendingCleanupHolder will reload all the
// browsing contexts.
void BrowsingContextsReload(PendingCleanupHolder* aHolder,
nsIPrincipal* aPrincipal) const;
};
} // namespace mozilla