[Pkg-mozext-commits] [tabmixplus] 09/61: Follow up bug 1129957 - [e10s] RemoteWebNavigation doesn't accept postdata or headers

David Prévot taffit at moszumanska.debian.org
Fri Aug 28 19:09:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit e6ac06228af2e199a21e946b93e0550f80991d21
Author: onemen <tabmix.onemen at gmail.com>
Date:   Fri Jul 10 18:50:10 2015 +0300

    Follow up bug 1129957 - [e10s] RemoteWebNavigation doesn't accept postdata or headers
---
 chrome/content/content.js | 22 ++++++++++++++++++----
 modules/AutoReload.jsm    | 18 +++++++-----------
 modules/Utils.jsm         | 12 +++++++++++-
 3 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/chrome/content/content.js b/chrome/content/content.js
index 025f549..16165dc 100644
--- a/chrome/content/content.js
+++ b/chrome/content/content.js
@@ -10,6 +10,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "DocShellCapabilities",
 XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
   "resource://gre/modules/BrowserUtils.jsm");
 
+XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
+  "resource://gre/modules/NetUtil.jsm");
+
 XPCOMUtils.defineLazyModuleGetter(this, "TabmixSvc",
   "resource://tabmixplus/Services.jsm");
 
@@ -85,15 +88,26 @@ let TabmixContentHandler = {
         break;
       case "Tabmix:collectReloadData":
         let json = {scrollX: content.scrollX,
-                    scrollY: content.scrollY};
-        let sh = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
+                    scrollY: content.scrollY,
+                    postData: null};
+        let sh = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory
+                         .QueryInterface(Ci.nsISHistoryInternal);
         if (sh) {
           let entry = sh.getEntryAtIndex(sh.index, false);
-          json.isPostData = !!entry.QueryInterface(Ci.nsISHEntry).postData;
-          json.isPostData = true;
+          let postData = entry.postData;
+          // RemoteWebNavigation accepting postdata or headers only from Firefox 42.
+          if (postData && TabmixSvc.version(420)) {
+            postData = postData.clone();
+            json.postData = NetUtil.readInputStreamToString(postData, postData.available());
+            let referrer = entry.referrerURI;
+            json.referrer = referrer ? referrer.spec : null;
+          }
+          json.isPostData = !!json.postData;
         }
         sendAsyncMessage("Tabmix:reloadTab", json);
         break;
+      case "Tabmix:setPostData":
+        break;
       case "Tabmix:isFrameInContent":
         let result = LinkNodeUtils.isFrameInContent(content, data.href, data.name);
         sendAsyncMessage("Tabmix:isFrameInContentResult", {result: result});
diff --git a/modules/AutoReload.jsm b/modules/AutoReload.jsm
index 719f379..4176f6c 100644
--- a/modules/AutoReload.jsm
+++ b/modules/AutoReload.jsm
@@ -263,23 +263,19 @@ this.AutoReload = {
     let resultOK = Services.prompt.confirm(window, title, msg);
     if (resultOK)
       tab.postDataAcceptedByUser = true;
-    else {
-      tab.autoReloadEnabled = false;
-      _setItem(tab, "_reload", null);
-      tab.autoReloadURI = null;
-      this._update(tab);
-    }
+    else
+      this._disable(tab);
+
     return resultOK;
   },
 
   reloadRemoteTab: function(browser, data) {
     var window = browser.ownerDocument.defaultView;
     let tab = window.gBrowser.getTabForBrowser(browser);
-    // RemoteWebNavigation doesn't accept postdata or headers.
-    if (data.isPostData && !this.confirm(window, tab, true))
+    // RemoteWebNavigation accepting postdata or headers only from Firefox 42.
+    if (data.isPostData && !this.confirm(window, tab, !TabmixSvc.version(420)))
       return;
 
-    data.remote = true;
     doReloadTab(window, browser, data);
   }
 };
@@ -330,11 +326,11 @@ function doReloadTab(window, browser, data) {
 
   // This part is based on BrowserReloadWithFlags.
   let url = browser.currentURI.spec;
-  let {postData, referrer, remote} = data;
+  let {postData, referrer} = data;
   let loadURIWithFlags = TabmixSvc.version(330) &&
       window.gBrowser.updateBrowserRemotenessByURL(browser, url) || postData;
   if (loadURIWithFlags) {
-    if (remote || !postData)
+    if (!postData)
       postData = referrer = null;
     browser.loadURIWithFlags(url, loadFlags, referrer, null, postData);
     return;
diff --git a/modules/Utils.jsm b/modules/Utils.jsm
index 1ee3720..fc0ea7e 100644
--- a/modules/Utils.jsm
+++ b/modules/Utils.jsm
@@ -2,7 +2,7 @@
 
 var EXPORTED_SYMBOLS = ["TabmixUtils"];
 
-const {interfaces: Ci, utils: Cu} = Components;
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 // Messages that will be received via the Frame Message Manager.
 const FMM_MESSAGES = [
@@ -56,6 +56,9 @@ this.TabmixUtils = {
         win.TabmixSessionManager.updateScrollPosition(tab, message.data.scroll);
         break;
       case "Tabmix:reloadTab":
+        let postData = message.data.postData;
+        if (postData)
+          message.data.postData = this.makeInputStream(postData);
         AutoReload.reloadRemoteTab(browser, message.data);
         break;
       case "Tabmix:getOpener":
@@ -66,6 +69,13 @@ this.TabmixUtils = {
     }
   },
 
+  makeInputStream: function(aString) {
+    let stream = Cc["@mozilla.org/io/string-input-stream;1"].
+    createInstance(Ci.nsISupportsCString);
+    stream.data = aString;
+    return stream;
+  },
+
   // change current history title
   updateHistoryTitle: function(history, title) {
     var shEntry = history.getEntryAtIndex(history.index, false).QueryInterface(Ci.nsISHEntry);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list