Bug 909048 - Collect text and scroll data from content script (r=ttaubert)
authorBill McCloskey <wmccloskey@mozilla.com>
Fri, 18 Oct 2013 10:09:25 -0700
changeset 165189 dc567d1ab40866be259ed55ec9b1e2205d42206e
parent 165188 65a3d9172a6becacbd4e4cd29f4a8985fc43fc5c
child 165190 dd684eb0462bc09632da4c7e73a0c40303a6722b
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs909048
milestone27.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 909048 - Collect text and scroll data from content script (r=ttaubert)
browser/components/sessionstore/content/content-sessionStore.js
browser/components/sessionstore/src/SessionStore.jsm
--- a/browser/components/sessionstore/content/content-sessionStore.js
+++ b/browser/components/sessionstore/content/content-sessionStore.js
@@ -15,16 +15,18 @@ Cu.import("resource://gre/modules/XPCOMU
 XPCOMUtils.defineLazyModuleGetter(this, "DocShellCapabilities",
   "resource:///modules/sessionstore/DocShellCapabilities.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PageStyle",
   "resource:///modules/sessionstore/PageStyle.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "SessionHistory",
   "resource:///modules/sessionstore/SessionHistory.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "SessionStorage",
   "resource:///modules/sessionstore/SessionStorage.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "TextAndScrollData",
+  "resource:///modules/sessionstore/TextAndScrollData.jsm");
 
 /**
  * Listens for and handles content events that we need for the
  * session store service to be notified of state changes in content.
  */
 let EventListener = {
 
   DOM_EVENTS: [
@@ -84,16 +86,24 @@ let MessageListener = {
   init: function () {
     this.MESSAGES.forEach(m => addMessageListener(m, this));
   },
 
   receiveMessage: function ({name, data: {id}}) {
     switch (name) {
       case "SessionStore:collectSessionHistory":
         let history = SessionHistory.read(docShell);
+        if ("index" in history) {
+          let tabIndex = history.index - 1;
+          // Don't include private data. It's only needed when duplicating
+          // tabs, which collects data synchronously.
+          TextAndScrollData.updateFrame(history.entries[tabIndex],
+                                        content,
+                                        docShell.isAppTab);
+        }
         sendAsyncMessage(name, {id: id, data: history});
         break;
       case "SessionStore:collectSessionStorage":
         let storage = SessionStorage.serialize(docShell);
         sendAsyncMessage(name, {id: id, data: storage});
         break;
       case "SessionStore:collectDocShellCapabilities":
         let disallow = DocShellCapabilities.collect(docShell);
--- a/browser/components/sessionstore/src/SessionStore.jsm
+++ b/browser/components/sessionstore/src/SessionStore.jsm
@@ -4211,17 +4211,18 @@ let TabState = {
     // have saved for it.
     let browser = tab.linkedBrowser;
     if (!browser.currentURI || (browser.__SS_data && browser.__SS_tabStillLoading)) {
       let tabData = new TabData(this._collectBaseTabData(tab));
       return Promise.resolve(tabData);
     }
 
     let promise = Task.spawn(function task() {
-      // Collected session history data asynchronously.
+      // Collect session history data asynchronously. Also collects
+      // text and scroll data.
       let history = yield Messenger.send(tab, "SessionStore:collectSessionHistory");
 
       // Collected session storage data asynchronously.
       let storage = yield Messenger.send(tab, "SessionStore:collectSessionStorage");
 
       // Collect docShell capabilities asynchronously.
       let disallow = yield Messenger.send(tab, "SessionStore:collectDocShellCapabilities");
 
@@ -4246,19 +4247,16 @@ let TabState = {
       if (disallow.length > 0) {
         tabData.disallow = disallow.join(",");
       }
 
       if (pageStyle) {
         tabData.pageStyle = pageStyle;
       }
 
-      // Save text and scroll data.
-      this._updateTextAndScrollDataForTab(tab, tabData);
-
       // If we're still the latest async collection for the given tab and
       // the cache hasn't been filled by collect() in the meantime, let's
       // fill the cache with the data we received.
       if (this._pendingCollections.get(tab) == promise) {
         TabStateCache.set(tab, tabData);
         this._pendingCollections.delete(tab);
       }