зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1474207 - Network Monitor response payload testing method variances. r=Honza
Changed the way we to access contents of `.CodeMirror`, by using `CodeMirror.getValue()` instead of `.textContent` Differential Revision: https://phabricator.services.mozilla.com/D22079 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
712dd2bb8c
Коммит
84c187d1fe
|
@ -60,7 +60,7 @@ add_task(async function() {
|
|||
function testResponse(type) {
|
||||
switch (type) {
|
||||
case "br": {
|
||||
is(document.querySelector(".CodeMirror-line").textContent, "X".repeat(64),
|
||||
is(getCodeMirrorValue(monitor), "X".repeat(64),
|
||||
"The text shown in the source editor is incorrect for the brotli request.");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ add_task(async function() {
|
|||
is(values[0].textContent, queryStringParamValue,
|
||||
"The first query string param value was incorrect.");
|
||||
|
||||
ok(tabpanel.querySelector(".CodeMirror-code").textContent.includes(requestPayload),
|
||||
ok(getCodeMirrorValue(monitor).includes(requestPayload),
|
||||
"The text shown in the source editor is incorrect.");
|
||||
|
||||
if (isJSON) {
|
||||
|
|
|
@ -185,7 +185,7 @@ add_task(async function() {
|
|||
case "xml": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
const text = document.querySelector(".CodeMirror-line").textContent;
|
||||
const text = getCodeMirrorValue(monitor);
|
||||
|
||||
is(text, "<label value='greeting'>Hello XML!</label>",
|
||||
"The text shown in the source editor is incorrect for the xml request.");
|
||||
|
@ -194,7 +194,7 @@ add_task(async function() {
|
|||
case "css": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
const text = document.querySelector(".CodeMirror-line").textContent;
|
||||
const text = getCodeMirrorValue(monitor);
|
||||
|
||||
is(text, "body:pre { content: 'Hello CSS!' }",
|
||||
"The text shown in the source editor is incorrect for the css request.");
|
||||
|
@ -203,7 +203,7 @@ add_task(async function() {
|
|||
case "js": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
const text = document.querySelector(".CodeMirror-line").textContent;
|
||||
const text = getCodeMirrorValue(monitor);
|
||||
|
||||
is(text, "function() { return 'Hello JS!'; }",
|
||||
"The text shown in the source editor is incorrect for the js request.");
|
||||
|
@ -235,7 +235,7 @@ add_task(async function() {
|
|||
case "html": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
const text = document.querySelector(".CodeMirror-line").textContent;
|
||||
const text = getCodeMirrorValue(monitor);
|
||||
|
||||
is(text, "<blink>Not Found</blink>",
|
||||
"The text shown in the source editor is incorrect for the html request.");
|
||||
|
@ -258,7 +258,7 @@ add_task(async function() {
|
|||
case "gzip": {
|
||||
checkVisibility("textarea");
|
||||
|
||||
const text = document.querySelector(".CodeMirror-line").textContent;
|
||||
const text = getCodeMirrorValue(monitor);
|
||||
|
||||
is(text, new Array(1000).join("Hello gzip!"),
|
||||
"The text shown in the source editor is incorrect for the gzip request.");
|
||||
|
|
|
@ -49,9 +49,8 @@ add_task(async function() {
|
|||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
document.querySelector("#response-tab"));
|
||||
await wait;
|
||||
const text = document.querySelector(".CodeMirror-line").textContent;
|
||||
|
||||
ok(text.includes("\u0411\u0440\u0430\u0442\u0430\u043d"),
|
||||
ok(getCodeMirrorValue(monitor).includes("\u0411\u0440\u0430\u0442\u0430\u043d"),
|
||||
"The text shown in the source editor is correct.");
|
||||
|
||||
return teardown(monitor);
|
||||
|
|
|
@ -67,8 +67,7 @@ add_task(async function() {
|
|||
is(tabpanel.querySelector(".response-image-box") === null, true,
|
||||
"The response image box doesn't have the intended visibility.");
|
||||
|
||||
is(document.querySelector(".CodeMirror-line").textContent,
|
||||
"{ \"greeting\": \"Hello malformed JSON!\" },",
|
||||
is(getCodeMirrorValue(monitor), "{ \"greeting\": \"Hello malformed JSON!\" },",
|
||||
"The text shown in the source editor is incorrect.");
|
||||
|
||||
await teardown(monitor);
|
||||
|
|
|
@ -55,9 +55,8 @@ add_task(async function() {
|
|||
document.querySelector("#response-tab"));
|
||||
await wait;
|
||||
|
||||
const text = document.querySelector(".CodeMirror-line").textContent;
|
||||
|
||||
ok(text.match(/^<p>/), "The text shown in the source editor is incorrect.");
|
||||
ok(getCodeMirrorValue(monitor).match(/^<p>/),
|
||||
"The text shown in the source editor is incorrect.");
|
||||
|
||||
await teardown(monitor);
|
||||
|
||||
|
|
|
@ -136,13 +136,7 @@ add_task(async function() {
|
|||
|
||||
is(labels.length, 3, "There should be 3 param values displayed in this tabpanel.");
|
||||
|
||||
// Collect code lines and combine into one text for checking
|
||||
let text = "";
|
||||
const lines = [...document.querySelectorAll(".CodeMirror-line")];
|
||||
|
||||
lines.forEach((line) => {
|
||||
text += line.textContent + "\n";
|
||||
});
|
||||
const text = getCodeMirrorValue(monitor);
|
||||
|
||||
ok(text.includes("Content-Disposition: form-data; name=\"text\""),
|
||||
"The text shown in the source editor is incorrect (1.1).");
|
||||
|
|
|
@ -57,7 +57,7 @@ add_task(async function() {
|
|||
is(labels[0].textContent, "a", "The JSON var name was incorrect.");
|
||||
is(values[0].textContent, "1", "The JSON var value was incorrect.");
|
||||
|
||||
ok(tabpanel.querySelector(".CodeMirror-code").textContent.includes('{"a":1}'),
|
||||
ok(getCodeMirrorValue(monitor).includes('{"a":1}'),
|
||||
"The text shown in the source editor is incorrect.");
|
||||
|
||||
return teardown(monitor);
|
||||
|
|
|
@ -75,7 +75,7 @@ add_task(async function() {
|
|||
return teardown(monitor);
|
||||
|
||||
function testEditorContent([ fmt, textRe ]) {
|
||||
ok(document.querySelector(".CodeMirror-line").textContent.match(textRe),
|
||||
ok(getCodeMirrorValue(monitor).match(textRe),
|
||||
"The text shown in the source editor for " + fmt + " is correct.");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -767,6 +767,14 @@ async function performRequests(monitor, tab, count) {
|
|||
await wait;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for retrieving `.CodeMirror` content
|
||||
*/
|
||||
function getCodeMirrorValue(monitor) {
|
||||
const document = monitor.panelWin.document;
|
||||
return document.querySelector(".CodeMirror").CodeMirror.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for lazy fields to be loaded in a request.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче