зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1809119 - [devtools] Use selected target in context selector for Browser Console autocomplete. r=ochameau.
Differential Revision: https://phabricator.services.mozilla.com/D166279
This commit is contained in:
Родитель
4e316b468e
Коммит
5afd249ea2
|
@ -16,6 +16,13 @@ const {
|
|||
shouldInputBeAutocompleted,
|
||||
} = require("resource://devtools/shared/webconsole/analyze-input-string.js");
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"getSelectedTarget",
|
||||
"resource://devtools/shared/commands/target/selectors/targets.js",
|
||||
true
|
||||
);
|
||||
|
||||
/**
|
||||
* Update the data used for the autocomplete popup in the console input (JsTerm).
|
||||
*
|
||||
|
@ -244,10 +251,9 @@ function autocompleteDataFetch({
|
|||
|
||||
let targetFront = commands.targetCommand.selectedTargetFront;
|
||||
// Note that getSelectedTargetFront will return null if we default to the top level target.
|
||||
// For now, in the browser console (without a toolbox), we don't support the context selector.
|
||||
const contextSelectorTargetFront = hud.toolbox
|
||||
? hud.toolbox.getSelectedTargetFront()
|
||||
: null;
|
||||
const contextSelectorTargetFront = getSelectedTarget(
|
||||
hud.commands.targetCommand.store.getState()
|
||||
);
|
||||
const selectedActorId = selectedNodeActorId || frameActorId;
|
||||
if (contextSelectorTargetFront) {
|
||||
targetFront = contextSelectorTargetFront;
|
||||
|
|
|
@ -96,6 +96,16 @@ add_task(async function() {
|
|||
);
|
||||
ok(true, "The evaluation is done in the document context");
|
||||
|
||||
info("Check that autocomplete is done in the tab document context");
|
||||
await setInputValueForAutocompletion(hud, "p");
|
||||
// `pauseInWorker` is defined in test-evaluate-worker.html
|
||||
ok(
|
||||
getAutocompletePopupLabels(hud.jsterm.autocompletePopup).includes(
|
||||
"pauseInWorker"
|
||||
),
|
||||
"autocomplete happened in the tab document context"
|
||||
);
|
||||
|
||||
// set input text so we can watch for instant evaluation result update
|
||||
setInputValue(hud, "globalThis.location.href");
|
||||
await waitForEagerEvaluationResult(hud, `"${documentWithWorkerUrl}"`);
|
||||
|
@ -140,6 +150,14 @@ add_task(async function() {
|
|||
);
|
||||
ok(true, "The evaluation is done in the worker context");
|
||||
|
||||
info("Check that autocomplete is done in the worker context");
|
||||
await setInputValueForAutocompletion(hud, "f");
|
||||
// `foo` is defined in test-evaluate-worker.js
|
||||
ok(
|
||||
getAutocompletePopupLabels(hud.jsterm.autocompletePopup).includes("foo"),
|
||||
"autocomplete happened in the worker context"
|
||||
);
|
||||
|
||||
// set input text so we can watch for instant evaluation result update
|
||||
setInputValue(hud, "document.location.host");
|
||||
await waitForEagerEvaluationResult(
|
||||
|
|
Загрузка…
Ссылка в новой задаче