Bug 1481732 - Fixed netmonitor request parameter parsing so equals signs are not removed from value field. r=Honza

This commit is contained in:
tossj 2018-08-23 13:34:39 -04:00
Родитель cb1b9f3b61
Коммит cb05f4c980
3 изменённых файлов: 62 добавлений и 2 удалений

Просмотреть файл

@ -307,7 +307,7 @@ function parseQueryString(query) {
const param = e.split("=");
return {
name: param[0] ? getUnicodeUrlPath(param[0]) : "",
value: param[1] ? getUnicodeUrlPath(param[1]) : "",
value: param[1] ? getUnicodeUrlPath(param.slice(1).join("=")) : "",
};
});
}

Просмотреть файл

@ -19,7 +19,7 @@ add_task(async function() {
store.dispatch(Actions.batchEnable(false));
// Execute requests.
await performRequests(monitor, tab, 7);
await performRequests(monitor, tab, 10);
wait = waitForDOM(document, "#params-panel .tree-section", 2);
EventUtils.sendMouseEvent({ type: "mousedown" },
@ -65,6 +65,26 @@ add_task(async function() {
document.querySelectorAll(".request-list-item")[6]);
testParamsTab3();
wait = waitForDOM(document, "#params-panel .tree-section", 2);
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll(".request-list-item")[7]);
await wait;
testParamsTab1("a", "b", '{ "foo": "bar" }', "");
wait = waitForDOM(document, "#params-panel .tree-section", 2);
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll(".request-list-item")[8]);
await wait;
testParamsTab1("a", "b", '{ "foo": "bar" }', "");
wait = waitForDOM(document, "#params-panel .tree-section", 1);
EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelectorAll(".request-list-item")[9]);
await wait;
testParamsTabGetWithArgs(new Map([
["species", "in=(52,60)"],
]));
await teardown(monitor);
function testParamsTab1(queryStringParamName, queryStringParamValue,
@ -176,4 +196,43 @@ add_task(async function() {
ok(!tabpanel.querySelector(".CodeMirror-code"),
"The request post data editor should be hidden.");
}
/**
* @param {Map} expectedParams A map of expected parameter keys and values
* as Strings.
*/
function testParamsTabGetWithArgs(expectedParams) {
const tabpanel = document.querySelector("#params-panel");
is(tabpanel.querySelectorAll(".tree-section").length, 1,
"Check the number of param tree sections displayed in this tabpanel.");
is(tabpanel.querySelectorAll("tr:not(.tree-section).treeRow").length, 1,
"Check the number of param rows displayed in this tabpanel.");
ok(!tabpanel.querySelector(".empty-notice"),
"The empty notice should not be displayed in this tabpanel.");
ok(tabpanel.querySelector(".treeTable"),
"The request params box should be shown.");
ok(!tabpanel.querySelector(".CodeMirror-code"),
"The request post data editor should be hidden.");
const treeSections = tabpanel.querySelectorAll(".tree-section");
const labels = tabpanel
.querySelectorAll("tr:not(.tree-section) .treeLabelCell .treeLabel");
const values = tabpanel
.querySelectorAll("tr:not(.tree-section) .treeValueCell .objectBox");
is(treeSections[0].querySelector(".treeLabel").textContent,
L10N.getStr("paramsQueryString"),
"Check the displayed params section title.");
const labelsIter = labels.values();
const valuesIter = values.values();
for (const [expKey, expValue] of expectedParams) {
const label = labelsIter.next().value;
const value = valuesIter.next().value;
is(label.textContent, expKey, "Check that parameter name matches.");
is(value.textContent, expValue, "Check that parameter value matches.");
}
}
});

Просмотреть файл

@ -68,6 +68,7 @@
await get("baz", "");
await patch("baz", "?a=b", urlencoded, '{ "foo": "bar" }');
await put("baz", "?a=b", urlencoded, '{ "foo": "bar" }');
await get("baz", "?species=in=(52,60)");
}
</script>
</body>