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 394212 e54c8d21e4c1fa34090ffb2190797be37da6f8fc
parent 394211 d19ad1c1c214c7f2f8b2fb292e7b4c8d4328a5f8
child 394213 274999e28c0773393d07754c765fb627d79ecc37
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1266747
milestone54.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 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)