Bug 1407515 - simplify Open in New Tab in launchpad r=Honza
authorTom Glowka <glowka.tom@gmail.com>
Thu, 29 Mar 2018 13:01:30 +0200
changeset 411493 52216da191ea
parent 411492 4213a293a540
child 411494 1debc4ccf15b
push id33760
push useraciure@mozilla.com
push dateTue, 03 Apr 2018 21:52:50 +0000
treeherdermozilla-central@ad27045cac84 [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 - simplify Open in New Tab in launchpad r=Honza Narrow down request methods to actually working (supported by form tag) when opening new tab in launchpad. MozReview-Commit-ID: 2fE2VkH8B8l
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,17 +7,17 @@
 
 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(url, method, requestPostData) {
+function openRequestInTab(url, requestPostData) {
   let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
   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);
--- a/devtools/client/netmonitor/src/utils/open-request-in-tab.js
+++ b/devtools/client/netmonitor/src/utils/open-request-in-tab.js
@@ -5,34 +5,33 @@
 "use strict";
 
 const Services = require("Services");
 const { gDevTools } = require("devtools/client/framework/devtools");
 
 /**
  * Opens given request in a new tab.
  */
-function openRequestInTab(url, method, requestPostData) {
+function openRequestInTab(url, requestPostData) {
   let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
-  if (method.toLowerCase() !== "get") {
+  if (!requestPostData) {
     win.openUILinkIn(url, "tab", {relatedToCurrent: true});
   } else {
-    openRequestInTabHelper({
+    openPostRequestInTabHelper({
       url,
-      method,
-      data: requestPostData ? requestPostData.postData : null,
+      data: requestPostData.postData
     });
   }
 }
 
-function openRequestInTabHelper({url, method, data}) {
+function openPostRequestInTabHelper({url, data}) {
   let form = document.createElement("form");
   form.target = "_blank";
   form.action = url;
-  form.method = method;
+  form.method = "post";
 
   if (data) {
     for (let key in data) {
       let input = document.createElement("input");
       input.name = key;
       input.value = data[key];
       form.appendChild(input);
     }
--- 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(id, url, method, requestPostData),
+      click: () => this.openRequestInTab(id, url, 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,20 +224,20 @@ class RequestListContextMenu {
     });
 
     showMenu(event, menu);
   }
 
   /**
    * Opens selected item in a new tab.
    */
-  async openRequestInTab(id, url, method, requestPostData) {
+  async openRequestInTab(id, url, requestPostData) {
     requestPostData = requestPostData ||
       await this.props.connector.requestData(id, "requestPostData");
-    openRequestInTab(url, method, requestPostData);
+    openRequestInTab(url, requestPostData);
   }
 
   /**
    * Opens selected item in the debugger
    */
   openInDebugger(url) {
     let toolbox = gDevTools.getToolbox(this.props.connector.getTabTarget());
     toolbox.viewSourceInDebugger(url, 0);