diff --git a/devtools/client/netmonitor/src/components/response-panel.js b/devtools/client/netmonitor/src/components/response-panel.js index d55514aa373f..f3c6ab221a02 100644 --- a/devtools/client/netmonitor/src/components/response-panel.js +++ b/devtools/client/netmonitor/src/components/response-panel.js @@ -156,17 +156,16 @@ const ResponsePanel = createClass({ sectionName = JSON_SCOPE_NAME; } object[sectionName] = json; - } else { - sectionName = RESPONSE_PAYLOAD; - - object[sectionName] = { - EDITOR_CONFIG: { - text, - mode: mimeType.replace(/;.+/, ""), - }, - }; } + // Others like text/html, text/plain, application/javascript + object[RESPONSE_PAYLOAD] = { + EDITOR_CONFIG: { + text, + mode: json ? "application/json" : mimeType.replace(/;.+/, ""), + }, + }; + return ( div({ className: "panel-container" }, error && div({ className: "response-error-header", title: error }, @@ -175,7 +174,7 @@ const ResponsePanel = createClass({ PropertiesView({ object, filterPlaceHolder: JSON_FILTER_TEXT, - sectionNames: [sectionName], + sectionNames: Object.keys(object), }), ) ); diff --git a/devtools/client/netmonitor/test/browser_net_content-type.js b/devtools/client/netmonitor/test/browser_net_content-type.js index 03f5162c098f..8a64d38912c5 100644 --- a/devtools/client/netmonitor/test/browser_net_content-type.js +++ b/devtools/client/netmonitor/test/browser_net_content-type.js @@ -170,7 +170,7 @@ add_task(function* () { box != "json", "The response json view doesn't display"); is(tabpanel.querySelector(".CodeMirror-code") === null, - box != "textarea", + (box !== "textarea" && box !== "json"), "The response editor doesn't display"); is(tabpanel.querySelector(".response-image-box") === null, box != "image", @@ -208,8 +208,8 @@ add_task(function* () { case "json": { checkVisibility("json"); - is(tabpanel.querySelectorAll(".tree-section").length, 1, - "There should be 1 tree sections displayed in this tabpanel."); + is(tabpanel.querySelectorAll(".tree-section").length, 2, + "There should be 2 tree sections displayed in this tabpanel."); is(tabpanel.querySelectorAll(".empty-notice").length, 0, "The empty notice should not be displayed in this tabpanel."); diff --git a/devtools/client/netmonitor/test/browser_net_json-b64.js b/devtools/client/netmonitor/test/browser_net_json-b64.js index e528c14b80a0..f419d2a0f486 100644 --- a/devtools/client/netmonitor/test/browser_net_json-b64.js +++ b/devtools/client/netmonitor/test/browser_net_json-b64.js @@ -23,7 +23,7 @@ add_task(function* () { }); yield wait; - wait = waitForDOM(document, "#response-panel"); + wait = waitForDOM(document, "#response-panel .CodeMirror-code"); EventUtils.sendMouseEvent({ type: "click" }, document.querySelector(".network-details-panel-toggle")); EventUtils.sendMouseEvent({ type: "click" }, @@ -37,13 +37,13 @@ add_task(function* () { let jsonView = tabpanel.querySelector(".tree-section .treeLabel") || {}; is(jsonView.textContent === L10N.getStr("jsonScopeName"), true, "The response json view has the intended visibility."); - is(tabpanel.querySelector(".CodeMirror-code") === null, true, - "The response editor doesn't have the intended visibility."); + is(tabpanel.querySelector(".CodeMirror-code") === null, false, + "The response editor has the intended visibility."); is(tabpanel.querySelector(".response-image-box") === null, true, "The response image box doesn't have the intended visibility."); - is(tabpanel.querySelectorAll(".tree-section").length, 1, - "There should be 1 tree sections displayed in this tabpanel."); + is(tabpanel.querySelectorAll(".tree-section").length, 2, + "There should be 2 tree sections displayed in this tabpanel."); is(tabpanel.querySelectorAll(".treeRow:not(.tree-section)").length, 1, "There should be 1 json properties displayed in this tabpanel."); is(tabpanel.querySelectorAll(".empty-notice").length, 0, diff --git a/devtools/client/netmonitor/test/browser_net_json-long.js b/devtools/client/netmonitor/test/browser_net_json-long.js index 93b717dc0167..0366e7fbe473 100644 --- a/devtools/client/netmonitor/test/browser_net_json-long.js +++ b/devtools/client/netmonitor/test/browser_net_json-long.js @@ -48,7 +48,7 @@ add_task(function* () { time: true }); - wait = waitForDOM(document, "#response-panel"); + wait = waitForDOM(document, "#response-panel .CodeMirror-code"); EventUtils.sendMouseEvent({ type: "click" }, document.querySelector(".network-details-panel-toggle")); EventUtils.sendMouseEvent({ type: "click" }, @@ -67,13 +67,13 @@ add_task(function* () { let jsonView = tabpanel.querySelector(".tree-section .treeLabel") || {}; is(jsonView.textContent === L10N.getStr("jsonScopeName"), true, "The response json view has the intended visibility."); - is(tabpanel.querySelector(".CodeMirror-code") === null, true, - "The response editor doesn't have the intended visibility."); + is(tabpanel.querySelector(".CodeMirror-code") === null, false, + "The response editor has the intended visibility."); is(tabpanel.querySelector(".response-image-box") === null, true, "The response image box doesn't have the intended visibility."); - is(tabpanel.querySelectorAll(".tree-section").length, 1, - "There should be 1 tree sections displayed in this tabpanel."); + is(tabpanel.querySelectorAll(".tree-section").length, 2, + "There should be 2 tree sections displayed in this tabpanel."); is(tabpanel.querySelectorAll(".treeRow:not(.tree-section)").length, 2047, "There should be 2047 json properties displayed in this tabpanel."); is(tabpanel.querySelectorAll(".empty-notice").length, 0, diff --git a/devtools/client/netmonitor/test/browser_net_json-malformed.js b/devtools/client/netmonitor/test/browser_net_json-malformed.js index 3d0be018d57d..263aaea8a400 100644 --- a/devtools/client/netmonitor/test/browser_net_json-malformed.js +++ b/devtools/client/netmonitor/test/browser_net_json-malformed.js @@ -62,7 +62,7 @@ add_task(function* () { is(jsonView.textContent === L10N.getStr("jsonScopeName"), false, "The response json view doesn't have the intended visibility."); is(tabpanel.querySelector(".CodeMirror-code") === null, false, - "The response editor doesn't have the intended visibility."); + "The response editor has the intended visibility."); is(tabpanel.querySelector(".response-image-box") === null, true, "The response image box doesn't have the intended visibility."); diff --git a/devtools/client/netmonitor/test/browser_net_json-null.js b/devtools/client/netmonitor/test/browser_net_json-null.js index 364e48184c28..460faebbcf2e 100644 --- a/devtools/client/netmonitor/test/browser_net_json-null.js +++ b/devtools/client/netmonitor/test/browser_net_json-null.js @@ -27,8 +27,8 @@ add_task(function* () { checkResponsePanelDisplaysJSON(); let tabpanel = document.querySelector("#response-panel"); - is(tabpanel.querySelectorAll(".tree-section").length, 1, - "There should be 1 tree sections displayed in this tabpanel."); + is(tabpanel.querySelectorAll(".tree-section").length, 2, + "There should be 2 tree sections displayed in this tabpanel."); is(tabpanel.querySelectorAll(".treeRow:not(.tree-section)").length, 1, "There should be 1 json properties displayed in this tabpanel."); is(tabpanel.querySelectorAll(".empty-notice").length, 0, @@ -55,8 +55,8 @@ add_task(function* () { let jsonView = panel.querySelector(".tree-section .treeLabel") || {}; is(jsonView.textContent === L10N.getStr("jsonScopeName"), true, "The response json view has the intended visibility."); - is(panel.querySelector(".CodeMirror-code") === null, true, - "The response editor doesn't have the intended visibility."); + is(panel.querySelector(".CodeMirror-code") === null, false, + "The response editor has the intended visibility."); is(panel.querySelector(".response-image-box") === null, true, "The response image box doesn't have the intended visibility."); } @@ -66,7 +66,7 @@ add_task(function* () { * Returns a promise that will resolve when the response panel DOM element is available. */ function openResponsePanel() { - let onReponsePanelReady = waitForDOM(document, "#response-panel"); + let onReponsePanelReady = waitForDOM(document, "#response-panel .CodeMirror-code"); EventUtils.sendMouseEvent({ type: "click" }, document.querySelector(".network-details-panel-toggle")); EventUtils.sendMouseEvent({ type: "click" }, diff --git a/devtools/client/netmonitor/test/browser_net_json_custom_mime.js b/devtools/client/netmonitor/test/browser_net_json_custom_mime.js index 02144d9a27fe..2bcc9097401c 100644 --- a/devtools/client/netmonitor/test/browser_net_json_custom_mime.js +++ b/devtools/client/netmonitor/test/browser_net_json_custom_mime.js @@ -42,7 +42,7 @@ add_task(function* () { time: true }); - wait = waitForDOM(document, "#response-panel"); + wait = waitForDOM(document, "#response-panel .CodeMirror-code"); EventUtils.sendMouseEvent({ type: "click" }, document.querySelector(".network-details-panel-toggle")); EventUtils.sendMouseEvent({ type: "click" }, @@ -61,13 +61,13 @@ add_task(function* () { let jsonView = tabpanel.querySelector(".tree-section .treeLabel") || {}; is(jsonView.textContent === L10N.getStr("jsonScopeName"), true, "The response json view has the intended visibility."); - is(tabpanel.querySelector(".CodeMirror-code") === null, true, - "The response editor doesn't have the intended visibility."); + is(tabpanel.querySelector(".CodeMirror-code") === null, false, + "The response editor has the intended visibility."); is(tabpanel.querySelector(".response-image-box") === null, true, "The response image box doesn't have the intended visibility."); - is(tabpanel.querySelectorAll(".tree-section").length, 1, - "There should be 1 tree sections displayed in this tabpanel."); + is(tabpanel.querySelectorAll(".tree-section").length, 2, + "There should be 2 tree sections displayed in this tabpanel."); is(tabpanel.querySelectorAll(".treeRow:not(.tree-section)").length, 1, "There should be 1 json properties displayed in this tabpanel."); is(tabpanel.querySelectorAll(".empty-notice").length, 0, diff --git a/devtools/client/netmonitor/test/browser_net_json_text_mime.js b/devtools/client/netmonitor/test/browser_net_json_text_mime.js index 45b6492ae2e9..e5c1dd27cf52 100644 --- a/devtools/client/netmonitor/test/browser_net_json_text_mime.js +++ b/devtools/client/netmonitor/test/browser_net_json_text_mime.js @@ -43,7 +43,7 @@ add_task(function* () { time: true }); - wait = waitForDOM(document, "#response-panel"); + wait = waitForDOM(document, "#response-panel .CodeMirror-code"); EventUtils.sendMouseEvent({ type: "click" }, document.querySelector(".network-details-panel-toggle")); EventUtils.sendMouseEvent({ type: "click" }, @@ -62,13 +62,13 @@ add_task(function* () { let jsonView = tabpanel.querySelector(".tree-section .treeLabel") || {}; is(jsonView.textContent === L10N.getStr("jsonScopeName"), true, "The response json view has the intended visibility."); - is(tabpanel.querySelector(".CodeMirror-code") === null, true, - "The response editor doesn't have the intended visibility."); + is(tabpanel.querySelector(".CodeMirror-code") === null, false, + "The response editor has the intended visibility."); is(tabpanel.querySelector(".response-image-box") === null, true, "The response image box doesn't have the intended visibility."); - is(tabpanel.querySelectorAll(".tree-section").length, 1, - "There should be 1 tree sections displayed in this tabpanel."); + is(tabpanel.querySelectorAll(".tree-section").length, 2, + "There should be 2 tree sections displayed in this tabpanel."); is(tabpanel.querySelectorAll(".treeRow:not(.tree-section)").length, 1, "There should be 1 json properties displayed in this tabpanel."); is(tabpanel.querySelectorAll(".empty-notice").length, 0, diff --git a/devtools/client/netmonitor/test/browser_net_jsonp.js b/devtools/client/netmonitor/test/browser_net_jsonp.js index aad0ad1c898b..8ff4243a01cf 100644 --- a/devtools/client/netmonitor/test/browser_net_jsonp.js +++ b/devtools/client/netmonitor/test/browser_net_jsonp.js @@ -57,7 +57,8 @@ add_task(function* () { time: true }); - wait = waitForDOM(document, "#response-panel"); + info("Testing first request"); + wait = waitForDOM(document, "#response-panel .CodeMirror-code"); EventUtils.sendMouseEvent({ type: "click" }, document.querySelector(".network-details-panel-toggle")); EventUtils.sendMouseEvent({ type: "click" }, @@ -66,7 +67,9 @@ add_task(function* () { testResponseTab("$_0123Fun", "Hello JSONP!"); - wait = waitForDOM(document, "#response-panel .tree-section"); + info("Testing second request"); + wait = waitForDOM(document, "#response-panel .CodeMirror-code"); + EventUtils.sendMouseEvent({ type: "mousedown" }, document.querySelectorAll(".request-list-item")[1]); yield wait; @@ -83,13 +86,13 @@ add_task(function* () { is(tabpanel.querySelector(".tree-section .treeLabel").textContent, L10N.getFormatStr("jsonpScopeName", func), "The response json view has the intened visibility and correct title."); - is(tabpanel.querySelector(".CodeMirror-code") === null, true, - "The response editor doesn't have the intended visibility."); + is(tabpanel.querySelector(".CodeMirror-code") === null, false, + "The response editor has the intended visibility."); is(tabpanel.querySelector(".responseImageBox") === null, true, "The response image box doesn't have the intended visibility."); - is(tabpanel.querySelectorAll(".tree-section").length, 1, - "There should be 1 tree sections displayed in this tabpanel."); + is(tabpanel.querySelectorAll(".tree-section").length, 2, + "There should be 2 tree sections displayed in this tabpanel."); is(tabpanel.querySelectorAll(".treeRow:not(.tree-section)").length, 1, "There should be 1 json properties displayed in this tabpanel."); is(tabpanel.querySelectorAll(".empty-notice").length, 0,