Bug 1407515 - simplify Open in New Tab in launchpad draft
authorTom Glowka <glowka.tom@gmail.com>
Thu, 29 Mar 2018 13:01:30 +0200
changeset 775112 9ba01ea8f145
parent 775111 8adf587744cc
child 775113 edf9b2a8d1d7
child 775114 82786d36dfa6
child 775115 ef5a4a80cc42
child 775117 8b1e08cde175
child 776628 e798a58b49bc
child 776653 67e1dfd23c31
push id104611
push userbmo:glowka.tom@gmail.com
push dateFri, 30 Mar 2018 03:02:03 +0000
bugs1407515
milestone61.0a1
Bug 1407515 - simplify Open in New Tab in launchpad 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);