Bug 1407515 - make sure post data is suplied to Open in New Tab r=Honza
authorTom Glowka <glowka.tom@gmail.com>
Thu, 29 Mar 2018 11:40:11 +0200
changeset 411564 4213a293a54063fcb860aedacdf87fe0de42fbd1
parent 411563 69964a79c66ac99adb528e1c8365b6cece01387c
child 411565 52216da191eae9b480ac625a6fc4a88e04d7cc2e
push id101686
push useraciure@mozilla.com
push dateTue, 03 Apr 2018 21:59:31 +0000
treeherdermozilla-inbound@8d846598d35d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1407515
milestone61.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 1407515 - make sure post data is suplied to Open in New Tab r=Honza MozReview-Commit-ID: JqqS7ZhLrr7
devtools/client/netmonitor/src/utils/firefox/open-request-in-tab.js
devtools/client/netmonitor/src/utils/open-request-in-tab.js
devtools/client/netmonitor/src/widgets/RequestListContextMenu.js
--- a/devtools/client/netmonitor/src/utils/firefox/open-request-in-tab.js
+++ b/devtools/client/netmonitor/src/utils/firefox/open-request-in-tab.js
@@ -7,30 +7,30 @@
 
 let { Cc, Ci } = require("chrome");
 const Services = require("Services");
 const { gDevTools } = require("devtools/client/framework/devtools");
 
 /**
  * Opens given request in a new tab.
  */
-function openRequestInTab(request) {
+function openRequestInTab(url, method, requestPostData) {
   let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
-  let rawData = request.requestPostData ? request.requestPostData.postData : null;
+  let rawData = requestPostData ? requestPostData.postData : null;
   let postData;
 
   if (rawData && rawData.text) {
     let stringStream = getInputStreamFromString(rawData.text);
     postData = Cc["@mozilla.org/network/mime-input-stream;1"]
       .createInstance(Ci.nsIMIMEInputStream);
     postData.addHeader("Content-Type", "application/x-www-form-urlencoded");
     postData.setData(stringStream);
   }
 
-  win.gBrowser.selectedTab = win.gBrowser.addTab(request.url, null, null, postData);
+  win.gBrowser.selectedTab = win.gBrowser.addTab(url, null, null, postData);
 }
 
 function getInputStreamFromString(data) {
   let stringStream = Cc["@mozilla.org/io/string-input-stream;1"]
     .createInstance(Ci.nsIStringInputStream);
   stringStream.data = data;
   return stringStream;
 }
--- a/devtools/client/netmonitor/src/utils/open-request-in-tab.js
+++ b/devtools/client/netmonitor/src/utils/open-request-in-tab.js
@@ -5,27 +5,25 @@
 "use strict";
 
 const Services = require("Services");
 const { gDevTools } = require("devtools/client/framework/devtools");
 
 /**
  * Opens given request in a new tab.
  */
-function openRequestInTab(request) {
+function openRequestInTab(url, method, requestPostData) {
   let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
-  if (request.method.toLowerCase() !== "get") {
-    win.openUILinkIn(this.selectedRequest.url, "tab", {
-      relatedToCurrent: true
-    });
+  if (method.toLowerCase() !== "get") {
+    win.openUILinkIn(url, "tab", {relatedToCurrent: true});
   } else {
     openRequestInTabHelper({
-      url: request.url,
-      method: request.method,
-      data: request.requestPostData ? request.requestPostData.postData : null,
+      url,
+      method,
+      data: requestPostData ? requestPostData.postData : null,
     });
   }
 }
 
 function openRequestInTabHelper({url, method, data}) {
   let form = document.createElement("form");
   form.target = "_blank";
   form.action = url;
--- a/devtools/client/netmonitor/src/widgets/RequestListContextMenu.js
+++ b/devtools/client/netmonitor/src/widgets/RequestListContextMenu.js
@@ -189,17 +189,17 @@ class RequestListContextMenu {
       visible: copySubmenu.slice(15, 16).some((subMenu) => subMenu.visible),
     });
 
     menu.push({
       id: "request-list-context-newtab",
       label: L10N.getStr("netmonitor.context.newTab"),
       accesskey: L10N.getStr("netmonitor.context.newTab.accesskey"),
       visible: !!selectedRequest,
-      click: () => this.openRequestInTab(selectedRequest),
+      click: () => this.openRequestInTab(id, url, method, requestPostData),
     });
 
     menu.push({
       id: "request-list-context-open-in-debugger",
       label: L10N.getStr("netmonitor.context.openInDebugger"),
       accesskey: L10N.getStr("netmonitor.context.openInDebugger.accesskey"),
       visible: !!(selectedRequest && mimeType && mimeType.includes("javascript")),
       click: () => this.openInDebugger(url),
@@ -224,18 +224,20 @@ class RequestListContextMenu {
     });
 
     showMenu(event, menu);
   }
 
   /**
    * Opens selected item in a new tab.
    */
-  openRequestInTab(selectedRequest) {
-    openRequestInTab(selectedRequest);
+  async openRequestInTab(id, url, method, requestPostData) {
+    requestPostData = requestPostData ||
+      await this.props.connector.requestData(id, "requestPostData");
+    openRequestInTab(url, method, requestPostData);
   }
 
   /**
    * Opens selected item in the debugger
    */
   openInDebugger(url) {
     let toolbox = gDevTools.getToolbox(this.props.connector.getTabTarget());
     toolbox.viewSourceInDebugger(url, 0);