diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-01 17:29:55 +0100 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-01 17:29:55 +0100 |
commit | 13a6805652925398b2f079f7ee7fba4b512b51ad (patch) | |
tree | 9f3dcbcf5b771aa92447421bc875b7062a863659 /devtools/client/netmonitor/open-request-in-tab.js | |
parent | aa60e7f7146d3b90931fd9e1fb01bed8399e6c23 (diff) | |
download | UXP-13a6805652925398b2f079f7ee7fba4b512b51ad.tar UXP-13a6805652925398b2f079f7ee7fba4b512b51ad.tar.gz UXP-13a6805652925398b2f079f7ee7fba4b512b51ad.tar.lz UXP-13a6805652925398b2f079f7ee7fba4b512b51ad.tar.xz UXP-13a6805652925398b2f079f7ee7fba4b512b51ad.zip |
Properly pass postData into new tab
https://github.com/MoonchildProductions/moebius/pull/352
Diffstat (limited to 'devtools/client/netmonitor/open-request-in-tab.js')
-rw-r--r-- | devtools/client/netmonitor/open-request-in-tab.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/open-request-in-tab.js b/devtools/client/netmonitor/open-request-in-tab.js new file mode 100644 index 000000000..aeb35dad0 --- /dev/null +++ b/devtools/client/netmonitor/open-request-in-tab.js @@ -0,0 +1,40 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+/* eslint-disable mozilla/reject-some-requires */
+
+"use strict";
+
+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) {
+ let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
+ let rawData = request.requestPostData ? request.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);
+}
+
+function getInputStreamFromString(data) {
+ let stringStream = Cc["@mozilla.org/io/string-input-stream;1"]
+ .createInstance(Ci.nsIStringInputStream);
+ stringStream.data = data;
+ return stringStream;
+}
+
+module.exports = {
+ openRequestInTab,
+};
|