Bug 1505286 - Part 1: Show proper URL of zombie tab on Android. r=ochameau,jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Mon, 10 Dec 2018 15:40:26 +0000
changeset 449768 755ac698de795b016bec6f6b14d15d6dd5f88a23
parent 449767 bfd73976f27e1dc2b64f0203f9460f726e3ebedd
child 449769 fd04a73e9732b4ede0ce8a82a7bee508d079176d
push id35185
push userncsoregi@mozilla.com
push dateTue, 11 Dec 2018 09:38:01 +0000
treeherdermozilla-central@0132b59bb093 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, jdescottes
bugs1505286
milestone66.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 1505286 - Part 1: Show proper URL of zombie tab on Android. r=ochameau,jdescottes Differential Revision: https://phabricator.services.mozilla.com/D13223
devtools/server/actors/targets/frame-proxy.js
--- a/devtools/server/actors/targets/frame-proxy.js
+++ b/devtools/server/actors/targets/frame-proxy.js
@@ -119,65 +119,75 @@ FrameTargetActorProxy.prototype = {
     this._form = form;
     if (this.options.favicons) {
       this._form.favicon = await this.getFaviconData();
     }
 
     return this;
   },
 
+  _isZombieTab() {
+    // Check for Firefox on Android.
+    if (this._browser.hasAttribute("pending")) {
+      return true;
+    }
+
+    // Check for other.
+    const tabbrowser = this._tabbrowser;
+    const tab = tabbrowser ? tabbrowser.getTabForBrowser(this._browser) : null;
+    return tab && tab.hasAttribute && tab.hasAttribute("pending");
+  },
+
   /**
    * If we don't have a title from the content side because it's a zombie tab, try to find
    * it on the chrome side.
    */
-  get title() {
+  _getZombieTabTitle() {
     // On Fennec, we can check the session store data for zombie tabs
     if (this._browser && this._browser.__SS_restore) {
       const sessionStore = this._browser.__SS_data;
       // Get the last selected entry
       const entry = sessionStore.entries[sessionStore.index - 1];
       return entry.title;
     }
     // If contentTitle is empty (e.g. on a not-yet-restored tab), but there is a
     // tabbrowser (i.e. desktop Firefox, but not Fennec), we can use the label
     // as the title.
     if (this._tabbrowser) {
       const tab = this._tabbrowser.getTabForBrowser(this._browser);
       if (tab) {
         return tab.label;
       }
     }
-    return "";
+
+    return null;
   },
 
   /**
    * If we don't have a url from the content side because it's a zombie tab, try to find
    * it on the chrome side.
    */
-  get url() {
+  _getZombieTabUrl() {
     // On Fennec, we can check the session store data for zombie tabs
     if (this._browser && this._browser.__SS_restore) {
       const sessionStore = this._browser.__SS_data;
       // Get the last selected entry
       const entry = sessionStore.entries[sessionStore.index - 1];
       return entry.url;
     }
+
     return null;
   },
 
   form() {
     const form = Object.assign({}, this._form);
-    // In some cases, the title and url fields might be empty.  Zombie tabs (not yet
-    // restored) are a good example.  In such cases, try to look up values for these
-    // fields using other data in the parent process.
-    if (!form.title) {
-      form.title = this.title;
-    }
-    if (!form.url) {
-      form.url = this.url;
+    // In case of Zombie tabs (not yet restored), look up title and url from other.
+    if (this._isZombieTab()) {
+      form.title = this._getZombieTabTitle() || form.title;
+      form.url = this._getZombieTabUrl() || form.url;
     }
 
     return form;
   },
 
   exit() {
     this._browser = null;
     this._form = null;