mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 12:15:33 +00:00
Bug 1445963 - Render array payload as array in the params panel; r=nchevobbe
* The patch fixes 'sortObjectKeys' method that caused the reported issue MozReview-Commit-ID: ANg3OCwKCVo --HG-- extra : rebase_source : e12e868f143484070bd36160be444b19db846f9b
This commit is contained in:
parent
6b57896c60
commit
8fe218cbd9
@ -13,6 +13,16 @@ function sortObjectKeys(object) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Array.isArray(object)) {
|
||||
for (let i = 0; i < object.length; i++) {
|
||||
if (typeof object[i] === "object") {
|
||||
object[i] = sortObjectKeys(object[i]);
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
return Object.keys(object).sort(function(left, right) {
|
||||
return left.toLowerCase().localeCompare(right.toLowerCase());
|
||||
}).reduce((acc, key) => {
|
||||
|
@ -27,6 +27,7 @@ support-files =
|
||||
html_params-test-page.html
|
||||
html_pause-test-page.html
|
||||
html_post-data-test-page.html
|
||||
html_post-array-data-test-page.html
|
||||
html_post-json-test-page.html
|
||||
html_post-raw-test-page.html
|
||||
html_post-raw-with-headers-test-page.html
|
||||
|
@ -6,9 +6,8 @@
|
||||
/**
|
||||
* Tests whether keys in Params panel are sorted.
|
||||
*/
|
||||
|
||||
add_task(async function() {
|
||||
let { tab, monitor } = await initNetMonitor(POST_DATA_URL);
|
||||
let { tab, monitor } = await initNetMonitor(POST_ARRAY_DATA_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
let { document, store, windowRequire } = monitor.panelWin;
|
||||
@ -16,7 +15,7 @@ add_task(async function() {
|
||||
|
||||
store.dispatch(Actions.batchEnable(false));
|
||||
|
||||
let wait = waitForNetworkEvents(monitor, 2);
|
||||
let wait = waitForNetworkEvents(monitor, 1);
|
||||
await ContentTask.spawn(tab.linkedBrowser, {}, async function() {
|
||||
content.wrappedJSObject.performRequests();
|
||||
});
|
||||
@ -30,9 +29,38 @@ add_task(async function() {
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
document.querySelector("#params-tab"));
|
||||
|
||||
let actualKeys = document.querySelectorAll(".treeLabel");
|
||||
let expectedKeys = ["Query string", "baz", "foo", "type",
|
||||
"Form data", "baz", "foo"];
|
||||
// The Params panel should render the following
|
||||
// POSTed JSON data structure:
|
||||
//
|
||||
// ▼ JSON
|
||||
// ▼ watches: […]
|
||||
// 0: hello
|
||||
// 1: how
|
||||
// 2: are
|
||||
// 3: you
|
||||
// ▼ 4: {…}
|
||||
// a: 10
|
||||
// ▼ b: […]
|
||||
// 0: "a"
|
||||
// 1: "c"
|
||||
// 2: "b"
|
||||
// c: 15
|
||||
let actualKeys = document.querySelectorAll(".treeTable .treeRow");
|
||||
let expectedKeys = [
|
||||
"JSON",
|
||||
"watches: [...]",
|
||||
"0: hello",
|
||||
"1: how",
|
||||
"2: are",
|
||||
"3: you",
|
||||
"4: {...}",
|
||||
"a: 10",
|
||||
"b: [...]",
|
||||
"0: a",
|
||||
"1: c",
|
||||
"2: b",
|
||||
"c: 15",
|
||||
];
|
||||
|
||||
for (let i = 0; i < actualKeys.length; i++) {
|
||||
is(actualKeys[i].innerText, expectedKeys[i],
|
||||
|
@ -40,6 +40,7 @@ const CONTENT_TYPE_WITHOUT_CACHE_REQUESTS = 8;
|
||||
const CYRILLIC_URL = EXAMPLE_URL + "html_cyrillic-test-page.html";
|
||||
const STATUS_CODES_URL = EXAMPLE_URL + "html_status-codes-test-page.html";
|
||||
const POST_DATA_URL = EXAMPLE_URL + "html_post-data-test-page.html";
|
||||
const POST_ARRAY_DATA_URL = EXAMPLE_URL + "html_post-array-data-test-page.html";
|
||||
const POST_JSON_URL = EXAMPLE_URL + "html_post-json-test-page.html";
|
||||
const POST_RAW_URL = EXAMPLE_URL + "html_post-raw-test-page.html";
|
||||
const POST_RAW_WITH_HEADERS_URL = EXAMPLE_URL + "html_post-raw-with-headers-test-page.html";
|
||||
|
@ -0,0 +1,34 @@
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
<title>Network Monitor test page</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
/* exported performRequests */
|
||||
"use strict";
|
||||
|
||||
function performRequests() {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "sjs_simple-test-server.sjs", true);
|
||||
|
||||
let postData = JSON.stringify({
|
||||
watches: ["hello", "how", "are", "you", {
|
||||
a: 10,
|
||||
c: 15,
|
||||
b: ["a", "c", "b"]
|
||||
}],
|
||||
});
|
||||
xhr.send(postData);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user