Bug 1628626 - Fix issue when clearing output with messages from destroyed targets. r=jdescottes.

With the new architecture, it might happen that a message (and the ObjectFronts
it holds), are still displayed in the Browser Console / Browser Toolbox Console,
even if the target of those object fronts was destroyed.
In such case, when the user would legimitely try to clear the console, we'd try
to release the fronts that were already destroyed, which would throw an exception
and leave the console in a bad state.
This patch simply check that the fronts are still alive when we try to release
them, and adds a test (that was failing without that patch, with fission ON) for
the Browser Console.

Differential Revision: https://phabricator.services.mozilla.com/D70398

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Chevobbe 2020-04-14 15:18:17 +00:00
parent 669348ec26
commit fa7cb96ca8
3 changed files with 45 additions and 2 deletions

View File

@ -34,11 +34,12 @@ function enableActorReleaser(webConsoleUI) {
) {
const promises = [];
state.messages.frontsToRelease.forEach(front => {
// We only release the front if it actually has a release method,
// and if it's not in the sidebar (where we might still need it).
// We only release the front if it actually has a release method, if it isn't
// already destroyed, and if it's not in the sidebar (where we might still need it).
if (
front &&
typeof front.release === "function" &&
front.actorID &&
(!state.ui.frontInSidebar ||
state.ui.frontInSidebar.actorID !== front.actorID)
) {

View File

@ -22,6 +22,7 @@ support-files =
[browser_console_cpow.js]
skip-if = !e10s # This test is only valid in e10s
[browser_console_clear_cache.js]
[browser_console_clear_closed_tab.js]
[browser_console_clear_method.js]
skip-if = true # Bug 1437843
[browser_console_consolejsm_output.js]

View File

@ -0,0 +1,41 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Check that clearing the browser console output still works if the tab that emitted some
// was closed. See Bug 1628626.
"use strict";
const TEST_URI =
"http://example.com/browser/devtools/client/webconsole/test/browser/test-console.html";
add_task(async function() {
// Show the content messages
await pushPref("devtools.browserconsole.contentMessages", true);
// Enable Fission browser console to see the logged content object
await pushPref("devtools.browsertoolbox.fission", true);
// Disable the preloaded process as it creates processes intermittently
// which forces the emission of RDP requests we aren't correctly waiting for.
await pushPref("dom.ipc.processPrelaunch.enabled", false);
const tab = await addTab(TEST_URI);
const hud = await BrowserConsoleManager.toggleBrowserConsole();
info("Log a new message from the content page");
SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
content.console.log({ hello: "world" });
});
await waitFor(() => findMessage(hud, "hello"));
await removeTab(tab);
// Wait for a bit, so the actors and fronts are released.
await wait(500);
info("Clear the console output");
hud.ui.outputNode.querySelector(".devtools-clear-icon").click();
await waitFor(() => !findMessage(hud, "hello"));
ok(true, "Browser Console was cleared");
});