зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1764717 - Part 4: Use type-specific findMessage(s) in devtools/client/webconsole/test/browser/browser_console_*. r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D147024
This commit is contained in:
Родитель
0ca8c52ae8
Коммит
1a8bd8c676
|
@ -27,9 +27,11 @@ add_task(async function() {
|
|||
execute(hud, `Cu.reportError("Cu.reportError");`); // bug 1561930
|
||||
info("Wait for expected message are shown on browser console");
|
||||
await waitFor(() =>
|
||||
expectedMessages.every(expectedMessage => findMessage(hud, expectedMessage))
|
||||
expectedMessages.every(expectedMessage =>
|
||||
findErrorMessage(hud, expectedMessage)
|
||||
)
|
||||
);
|
||||
await waitFor(() => findMessage(hud, "hello from content"));
|
||||
await waitFor(() => findConsoleAPIMessage(hud, "hello from content"));
|
||||
|
||||
ok(true, "Expected messages are displayed in the browser console");
|
||||
|
||||
|
@ -38,12 +40,12 @@ add_task(async function() {
|
|||
hud,
|
||||
".webconsole-console-settings-menu-item-contentMessages"
|
||||
);
|
||||
await waitFor(() => !findMessage(hud, "hello from content"));
|
||||
await waitFor(() => !findConsoleAPIMessage(hud, "hello from content"));
|
||||
|
||||
info("Check the expected messages are still visiable in the browser console");
|
||||
for (const expectedMessage of expectedMessages) {
|
||||
ok(
|
||||
findMessage(hud, expectedMessage),
|
||||
findErrorMessage(hud, expectedMessage),
|
||||
`"${expectedMessage}" should be still visible`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ add_task(async function() {
|
|||
|
||||
info("Click the clear output button");
|
||||
const onBrowserConsoleOutputCleared = waitFor(
|
||||
() => !findMessage(hud, CACHED_MESSAGE)
|
||||
() => !findConsoleAPIMessage(hud, CACHED_MESSAGE)
|
||||
);
|
||||
hud.ui.window.document.querySelector(".devtools-clear-icon").click();
|
||||
await onBrowserConsoleOutputCleared;
|
||||
|
@ -42,7 +42,7 @@ add_task(async function() {
|
|||
info("Log a smoke message in order to know that the console is ready");
|
||||
await logTextInContentAndWaitForMessage(hud, "Smoke message");
|
||||
is(
|
||||
findMessage(hud, CACHED_MESSAGE),
|
||||
findConsoleAPIMessage(hud, CACHED_MESSAGE),
|
||||
undefined,
|
||||
"The cached message is not visible anymore"
|
||||
);
|
||||
|
|
|
@ -27,7 +27,7 @@ add_task(async function() {
|
|||
content.console.log({ hello: "world" });
|
||||
});
|
||||
|
||||
await waitFor(() => findMessage(hud, "hello"));
|
||||
await waitFor(() => findConsoleAPIMessage(hud, "hello"));
|
||||
|
||||
await removeTab(tab);
|
||||
// Wait for a bit, so the actors and fronts are released.
|
||||
|
@ -36,6 +36,6 @@ add_task(async function() {
|
|||
info("Clear the console output");
|
||||
hud.ui.outputNode.querySelector(".devtools-clear-icon").click();
|
||||
|
||||
await waitFor(() => !findMessage(hud, "hello"));
|
||||
await waitFor(() => !findConsoleAPIMessage(hud, "hello"));
|
||||
ok(true, "Browser Console was cleared");
|
||||
});
|
||||
|
|
|
@ -125,12 +125,12 @@ add_task(async function testProfile() {
|
|||
|
||||
async function checkMessageExists(hud, msg) {
|
||||
info(`Checking "${msg}" was logged`);
|
||||
const message = await waitFor(() => findMessage(hud, msg));
|
||||
const message = await waitFor(() => findConsoleAPIMessage(hud, msg));
|
||||
ok(message, `"${msg}" was logged`);
|
||||
}
|
||||
|
||||
async function checkMessageHidden(hud, msg) {
|
||||
info(`Checking "${msg}" was not logged`);
|
||||
await waitFor(() => findMessage(hud, msg) == null);
|
||||
await waitFor(() => findConsoleAPIMessage(hud, msg) == null);
|
||||
ok(true, `"${msg}" was not logged`);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ add_task(async function() {
|
|||
);
|
||||
});
|
||||
|
||||
const node = await waitFor(() => findMessage(hud, "oi-test"));
|
||||
const node = await waitFor(() => findConsoleAPIMessage(hud, "oi-test"));
|
||||
const oi = node.querySelector(".tree");
|
||||
|
||||
expandObjectInspectorNode(oi);
|
||||
|
|
|
@ -36,7 +36,7 @@ add_task(async function() {
|
|||
|
||||
info("wait for long string expansion");
|
||||
const onLongStringFullTextDisplayed = waitFor(() =>
|
||||
findMessage(hud, LONGSTRING)
|
||||
findConsoleAPIMessage(hud, LONGSTRING)
|
||||
);
|
||||
arrow.click();
|
||||
await onLongStringFullTextDisplayed;
|
||||
|
@ -44,7 +44,9 @@ add_task(async function() {
|
|||
ok(true, "The full text of the longString is displayed");
|
||||
|
||||
info("wait for long string collapse");
|
||||
const onLongStringCollapsed = waitFor(() => !findMessage(hud, LONGSTRING));
|
||||
const onLongStringCollapsed = waitFor(
|
||||
() => !findConsoleAPIMessage(hud, LONGSTRING)
|
||||
);
|
||||
arrow.click();
|
||||
await onLongStringCollapsed;
|
||||
|
||||
|
|
|
@ -23,7 +23,10 @@ add_task(async function() {
|
|||
|
||||
info("Wait until the content object is displayed");
|
||||
let objectMessage = await waitFor(() =>
|
||||
findMessage(hud, `Object { contentObject: "YAY!", deep: (1) […] }`)
|
||||
findConsoleAPIMessage(
|
||||
hud,
|
||||
`Object { contentObject: "YAY!", deep: (1) […] }`
|
||||
)
|
||||
);
|
||||
ok(true, "Content object is displayed in the Browser Console");
|
||||
|
||||
|
@ -35,7 +38,10 @@ add_task(async function() {
|
|||
|
||||
info("Wait until the content object is displayed");
|
||||
objectMessage = await waitFor(() =>
|
||||
findMessage(hud, `Object { contentObject: "YAY!", deep: (1) […] }`)
|
||||
findConsoleAPIMessage(
|
||||
hud,
|
||||
`Object { contentObject: "YAY!", deep: (1) […] }`
|
||||
)
|
||||
);
|
||||
ok(true, "Content object is displayed in the Browser Console after restart");
|
||||
|
||||
|
|
|
@ -26,7 +26,10 @@ add_task(async function() {
|
|||
|
||||
info("Wait until the content object is displayed");
|
||||
const objectMessage = await waitFor(() =>
|
||||
findMessage(hud, `Object { contentObject: "YAY!", deep: (2) […] }`)
|
||||
findConsoleAPIMessage(
|
||||
hud,
|
||||
`Object { contentObject: "YAY!", deep: (2) […] }`
|
||||
)
|
||||
);
|
||||
ok(true, "Content object is displayed in the Browser Console");
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ add_task(async function() {
|
|||
info("Open the Browser Console");
|
||||
const hud = await BrowserConsoleManager.toggleBrowserConsole();
|
||||
|
||||
const message = await waitFor(() => findMessage(hud, "foo"));
|
||||
const message = await waitFor(() => findConsoleAPIMessage(hud, "foo"));
|
||||
const [objectA, objectB] = message.querySelectorAll(
|
||||
".object-inspector .objectBox-object"
|
||||
);
|
||||
|
|
|
@ -39,7 +39,7 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
const msg = await waitFor(() =>
|
||||
findMessage(bcHud, "TypeError: this._toolPanels is not iterable")
|
||||
findErrorMessage(bcHud, "TypeError: this._toolPanels is not iterable")
|
||||
);
|
||||
|
||||
fixToolbox();
|
||||
|
|
|
@ -36,7 +36,7 @@ add_task(async function() {
|
|||
const messageText = "ReferenceError: foobar is not defined";
|
||||
|
||||
const msg = await waitFor(
|
||||
() => findMessage(hud, messageText),
|
||||
() => findErrorMessage(hud, messageText),
|
||||
`Message "${messageText}" wasn't found`
|
||||
);
|
||||
ok(msg, `Message found: "${messageText}"`);
|
||||
|
|
|
@ -37,13 +37,13 @@ add_task(async function() {
|
|||
);
|
||||
|
||||
const beforeCreateXUL = await waitFor(() =>
|
||||
findMessage(hud, "before createXULElement", ".console-api")
|
||||
findConsoleAPIMessage(hud, "before createXULElement")
|
||||
);
|
||||
const afterCreateXUL = await waitFor(() =>
|
||||
findMessage(hud, "after createXULElement", ".console-api")
|
||||
findConsoleAPIMessage(hud, "after createXULElement")
|
||||
);
|
||||
const inMicroTask = await waitFor(() =>
|
||||
findMessage(hud, "in microtask", ".console-api")
|
||||
findConsoleAPIMessage(hud, "in microtask")
|
||||
);
|
||||
|
||||
const getMessageIndex = msg => {
|
||||
|
|
|
@ -54,12 +54,14 @@ add_task(async function() {
|
|||
hud = await BrowserConsoleManager.toggleBrowserConsole();
|
||||
ok(hud, "browser console opened");
|
||||
|
||||
await waitFor(() => findMessage(hud, "cachedBrowserConsoleMessage"));
|
||||
await waitFor(() =>
|
||||
findConsoleAPIMessage(hud, "cachedBrowserConsoleMessage")
|
||||
);
|
||||
Services.console.logStringMessage("liveBrowserConsoleMessage2");
|
||||
await waitFor(() => findMessage(hud, "liveBrowserConsoleMessage2"));
|
||||
await waitFor(() => findConsoleAPIMessage(hud, "liveBrowserConsoleMessage2"));
|
||||
|
||||
const msg = await waitFor(() =>
|
||||
findMessage(hud, "liveBrowserConsoleMessage")
|
||||
findConsoleAPIMessage(hud, "liveBrowserConsoleMessage")
|
||||
);
|
||||
ok(msg, "message element for liveBrowserConsoleMessage (nsIConsoleMessage)");
|
||||
|
||||
|
@ -70,13 +72,14 @@ add_task(async function() {
|
|||
|
||||
// And then checking that the log messages are hidden.
|
||||
await waitFor(
|
||||
() => findMessages(hud, "cachedBrowserConsoleMessage").length === 0
|
||||
() =>
|
||||
findConsoleAPIMessages(hud, "cachedBrowserConsoleMessage").length === 0
|
||||
);
|
||||
await waitFor(
|
||||
() => findMessages(hud, "liveBrowserConsoleMessage").length === 0
|
||||
() => findConsoleAPIMessages(hud, "liveBrowserConsoleMessage").length === 0
|
||||
);
|
||||
await waitFor(
|
||||
() => findMessages(hud, "liveBrowserConsoleMessage2").length === 0
|
||||
() => findConsoleAPIMessages(hud, "liveBrowserConsoleMessage2").length === 0
|
||||
);
|
||||
|
||||
resetFilters(hud);
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(async function() {
|
|||
|
||||
info("Emit a log message to display it in the Browser Console");
|
||||
console.log(TEST_MESSAGE);
|
||||
await waitFor(() => findMessage(hud, TEST_MESSAGE));
|
||||
await waitFor(() => findConsoleAPIMessage(hud, TEST_MESSAGE));
|
||||
|
||||
let currWindow = Services.wm.getMostRecentWindow(null);
|
||||
is(
|
||||
|
|
|
@ -88,7 +88,7 @@ async function checkContentConsoleApiMessages(nonPrimitiveVariablesDisplayed) {
|
|||
await waitFor(
|
||||
() =>
|
||||
expectedMessages.every(expectedMessage =>
|
||||
findMessage(hud, expectedMessage)
|
||||
findConsoleAPIMessage(hud, expectedMessage)
|
||||
),
|
||||
"wait for all the messages to be displayed",
|
||||
100
|
||||
|
@ -96,7 +96,11 @@ async function checkContentConsoleApiMessages(nonPrimitiveVariablesDisplayed) {
|
|||
ok(true, "Expected messages are displayed in the browser console");
|
||||
|
||||
if (nonPrimitiveVariablesDisplayed) {
|
||||
const tableMessage = findMessage(hud, "console.table()", ".message.table");
|
||||
const tableMessage = findConsoleAPIMessage(
|
||||
hud,
|
||||
"console.table()",
|
||||
".table"
|
||||
);
|
||||
|
||||
const table = await waitFor(() =>
|
||||
tableMessage.querySelector(".consoletable")
|
||||
|
@ -113,7 +117,7 @@ async function checkContentConsoleApiMessages(nonPrimitiveVariablesDisplayed) {
|
|||
|
||||
info("Uncheck the Show content messages checkbox");
|
||||
const onContentMessagesHidden = waitFor(
|
||||
() => !findMessage(hud, contentArgs.log)
|
||||
() => !findConsoleAPIMessage(hud, contentArgs.log)
|
||||
);
|
||||
await toggleConsoleSetting(
|
||||
hud,
|
||||
|
@ -122,12 +126,17 @@ async function checkContentConsoleApiMessages(nonPrimitiveVariablesDisplayed) {
|
|||
await onContentMessagesHidden;
|
||||
|
||||
for (const expectedMessage of expectedMessages) {
|
||||
ok(!findMessage(hud, expectedMessage), `"${expectedMessage}" is hidden`);
|
||||
ok(
|
||||
!findConsoleAPIMessage(hud, expectedMessage),
|
||||
`"${expectedMessage}" is hidden`
|
||||
);
|
||||
}
|
||||
|
||||
info("Check the Show content messages checkbox");
|
||||
const onContentMessagesDisplayed = waitFor(() =>
|
||||
expectedMessages.every(expectedMessage => findMessage(hud, expectedMessage))
|
||||
expectedMessages.every(expectedMessage =>
|
||||
findConsoleAPIMessage(hud, expectedMessage)
|
||||
)
|
||||
);
|
||||
await toggleConsoleSetting(
|
||||
hud,
|
||||
|
@ -136,7 +145,10 @@ async function checkContentConsoleApiMessages(nonPrimitiveVariablesDisplayed) {
|
|||
await onContentMessagesDisplayed;
|
||||
|
||||
for (const expectedMessage of expectedMessages) {
|
||||
ok(findMessage(hud, expectedMessage), `"${expectedMessage}" is visible`);
|
||||
ok(
|
||||
findConsoleAPIMessage(hud, expectedMessage),
|
||||
`"${expectedMessage}" is visible`
|
||||
);
|
||||
}
|
||||
|
||||
info("Clear and close the Browser Console");
|
||||
|
|
|
@ -10,7 +10,12 @@ const TEST_URI =
|
|||
"http://example.com/browser/devtools/client/webconsole/" +
|
||||
"test/browser/test-console-iframes.html";
|
||||
|
||||
const expectedMessages = ["main file", "blah", "iframe 2", "iframe 3"];
|
||||
const expectedMessages = [
|
||||
["main file", ".console-api"],
|
||||
["blah", ".error"],
|
||||
["iframe 2", ".console-api"],
|
||||
["iframe 3", ".console-api"],
|
||||
];
|
||||
|
||||
// This log comes from test-iframe1.html, which is included from test-console-iframes.html
|
||||
// __and__ from test-iframe3.html as well, so we should see it twice.
|
||||
|
@ -44,13 +49,15 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
async function testMessages(hud) {
|
||||
for (const message of expectedMessages) {
|
||||
for (const [message, selector] of expectedMessages) {
|
||||
info(`checking that the message "${message}" exists`);
|
||||
await waitFor(() => findMessage(hud, message));
|
||||
await waitFor(() => findMessageByType(hud, message, selector));
|
||||
}
|
||||
|
||||
ok(true, "Found expected unique messages");
|
||||
|
||||
await waitFor(() => findMessages(hud, expectedDupedMessage).length == 2);
|
||||
await waitFor(
|
||||
() => findConsoleAPIMessages(hud, expectedDupedMessage).length == 2
|
||||
);
|
||||
ok(true, `${expectedDupedMessage} is present twice`);
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ async function testBrowserConsole(publicTab) {
|
|||
hud = await openConsole(privateTab);
|
||||
ok(hud, "web console reopened");
|
||||
|
||||
await waitFor(() => findMessage(hud, PRIVATE_MESSAGE));
|
||||
await waitFor(() => findMessage(hud, PRIVATE_EXCEPTION, ".message.error"));
|
||||
await waitFor(() => findConsoleAPIMessage(hud, PRIVATE_MESSAGE));
|
||||
await waitFor(() => findErrorMessage(hud, PRIVATE_EXCEPTION));
|
||||
ok(
|
||||
true,
|
||||
"Messages are still displayed after closing and reopening the console"
|
||||
|
@ -144,7 +144,7 @@ async function testBrowserConsole(publicTab) {
|
|||
await onPrivateMessagesCleared;
|
||||
|
||||
ok(
|
||||
findMessage(hud, NON_PRIVATE_MESSAGE),
|
||||
findConsoleAPIMessage(hud, NON_PRIVATE_MESSAGE),
|
||||
"non-private messages are still shown after private window closed"
|
||||
);
|
||||
assertNoPrivateMessages(hud);
|
||||
|
@ -168,12 +168,12 @@ function logPrivateMessages(browser) {
|
|||
|
||||
function assertNoPrivateMessages(hud) {
|
||||
is(
|
||||
findMessage(hud, PRIVATE_MESSAGE, ".message:not(.error)")?.textContent,
|
||||
findConsoleAPIMessage(hud, PRIVATE_MESSAGE, ":not(.error)")?.textContent,
|
||||
undefined,
|
||||
"no console message displayed"
|
||||
);
|
||||
is(
|
||||
findMessage(hud, PRIVATE_EXCEPTION, ".message.error")?.textContent,
|
||||
findErrorMessage(hud, PRIVATE_EXCEPTION)?.textContent,
|
||||
undefined,
|
||||
"no exception displayed"
|
||||
);
|
||||
|
|
|
@ -69,15 +69,23 @@ async function testWebExtensionMessages(
|
|||
!createWebExtensionBeforeOpeningBrowserConsole ||
|
||||
Services.prefs.getBoolPref("devtools.browsertoolbox.fission", false)
|
||||
) {
|
||||
await checkUniqueMessageExists(hud, "content console API message");
|
||||
await checkUniqueMessageExists(hud, "background console API message");
|
||||
await checkUniqueMessageExists(
|
||||
hud,
|
||||
"content console API message",
|
||||
".console-api"
|
||||
);
|
||||
await checkUniqueMessageExists(
|
||||
hud,
|
||||
"background console API message",
|
||||
".console-api"
|
||||
);
|
||||
}
|
||||
|
||||
await checkUniqueMessageExists(hud, "content error", ".error");
|
||||
await checkUniqueMessageExists(hud, "background error", ".error");
|
||||
|
||||
// TODO: Re-enable those checks (See Bug 1699050).
|
||||
// await checkUniqueMessageExists(hud, "popup console API message");
|
||||
// await checkUniqueMessageExists(hud, "popup console API message", ".console-api");
|
||||
// await checkUniqueMessageExists(hud, "popup error", ".error");
|
||||
|
||||
await clearOutput(hud);
|
||||
|
@ -151,7 +159,7 @@ async function checkUniqueMessageExists(hud, msg, selector) {
|
|||
let messages;
|
||||
try {
|
||||
messages = await waitFor(() => {
|
||||
const msgs = findMessages(hud, msg, selector);
|
||||
const msgs = findMessagesByType(hud, msg, selector);
|
||||
return msgs.length > 0 ? msgs : null;
|
||||
});
|
||||
} catch (e) {
|
||||
|
|
|
@ -53,7 +53,7 @@ add_task(async function() {
|
|||
info(`Check that no error was logged`);
|
||||
// wait a bit so potential errors can be printed
|
||||
await wait(1000);
|
||||
const error = findMessage(hud, "", ".message.error:not(.network)");
|
||||
const error = findErrorMessage(hud, "", ":not(.network)");
|
||||
if (error) {
|
||||
ok(false, `Got error ${JSON.stringify(error.textContent)}`);
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче