Bug 1427006 - Enhanced the browser_webconsole_console_group test; r=nchevobbe

MozReview-Commit-ID: Efe5xb8sq7C

--HG--
extra : rebase_source : c9bc62bfe98166f3907143099a7a58a42dfc03ff
This commit is contained in:
abhinav 2017-12-15 00:39:34 +05:30
Родитель 1a33f28694
Коммит af5f219381
1 изменённых файлов: 61 добавлений и 8 удалений

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

@ -31,46 +31,70 @@ add_task(async function () {
info("messages : " + JSON.stringify(messages));
});
const onMessagesLogged = waitForMessage(hud, "log-6");
ContentTask.spawn(gBrowser.selectedBrowser, null, function () {
content.wrappedJSObject.doLog();
});
await onMessagesLogged;
info("Test a group at root level");
let node = await waitFor(() => findMessage(hud, "group-1"));
let node = findMessage(hud, "group-1");
testClass(node, "startGroup");
testIndent(node, 0);
await testGroupToggle({
node,
store,
shouldBeOpen: true,
visibleMessageIdsAfterExpand: ["1","2","3","4","6","8","9","12"],
visibleMessageIdsAfterCollapse: ["1","8","9","12"],
});
info("Test a message in a 1 level deep group");
node = await waitFor(() => findMessage(hud, "log-1"), undefined, 200);
node = findMessage(hud, "log-1");
testClass(node, "log");
testIndent(node, 1);
info("Test a group in a 1 level deep group");
node = await waitFor(() => findMessage(hud, "group-2"));
node = findMessage(hud, "group-2");
testClass(node, "startGroup");
testIndent(node, 1);
await testGroupToggle({
node,
store,
shouldBeOpen: true,
visibleMessageIdsAfterExpand: ["1","2","3","4","6","8","9","12"],
visibleMessageIdsAfterCollapse: ["1","2","3","6","8","9","12"],
});
info("Test a message in a 2 level deep group");
node = await waitFor(() => findMessage(hud, "log-2"));
node = findMessage(hud, "log-2");
testClass(node, "log");
testIndent(node, 2);
info("Test a message in a 1 level deep group, after closing a 2 level deep group");
node = await waitFor(() => findMessage(hud, "log-3"));
node = findMessage(hud, "log-3");
testClass(node, "log");
testIndent(node, 1);
info("Test a message at root level, after closing all the groups");
node = await waitFor(() => findMessage(hud, "log-4"));
node = findMessage(hud, "log-4");
testClass(node, "log");
testIndent(node, 0);
info("Test a collapsed group at root level");
node = await waitFor(() => findMessage(hud, "group-3"));
node = findMessage(hud, "group-3");
testClass(node, "startGroupCollapsed");
testIndent(node, 0);
await testGroupToggle({
node,
store,
shouldBeOpen: false,
visibleMessageIdsAfterExpand: ["1","2","3","4","6","8","9","10","12"],
visibleMessageIdsAfterCollapse: ["1","2","3","4","6","8","9","12"]
});
info("Test a message at root level, after closing a collapsed group");
node = await waitFor(() => findMessage(hud, "log-6"));
node = findMessage(hud, "log-6");
testClass(node, "log");
testIndent(node, 0);
let nodes = hud.ui.outputNode.querySelectorAll(".message");
@ -86,3 +110,32 @@ function testIndent(node, indent) {
is(node.querySelector(".indent").style.width, indent,
"message has the expected level of indentation");
}
async function testGroupToggle({
node,
store,
shouldBeOpen,
visibleMessageIdsAfterExpand,
visibleMessageIdsAfterCollapse
}) {
let toggleArrow = node.querySelector(".theme-twisty");
const isOpen = node => node.classList.contains("open");
const assertVisibleMessageIds = (expanded) => {
let visibleMessageIds = store.getState().messages.visibleMessages;
expanded ? is(visibleMessageIds.toString(), visibleMessageIdsAfterExpand.toString()) :
is(visibleMessageIds.toString(), visibleMessageIdsAfterCollapse.toString());
}
await waitFor(() => isOpen(node) === shouldBeOpen)
assertVisibleMessageIds(shouldBeOpen);
toggleArrow.click();
shouldBeOpen = !shouldBeOpen;
await waitFor(() => isOpen(node) === shouldBeOpen)
assertVisibleMessageIds(shouldBeOpen);
toggleArrow.click();
shouldBeOpen = !shouldBeOpen;
await waitFor(() => isOpen(node) === shouldBeOpen)
assertVisibleMessageIds(shouldBeOpen);
}