Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Bug 1593933 - [devtools] Navigating should close existing console.gro…
Browse files Browse the repository at this point in the history
…up messages. r=nchevobbe

When a navigation message is added into the store, reset the currentGroup property
This adds a test to ensure the fix works as expected.

Differential Revision: https://phabricator.services.mozilla.com/D92778
  • Loading branch information
miggs125 committed Oct 12, 2020
1 parent b327d7c commit 8b44ff3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
9 changes: 8 additions & 1 deletion devtools/client/webconsole/reducers/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ function cloneState(state) {
*/
// eslint-disable-next-line complexity
function addMessage(newMessage, state, filtersState, prefsState, uiState) {
const { messagesById, groupsById, currentGroup, repeatById } = state;
const { messagesById, groupsById, repeatById } = state;

if (newMessage.type === constants.MESSAGE_TYPE.NAVIGATION_MARKER) {
// We set the state's currentGroup property to null after navigating
state.currentGroup = null;
}
const { currentGroup } = state;

if (newMessage.type === constants.MESSAGE_TYPE.NULL_MESSAGE) {
// When the message has a NULL type, we don't add it.
return state;
Expand Down
1 change: 1 addition & 0 deletions devtools/client/webconsole/test/browser/_webconsole.ini
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ tags = mcb
[browser_webconsole_clickable_urls.js]
[browser_webconsole_close_unfocused_window.js]
[browser_webconsole_closing_after_completion.js]
[browser_webconsole_close_groups_after_navigation.js]
[browser_webconsole_close_sidebar.js]
skip-if = true # Bug 1405250
[browser_webconsole_console_api_iframe.js]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";
const TEST_URI = `data:text/html;charset=utf8,<script>console.group('hello')</script>`;

add_task(async function() {
// Enable persist logs
await pushPref("devtools.webconsole.persistlog", true);

const hud = await openNewTabAndConsole(TEST_URI);

info("Refresh tab several times and check for correct message indentation");
for (let i = 0; i < 5; i++) {
await refreshTabAndCheckIndent(hud);
}
});

async function refreshTabAndCheckIndent(hud) {
const onMessage = waitForMessage(hud, "hello");
await refreshTab();
const { node } = await onMessage;

is(
node.querySelector(".indent").getAttribute("data-indent"),
"0",
"The message has the expected indent"
);
}

0 comments on commit 8b44ff3

Please sign in to comment.