Bug 1548034 - Remove Clear-Site-Data 'executionContexts' feature, r=annevk,smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 08 May 2019 13:12:59 +0000
changeset 531876 071e3e7156387b323d52ae3231a8bbffd408d87a
parent 531875 72f1173462423fe2959e08bc1788e902a3a8d7c8
child 531877 51988a2d186aa08ab16d0ae5aa0d71bee1a7ffad
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersannevk, smaug
bugs1548034
milestone68.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 1548034 - Remove Clear-Site-Data 'executionContexts' feature, r=annevk,smaug Differential Revision: https://phabricator.services.mozilla.com/D29863
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowInner.h
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/PContent.ipdl
testing/web-platform/meta/clear-site-data/executionContexts.sub.html.ini
toolkit/components/clearsitedata/ClearSiteData.cpp
toolkit/components/clearsitedata/ClearSiteData.h
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -883,20 +883,16 @@ nsGlobalWindowInner::nsGlobalWindowInner
   mObserver = new nsGlobalWindowObserver(this);
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os) {
     // Watch for online/offline status changes so we can fire events. Use
     // a strong reference.
     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");
 
   // Watch for storage notifications so we can fire storage events.
   RefPtr<StorageNotifierService> sns = StorageNotifierService::GetOrCreate();
   if (sns) {
     sns->Register(mObserver);
@@ -1195,21 +1191,16 @@ void nsGlobalWindowInner::FreeInnerObjec
 
   DisconnectEventTargetObjects();
 
   if (mObserver) {
     nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     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();
     if (sns) {
       sns->Unregister(mObserver);
     }
 
     Preferences::RemoveObserver(mObserver, "intl.accept_languages");
@@ -4809,23 +4800,16 @@ nsresult nsGlobalWindowInner::Observe(ns
   if (!nsCRT::strcmp(aTopic, MEMORY_PRESSURE_OBSERVER_TOPIC)) {
     if (mPerformance) {
       mPerformance->MemoryPressure();
       mReportRecords.Clear();
     }
     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;
 
     // Instantiate the application object now. It observes update belonging to
     // this window's document and correctly updates the applicationCache object
     // state.
     nsCOMPtr<nsIObserver> observer = GetApplicationCache();
     if (observer) observer->Observe(aSubject, aTopic, aData);
@@ -6933,52 +6917,16 @@ void nsPIDOMWindowInner::MaybeCreateDoc(
     // Note that |document| here is the same thing as our mDoc, but we
     // don't have to explicitly set the member variable because the docshell
     // has already called SetNewDocument().
     nsCOMPtr<Document> document = docShell->GetDocument();
     Unused << document;
   }
 }
 
-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) {
     return doc->GetDocGroup();
   }
   return nullptr;
 }
 
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -239,19 +239,17 @@ class nsGlobalWindowInner final : public
 
   // nsWrapperCache
   virtual JSObject* WrapObject(JSContext* cx,
                                JS::Handle<JSObject*> aGivenProto) override {
     return GetWrapper();
   }
 
   // nsIGlobalObject
-  JSObject* GetGlobalJSObject() final {
-    return GetWrapper();
-  }
+  JSObject* GetGlobalJSObject() final { return GetWrapper(); }
   JSObject* GetGlobalJSObjectPreserveColor() const final {
     return GetWrapperPreserveColor();
   }
   // The HasJSGlobal on nsIGlobalObject ends up having to do a virtual
   // call to GetGlobalJSObjectPreserveColor(), because when it's
   // making the call it doesn't know it's doing it on an
   // nsGlobalWindowInner.  Add a version here that can be entirely
   // non-virtual.
@@ -911,18 +909,16 @@ class nsGlobalWindowInner final : public
   void GetInterface(JSContext* aCx, JS::Handle<JS::Value> aIID,
                     JS::MutableHandle<JS::Value> aRetval,
                     mozilla::ErrorResult& aError);
 
   already_AddRefed<nsWindowRoot> GetWindowRoot(mozilla::ErrorResult& aError);
 
   bool ShouldReportForServiceWorkerScope(const nsAString& aScope);
 
-  void PropagateClearSiteDataReload(const nsACString& aOrigin);
-
   already_AddRefed<mozilla::dom::InstallTriggerImpl> GetInstallTrigger();
 
   nsIDOMWindowUtils* GetWindowUtils(mozilla::ErrorResult& aRv);
 
   bool HasOpenerForInitialContentBrowser();
 
   void UpdateTopInnerWindow();
 
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2526,27 +2526,16 @@ mozilla::ipc::IPCResult ContentChild::Re
 }
 
 mozilla::ipc::IPCResult ContentChild::RecvUpdateRequestedLocales(
     nsTArray<nsCString>&& aRequestedLocales) {
   LocaleService::GetInstance()->AssignRequestedLocales(aRequestedLocales);
   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 =
       services::GetPermissionManager();
   nsPermissionManager* permissionManager =
       static_cast<nsPermissionManager*>(permissionManagerIface.get());
   MOZ_ASSERT(permissionManager,
              "We have no permissionManager in the Content process !");
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -383,19 +383,16 @@ class ContentChild final : public PConte
       InfallibleTArray<SystemFontListEntry>&& aFontList);
   mozilla::ipc::IPCResult RecvRebuildFontList();
 
   mozilla::ipc::IPCResult RecvUpdateAppLocales(
       nsTArray<nsCString>&& aAppLocales);
   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();
 
   mozilla::ipc::IPCResult RecvFlushMemory(const nsString& reason);
 
   mozilla::ipc::IPCResult RecvActivateA11y(const uint32_t& aMainChromeTid,
                                            const uint32_t& aMsaaID);
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -609,17 +609,16 @@ static const char* sObserverTopics[] = {
 #ifdef ACCESSIBILITY
     "a11y-init-or-shutdown",
 #endif
     "cacheservice:empty-cache",
     "intl:app-locales-changed",
     "intl:requested-locales-changed",
     "cookie-changed",
     "private-cookie-changed",
-    "clear-site-data-reload-needed",
     NS_NETWORK_LINK_TYPE_TOPIC,
 };
 
 #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
 bool ContentParent::sEarlySandboxInit = false;
 #endif
 
 // PreallocateProcess is called by the PreallocatedProcessManager.
@@ -3118,19 +3117,16 @@ ContentParent::Observe(nsISupports* aSub
     nsCOMPtr<nsICookie> xpcCookie = do_QueryInterface(aSubject);
     NS_ASSERTION(xpcCookie, "couldn't get cookie");
     if (!nsCRT::strcmp(aData, u"deleted")) {
       cs->RemoveCookie(xpcCookie);
     } else if ((!nsCRT::strcmp(aData, u"added")) ||
                (!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();
   }
 
   return NS_OK;
 }
 
 void ContentParent::UpdateNetworkLinkType() {
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -508,18 +508,16 @@ child:
      * for src:local() names that were previously not known, so content
      * may need to be reflowed.
      */
     async FontListChanged();
 
     async UpdateAppLocales(nsCString[] appLocales);
     async UpdateRequestedLocales(nsCString[] requestedLocales);
 
-    async ClearSiteDataReloadNeeded(nsString origin);
-
     async RegisterStringBundles(StringBundleDescriptor[] stringBundles);
 
     async UpdateSharedData(FileDescriptor mapFile, uint32_t aSize,
                            IPCBlob[] blobs,
                            nsCString[] changedKeys);
 
     // nsIPermissionManager messages
     async AddPermission(Permission permission);
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/clear-site-data/executionContexts.sub.html.ini
@@ -0,0 +1,7 @@
+[executionContexts.sub.html]
+  expected: TIMEOUT
+  [executionContexts triggers the reload of contexts]
+    expected: TIMEOUT
+
+  [* triggers the reload of contexts]
+    expected: NOTRUN
--- a/toolkit/components/clearsitedata/ClearSiteData.cpp
+++ b/toolkit/components/clearsitedata/ClearSiteData.cpp
@@ -46,62 +46,38 @@ class ClearSiteData::PendingCleanupHolde
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     mPendingOp = true;
     return NS_OK;
   }
 
-  // This method must be called after any Start() call.
-  void BrowsingContextsReloadNeeded(const nsACString& aOrigin) {
-    mContextsReloadOrigin = aOrigin;
-    MaybeBrowsingContextsReload();
-  }
-
   // nsIClearDataCallback interface
 
   NS_IMETHOD
   OnDataDeleted(uint32_t aFailedFlags) override {
     MOZ_ASSERT(mPendingOp);
     mPendingOp = false;
 
     mChannel->Resume();
     mChannel = nullptr;
 
-    MaybeBrowsingContextsReload();
     return NS_OK;
   }
 
  private:
   ~PendingCleanupHolder() {
     if (mPendingOp) {
       mChannel->Resume();
     }
   }
 
-  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)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIClearDataCallback)
   NS_INTERFACE_MAP_ENTRY(nsIClearDataCallback)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(ClearSiteData::PendingCleanupHolder)
