Bug 1266747 P2 Track last focus time on ServiceWorkerClient. r=smaug
☠☠ backed out by cd6fd1b64337 ☠ ☠
authorBen Kelly <ben@wanderview.com>
Tue, 28 Feb 2017 10:48:51 -0500
changeset 490601 e54c8d21e4c1fa34090ffb2190797be37da6f8fc
parent 490600 d19ad1c1c214c7f2f8b2fb292e7b4c8d4328a5f8
child 490602 274999e28c0773393d07754c765fb627d79ecc37
push id47156
push userbmo:lockhart@cs.dal.ca
push dateTue, 28 Feb 2017 22:47:20 +0000
reviewerssmaug
bugs1266747
milestone54.0a1
Bug 1266747 P2 Track last focus time on ServiceWorkerClient. r=smaug
dom/workers/ServiceWorkerClient.cpp
dom/workers/ServiceWorkerClient.h
--- a/dom/workers/ServiceWorkerClient.cpp
+++ b/dom/workers/ServiceWorkerClient.cpp
@@ -54,22 +54,27 @@ ServiceWorkerClientInfo::ServiceWorkerCl
   nsCOMPtr<nsIURI> originalURI = aDoc->GetOriginalURI();
   if (originalURI) {
     nsAutoCString spec;
     originalURI->GetSpec(spec);
     CopyUTF8toUTF16(spec, mUrl);
   }
   mVisibilityState = aDoc->VisibilityState();
 
+  mLastFocusTime = aDoc->LastFocusTime();
+
   ErrorResult result;
   mFocused = aDoc->HasFocus(result);
   if (result.Failed()) {
     NS_WARNING("Failed to get focus information.");
   }
 
+  MOZ_ASSERT_IF(mLastFocusTime.IsNull(), !mFocused);
+  MOZ_ASSERT_IF(mFocused, !mLastFocusTime.IsNull());
+
   RefPtr<nsGlobalWindow> outerWindow = nsGlobalWindow::Cast(aDoc->GetWindow());
   if (!outerWindow) {
     MOZ_ASSERT(mFrameType == FrameType::None);
   } else if (!outerWindow->IsTopLevelWindow()) {
     mFrameType = FrameType::Nested;
   } else if (outerWindow->HadOriginalOpener()) {
     mFrameType = FrameType::Auxiliary;
   } else {
--- a/dom/workers/ServiceWorkerClient.h
+++ b/dom/workers/ServiceWorkerClient.h
@@ -41,18 +41,19 @@ public:
 private:
   const mozilla::dom::ClientType mType;
   nsString mClientId;
   uint64_t mWindowId;
   nsString mUrl;
 
   // Window Clients
   VisibilityState mVisibilityState;
+  FrameType mFrameType;
+  TimeStamp mLastFocusTime;
   bool mFocused;
-  FrameType mFrameType;
 };
 
 class ServiceWorkerClient : public nsISupports,
                             public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ServiceWorkerClient)