Bug 1764717 - Part 10: Use findMessagePart(s)ByType in devtools/client/webconsole/test/browser/. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D147030
This commit is contained in:
Tooru Fujisawa 2022-05-24 10:06:01 +00:00
Родитель 0192380a06
Коммит a287d936ce
5 изменённых файлов: 152 добавлений и 30 удалений

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

@ -35,11 +35,31 @@ add_task(async function() {
const [objectA, objectB] = message.querySelectorAll(
".object-inspector .objectBox-object"
);
const number = findMessage(hud, "100", ".objectBox");
const string = findMessage(hud, "foo", ".objectBox");
const bool = findMessage(hud, "false", ".objectBox");
const nullMessage = findMessage(hud, "null", ".objectBox");
const undefinedMsg = findMessage(hud, "undefined", ".objectBox");
const number = findMessagePartByType(hud, {
text: "100",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
const string = findMessagePartByType(hud, {
text: "foo",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
const bool = findMessagePartByType(hud, {
text: "false",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
const nullMessage = findMessagePartByType(hud, {
text: "null",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
const undefinedMsg = findMessagePartByType(hud, {
text: "undefined",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
info("Showing sidebar for {a:1}");
await showSidebarWithContextMenu(hud, objectA, true);

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

@ -34,25 +34,53 @@ add_task(async function() {
);
const [groupMsgObj] = await waitFor(() =>
findMessages(hud, "group", ".message-body")
findMessagePartsByType(hud, {
text: "group",
typeSelector: ".console-api",
partSelector: ".message-body",
})
);
const [collapsedGroupMsgObj] = await waitFor(() =>
findMessages(hud, "collapsed", ".message-body")
findMessagePartsByType(hud, {
text: "collapsed",
typeSelector: ".console-api",
partSelector: ".message-body",
})
);
const [numberMsgObj] = await waitFor(() =>
findMessages(hud, `532`, ".message-body")
findMessagePartsByType(hud, {
text: `532`,
typeSelector: ".console-api",
partSelector: ".message-body",
})
);
const [trueMsgObj] = await waitFor(() =>
findMessages(hud, `true`, ".message-body")
findMessagePartsByType(hud, {
text: `true`,
typeSelector: ".console-api",
partSelector: ".message-body",
})
);
const [falseMsgObj] = await waitFor(() =>
findMessages(hud, `false`, ".message-body")
findMessagePartsByType(hud, {
text: `false`,
typeSelector: ".console-api",
partSelector: ".message-body",
})
);
const [undefinedMsgObj] = await waitFor(() =>
findMessages(hud, `undefined`, ".message-body")
findMessagePartsByType(hud, {
text: `undefined`,
typeSelector: ".console-api",
partSelector: ".message-body",
})
);
const [nullMsgObj] = await waitFor(() =>
findMessages(hud, `null`, ".message-body")
findMessagePartsByType(hud, {
text: `null`,
typeSelector: ".console-api",
partSelector: ".message-body",
})
);
ok(nullMsgObj, "One message with null value should have appeared");
@ -66,7 +94,11 @@ add_task(async function() {
const nestedObjInMsg = msgNested.querySelector(".objectBox-object");
const consoleMessages = await waitFor(() =>
findMessages(hud, 'console.log("foo");', ".message-location")
findMessagePartsByType(hud, {
text: 'console.log("foo");',
typeSelector: ".console-api",
partSelector: ".message-location",
})
);
await testCopyObjectMenuItemDisabled(hud, consoleMessages[0]);

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

@ -29,11 +29,31 @@ add_task(async function() {
const [objectA, objectB] = message.querySelectorAll(
".object-inspector .objectBox-object"
);
const number = findMessage(hud, "100", ".objectBox");
const string = findMessage(hud, "foo", ".objectBox");
const bool = findMessage(hud, "false", ".objectBox");
const nullMessage = findMessage(hud, "null", ".objectBox");
const undefinedMsg = findMessage(hud, "undefined", ".objectBox");
const number = findMessagePartByType(hud, {
text: "100",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
const string = findMessagePartByType(hud, {
text: "foo",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
const bool = findMessagePartByType(hud, {
text: "false",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
const nullMessage = findMessagePartByType(hud, {
text: "null",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
const undefinedMsg = findMessagePartByType(hud, {
text: "undefined",
typeSelector: ".console-api",
partSelector: ".objectBox",
});
info("Showing sidebar for {a:1}");
await showSidebarWithContextMenu(hud, objectA, true);

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

@ -29,17 +29,33 @@ add_task(async function() {
const msgWithText = await waitFor(() => findConsoleAPIMessage(hud, `foo`));
const msgWithObj = await waitFor(() => findConsoleAPIMessage(hud, `Object`));
const nonDomEl = await waitFor(() =>
findMessage(hud, `<span>`, ".objectBox-node")
findMessagePartByType(hud, {
text: `<span>`,
typeSelector: ".console-api",
partSelector: ".objectBox-node",
})
);
const domEl = await waitFor(() =>
findMessage(hud, `<div>`, ".objectBox-node")
findMessagePartByType(hud, {
text: `<div>`,
typeSelector: ".console-api",
partSelector: ".objectBox-node",
})
);
const domTextEl = await waitFor(() =>
findMessage(hud, `test-text`, ".objectBox-textNode")
findMessagePartByType(hud, {
text: `test-text`,
typeSelector: ".console-api",
partSelector: ".objectBox-textNode",
})
);
const domElCollection = await waitFor(() =>
findMessage(hud, `html`, ".objectBox-node")
findMessagePartByType(hud, {
text: `html`,
typeSelector: ".console-api",
partSelector: ".objectBox-node",
})
);
info("Check `Reveal in Inspector` is not visible for strings");

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

@ -80,8 +80,16 @@ add_task(async function() {
// which is the document url, which also include the logged string...
await waitFor(
() =>
findMessages(hud, "first document load", ".message-body").length === 1 &&
findMessages(hud, "first document show", ".message-body").length === 1
findMessagePartsByType(hud, {
text: "first document load",
typeSelector: ".console-api",
partSelector: ".message-body",
}).length === 1 &&
findMessagePartsByType(hud, {
text: "first document show",
typeSelector: ".console-api",
partSelector: ".message-body",
}).length === 1
);
const firstPageInnerWindowId =
gBrowser.selectedBrowser.browsingContext.currentWindowGlobal.innerWindowId;
@ -96,11 +104,20 @@ add_task(async function() {
"The second page is having a distinct inner window id"
);
await waitFor(
() => findMessages(hud, "second", ".message-body").length === 2
() =>
findMessagePartsByType(hud, {
text: "second",
typeSelector: ".console-api",
partSelector: ".message-body",
}).length === 2
);
ok("Second page message appeared");
is(
findMessages(hud, "first", ".message-body").length,
findMessagePartsByType(hud, {
text: "first",
typeSelector: ".console-api",
partSelector: ".message-body",
}).length,
0,
"First page message disappeared"
);
@ -109,7 +126,12 @@ add_task(async function() {
gBrowser.selectedBrowser.goBack();
// When going pack, the page isn't reloaded, so that we only get the pageshow event
await waitFor(
() => findMessages(hud, "first document show", ".message-body").length === 1
() =>
findMessagePartsByType(hud, {
text: "first document show",
typeSelector: ".console-api",
partSelector: ".message-body",
}).length === 1
);
ok("First page message re-appeared");
is(
@ -118,7 +140,11 @@ add_task(async function() {
"The first page is really a bfcache navigation, keeping the same WindowGlobal"
);
is(
findMessages(hud, "second", ".message-body").length,
findMessagePartsByType(hud, {
text: "second",
typeSelector: ".console-api",
partSelector: ".message-body",
}).length,
0,
"Second page message disappeared"
);
@ -127,7 +153,11 @@ add_task(async function() {
gBrowser.selectedBrowser.goForward();
await waitFor(
() =>
findMessages(hud, "second document show", ".message-body").length === 1
findMessagePartsByType(hud, {
text: "second document show",
typeSelector: ".console-api",
partSelector: ".message-body",
}).length === 1
);
ok("Second page message appeared");
is(
@ -136,7 +166,11 @@ add_task(async function() {
"The second page is really a bfcache navigation, keeping the same WindowGlobal"
);
is(
findMessages(hud, "first", ".message-body").length,
findMessagePartsByType(hud, {
text: "first",
typeSelector: ".console-api",
partSelector: ".message-body",
}).length,
0,
"First page message disappeared"
);