mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 929887 - Make the Network Monitor use CodeMirror. r=vporof
This commit is contained in:
parent
0ef7e11de9
commit
25b01a19e1
@ -61,13 +61,15 @@ const EVENTS = {
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js").Promise;
|
||||
Cu.import("resource:///modules/devtools/sourceeditor/source-editor.jsm");
|
||||
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
|
||||
Cu.import("resource:///modules/devtools/SideMenuWidget.jsm");
|
||||
Cu.import("resource:///modules/devtools/VariablesView.jsm");
|
||||
Cu.import("resource:///modules/devtools/VariablesViewController.jsm");
|
||||
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
|
||||
|
||||
const require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools.require;
|
||||
const Editor = require("devtools/sourceeditor/editor");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
|
@ -29,22 +29,22 @@ const CONTENT_MIME_TYPE_ABBREVIATIONS = {
|
||||
"x-javascript": "js"
|
||||
};
|
||||
const CONTENT_MIME_TYPE_MAPPINGS = {
|
||||
"/ecmascript": SourceEditor.MODES.JAVASCRIPT,
|
||||
"/javascript": SourceEditor.MODES.JAVASCRIPT,
|
||||
"/x-javascript": SourceEditor.MODES.JAVASCRIPT,
|
||||
"/html": SourceEditor.MODES.HTML,
|
||||
"/xhtml": SourceEditor.MODES.HTML,
|
||||
"/xml": SourceEditor.MODES.HTML,
|
||||
"/atom": SourceEditor.MODES.HTML,
|
||||
"/soap": SourceEditor.MODES.HTML,
|
||||
"/rdf": SourceEditor.MODES.HTML,
|
||||
"/rss": SourceEditor.MODES.HTML,
|
||||
"/css": SourceEditor.MODES.CSS
|
||||
"/ecmascript": Editor.modes.js,
|
||||
"/javascript": Editor.modes.js,
|
||||
"/x-javascript": Editor.modes.js,
|
||||
"/html": Editor.modes.html,
|
||||
"/xhtml": Editor.modes.html,
|
||||
"/xml": Editor.modes.html,
|
||||
"/atom": Editor.modes.html,
|
||||
"/soap": Editor.modes.html,
|
||||
"/rdf": Editor.modes.css,
|
||||
"/rss": Editor.modes.css,
|
||||
"/css": Editor.modes.css
|
||||
};
|
||||
const DEFAULT_EDITOR_CONFIG = {
|
||||
mode: SourceEditor.MODES.TEXT,
|
||||
mode: Editor.modes.text,
|
||||
readOnly: true,
|
||||
showLineNumbers: true
|
||||
lineNumbers: true
|
||||
};
|
||||
const GENERIC_VARIABLES_VIEW_SETTINGS = {
|
||||
lazyEmpty: true,
|
||||
@ -156,7 +156,7 @@ let NetMonitorView = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Lazily initializes and returns a promise for a SourceEditor instance.
|
||||
* Lazily initializes and returns a promise for a Editor instance.
|
||||
*
|
||||
* @param string aId
|
||||
* The id of the editor placeholder node.
|
||||
@ -175,7 +175,8 @@ let NetMonitorView = {
|
||||
|
||||
// Initialize the source editor and store the newly created instance
|
||||
// in the ether of a resolved promise's value.
|
||||
new SourceEditor().init($(aId), DEFAULT_EDITOR_CONFIG, deferred.resolve);
|
||||
let editor = new Editor(DEFAULT_EDITOR_CONFIG);
|
||||
editor.appendTo($(aId)).then(() => deferred.resolve(editor));
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
@ -1900,7 +1901,7 @@ NetworkDetailsView.prototype = {
|
||||
else {
|
||||
$("#response-content-textarea-box").hidden = false;
|
||||
NetMonitorView.editor("#response-content-textarea").then(aEditor => {
|
||||
aEditor.setMode(SourceEditor.MODES.JAVASCRIPT);
|
||||
aEditor.setMode(Editor.modes.js);
|
||||
aEditor.setText(aString);
|
||||
});
|
||||
let infoHeader = $("#response-content-info-header");
|
||||
@ -1937,7 +1938,7 @@ NetworkDetailsView.prototype = {
|
||||
else {
|
||||
$("#response-content-textarea-box").hidden = false;
|
||||
NetMonitorView.editor("#response-content-textarea").then(aEditor => {
|
||||
aEditor.setMode(SourceEditor.MODES.TEXT);
|
||||
aEditor.setMode(Editor.modes.text);
|
||||
aEditor.setText(aString);
|
||||
|
||||
// Maybe set a more appropriate mode in the Source Editor if possible,
|
||||
|
@ -9,7 +9,7 @@ function test() {
|
||||
initNetMonitor(CONTENT_TYPE_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -130,7 +130,7 @@ function test() {
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "<label value='greeting'>Hello XML!</label>",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.HTML,
|
||||
is(aEditor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
});
|
||||
}
|
||||
@ -140,7 +140,7 @@ function test() {
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "body:pre { content: 'Hello CSS!' }",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.CSS,
|
||||
is(aEditor.getMode(), Editor.modes.css,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
});
|
||||
}
|
||||
@ -150,7 +150,7 @@ function test() {
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "function() { return 'Hello JS!'; }",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.JAVASCRIPT,
|
||||
is(aEditor.getMode(), Editor.modes.js,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
});
|
||||
}
|
||||
@ -188,7 +188,7 @@ function test() {
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "<blink>Not Found</blink>",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.HTML,
|
||||
is(aEditor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is incorrect for the xml request.");
|
||||
});
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ function test() {
|
||||
initNetMonitor(CYRILLIC_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -29,7 +29,7 @@ function test() {
|
||||
NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText().indexOf("\u044F"), 26, // я
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.TEXT,
|
||||
is(aEditor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
|
@ -10,7 +10,7 @@ function test() {
|
||||
initNetMonitor(CYRILLIC_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -30,7 +30,7 @@ function test() {
|
||||
NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText().indexOf("\u044F"), 302, // я
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.HTML,
|
||||
is(aEditor.getMode(), Editor.modes.html,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
|
@ -13,7 +13,7 @@ function test() {
|
||||
// in a variables view instance. Debug builds are slow.
|
||||
requestLongerTimeout(4);
|
||||
|
||||
let { document, L10N, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
@ -9,7 +9,7 @@ function test() {
|
||||
initNetMonitor(JSON_MALFORMED_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -59,7 +59,7 @@ function test() {
|
||||
NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "{ \"greeting\": \"Hello malformed JSON!\" },",
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.JAVASCRIPT,
|
||||
is(aEditor.getMode(), Editor.modes.js,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
|
@ -9,7 +9,7 @@ function test() {
|
||||
initNetMonitor(JSON_CUSTOM_MIME_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
@ -9,7 +9,7 @@ function test() {
|
||||
initNetMonitor(JSONP_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, L10N, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
|
@ -13,7 +13,7 @@ function test() {
|
||||
// is going to be requested and displayed in the source editor.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
let { document, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -29,7 +29,7 @@ function test() {
|
||||
NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
ok(aEditor.getText().match(/^<p>/),
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.TEXT,
|
||||
is(aEditor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
|
||||
teardown(aMonitor).then(finish);
|
||||
|
@ -9,7 +9,7 @@ function test() {
|
||||
initNetMonitor(POST_DATA_URL).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -141,7 +141,7 @@ function test() {
|
||||
"The text shown in the source editor is incorrect (3.2).");
|
||||
ok(aEditor.getText().contains("Extra data"),
|
||||
"The text shown in the source editor is incorrect (4.2).");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.TEXT,
|
||||
is(aEditor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
});
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ function test() {
|
||||
initNetMonitor(SIMPLE_SJS).then(([aTab, aDebuggee, aMonitor]) => {
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, L10N, SourceEditor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { document, L10N, Editor, NetMonitorView } = aMonitor.panelWin;
|
||||
let { RequestsMenu, NetworkDetails } = NetMonitorView;
|
||||
|
||||
RequestsMenu.lazyUpdate = false;
|
||||
@ -194,7 +194,7 @@ function test() {
|
||||
return NetMonitorView.editor("#response-content-textarea").then((aEditor) => {
|
||||
is(aEditor.getText(), "Hello world!",
|
||||
"The text shown in the source editor is incorrect.");
|
||||
is(aEditor.getMode(), SourceEditor.MODES.TEXT,
|
||||
is(aEditor.getMode(), Editor.modes.text,
|
||||
"The mode active in the source editor is incorrect.");
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user