@@ -238,30 +214,16 @@ void ClearSiteData::ClearDataFromChannel
     }
 
     rv = csd->DeleteDataFromPrincipal(principal, false /* user request */,
                                       cleanFlags, holder);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       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,
                                     nsIURI* aURI) const {
   MOZ_ASSERT(aChannel);
 
   nsAutoCString headerValue;
   nsresult rv = aChannel->GetResponseHeader(
@@ -287,23 +249,18 @@ uint32_t ClearSiteData::ParseHeader(nsIH
       continue;
     }
 
     if (value.EqualsLiteral("\"storage\"")) {
       flags |= eStorage;
       continue;
     }
 
-    if (value.EqualsLiteral("\"executionContexts\"")) {
-      flags |= eExecutionContexts;
-      continue;
-    }
-
     if (value.EqualsLiteral("\"*\"")) {
-      flags = eCache | eCookies | eStorage | eExecutionContexts;
+      flags = eCache | eCookies | eStorage;
       break;
     }
 
     LogErrorToConsole(aChannel, aURI, value);
   }
 
   return flags;
 }
@@ -374,35 +331,20 @@ void ClearSiteData::TypeToString(Type aT
     case eCookies:
       aStr.AssignLiteral("cookies");
       break;
 
     case eStorage:
       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)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(ClearSiteData)
 NS_IMPL_RELEASE(ClearSiteData)
--- a/toolkit/components/clearsitedata/ClearSiteData.h
+++ b/toolkit/components/clearsitedata/ClearSiteData.h
@@ -37,35 +37,29 @@ class ClearSiteData final : public nsIOb
 
   // From the Clear-Site-Data header, it returns a bitmap with Type values.
   uint32_t ParseHeader(nsIHttpChannel* aChannel, nsIURI* aURI) const;
 
   enum Type {
     eCache = 0x01,
     eCookies = 0x02,
     eStorage = 0x04,
-    eExecutionContexts = 0x08,
   };
 
   // This method writes a console message when a cleanup operation is going to
   // be executed.
   void LogOpToConsole(nsIHttpChannel* aChannel, nsIURI* aURI, Type aType) const;
 
   // Logging of an unknown type value.
   void LogErrorToConsole(nsIHttpChannel* aChannel, nsIURI* aURI,
                          const nsACString& aUnknownType) const;
 
   void LogToConsoleInternal(nsIHttpChannel* aChannel, nsIURI* aURI,
                             const char* aMsg,
                             const nsTArray<nsString>& aParams) const;
 
   // 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
 
 #endif  // mozilla_clearsitedata_h