mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 11:57:32 +09:00
Properly pass postData into new tab
https://github.com/MoonchildProductions/moebius/pull/352
This commit is contained in:
parent
4f34dc2b96
commit
27538800b5
3 changed files with 43 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ DevToolsModules(
|
|||
'events.js',
|
||||
'filter-predicates.js',
|
||||
'l10n.js',
|
||||
'open-request-in-tab.js',
|
||||
'panel.js',
|
||||
'performance-statistics-view.js',
|
||||
'prefs.js',
|
||||
|
|
|
|||
40
devtools/client/netmonitor/open-request-in-tab.js
Normal file
40
devtools/client/netmonitor/open-request-in-tab.js
Normal file
|
|
@ -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,
|
||||
};
|
||||
|
|
@ -10,6 +10,7 @@ const Services = require("Services");
|
|||
const { Task } = require("devtools/shared/task");
|
||||
const { Curl } = require("devtools/client/shared/curl");
|
||||
const { gDevTools } = require("devtools/client/framework/devtools");
|
||||
const { openRequestInTab } = require("devtools/client/netmonitor/open-request-in-tab");
|
||||
const Menu = require("devtools/client/framework/menu");
|
||||
const MenuItem = require("devtools/client/framework/menu-item");
|
||||
const { L10N } = require("./l10n");
|
||||
|
|
@ -186,8 +187,7 @@ RequestListContextMenu.prototype = {
|
|||
*/
|
||||
openRequestInTab() {
|
||||
let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
|
||||
let { url } = this.selectedItem.attachment;
|
||||
win.openUILinkIn(url, "tab", { relatedToCurrent: true });
|
||||
openRequestInTab(this.selectedItem.attachment);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue