mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 1484989 - Prevent JsTerm to steal focus when reloading a page; r=bgrins.
JsTerm's focus function was called in clearOutput, which we call when navigating to a new page (if Persist Logs is not checked). This means that we were forcing the JsTerm to be focused each time the user navigated while having the console open. This behavior, can be annoying, or at worst, if you're debugging a focus issue in your content page, completely maddening. The fix is striaghtforward: do not call focus in clearOutput. A test is added to make sure we don't regress this. Differential Revision: https://phabricator.services.mozilla.com/D8701 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
4298421581
commit
95a682c9a9
@ -220,6 +220,7 @@ skip-if = os != 'mac' # The tested ctrl+key shortcuts are OSX only
|
||||
[browser_jsterm_document_no_xray.js]
|
||||
[browser_jsterm_error_docs.js]
|
||||
[browser_jsterm_error_outside_valid_range.js]
|
||||
[browser_jsterm_focus_reload.js]
|
||||
[browser_jsterm_helper_clear.js]
|
||||
[browser_jsterm_helper_dollar_dollar.js]
|
||||
[browser_jsterm_helper_dollar_x.js]
|
||||
|
@ -0,0 +1,33 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Check that the console does not steal the focus when reloading a page, if the focus
|
||||
// is on the content page.
|
||||
|
||||
"use strict";
|
||||
|
||||
const TEST_URI = `data:text/html,<meta charset=utf8>Focus test`;
|
||||
|
||||
add_task(async function() {
|
||||
// Run test with legacy JsTerm
|
||||
await pushPref("devtools.webconsole.jsterm.codeMirror", false);
|
||||
await performTests();
|
||||
// And then run it with the CodeMirror-powered one.
|
||||
await pushPref("devtools.webconsole.jsterm.codeMirror", true);
|
||||
await performTests();
|
||||
});
|
||||
|
||||
async function performTests() {
|
||||
info("Testing that messages disappear on a refresh if logs aren't persisted");
|
||||
const {jsterm} = await openNewTabAndConsole(TEST_URI);
|
||||
is(isJstermFocused(jsterm), true, "JsTerm is focused when opening the console");
|
||||
|
||||
info("Put the focus on the content page");
|
||||
ContentTask.spawn(gBrowser.selectedBrowser, null, () => content.focus());
|
||||
await waitFor(() => isJstermFocused(jsterm) === false);
|
||||
|
||||
info("Reload the page to check that JsTerm does not steal the content page focus");
|
||||
await refreshTab();
|
||||
is(isJstermFocused(jsterm), false,
|
||||
"JsTerm is still unfocused after reloading the page");
|
||||
}
|
@ -140,7 +140,6 @@ WebConsoleFrame.prototype = {
|
||||
if (clearStorage) {
|
||||
this.webConsoleClient.clearMessagesCache();
|
||||
}
|
||||
this.jsterm.focus();
|
||||
this.emit("messages-cleared");
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user