mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1715904 - [devtools] Refactor test to use DOCUMENT_EVENT's will-navigate. r=nchevobbe
I'm wondering if we should have yet another helper, like TargetCommand.waitForNextWillNavigate, which would be a wrapper around waitForNextResource ? Differential Revision: https://phabricator.services.mozilla.com/D118155
This commit is contained in:
parent
134b842c2e
commit
06ed013306
@ -79,7 +79,18 @@ add_task(async function() {
|
||||
ok(iframeBtn, "Got iframe document in the list");
|
||||
|
||||
// Listen to will-navigate to check if the view is empty
|
||||
const willNavigate = toolbox.target.once("will-navigate");
|
||||
const { resourceCommand } = toolbox.commands;
|
||||
const {
|
||||
onResource: willNavigate,
|
||||
} = await resourceCommand.waitForNextResource(
|
||||
resourceCommand.TYPES.DOCUMENT_EVENT,
|
||||
{
|
||||
ignoreExistingResources: true,
|
||||
predicate(resource) {
|
||||
return resource.name == "will-navigate";
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
// Only select the iframe after we are able to select an element from the top
|
||||
// level document.
|
||||
|
@ -8,12 +8,23 @@ const URL_1 = URL_ROOT + "doc_markup_update-on-navigtion_1.html";
|
||||
const URL_2 = URL_ROOT + "doc_markup_update-on-navigtion_2.html";
|
||||
|
||||
add_task(async function() {
|
||||
const { inspector } = await openInspectorForURL(URL_1);
|
||||
const { inspector, toolbox } = await openInspectorForURL(URL_1);
|
||||
|
||||
assertMarkupViewIsLoaded();
|
||||
await selectNode("#one", inspector);
|
||||
|
||||
const willNavigate = inspector.currentTarget.once("will-navigate");
|
||||
const { resourceCommand } = toolbox.commands;
|
||||
const {
|
||||
onResource: willNavigate,
|
||||
} = await resourceCommand.waitForNextResource(
|
||||
resourceCommand.TYPES.DOCUMENT_EVENT,
|
||||
{
|
||||
ignoreExistingResources: true,
|
||||
predicate(resource) {
|
||||
return resource.name == "will-navigate";
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
// We should not await on navigateTo here, because the test will assert the
|
||||
// various phases of the inspector during the navigation.
|
||||
|
@ -64,7 +64,19 @@ add_task(async function() {
|
||||
);
|
||||
|
||||
// Listen to will-navigate to check if the view is empty
|
||||
const willNavigate = toolbox.target.once("will-navigate").then(() => {
|
||||
const { resourceCommand } = toolbox.commands;
|
||||
const {
|
||||
onResource: willNavigate,
|
||||
} = await resourceCommand.waitForNextResource(
|
||||
resourceCommand.TYPES.DOCUMENT_EVENT,
|
||||
{
|
||||
ignoreExistingResources: true,
|
||||
predicate(resource) {
|
||||
return resource.name == "will-navigate";
|
||||
},
|
||||
}
|
||||
);
|
||||
willNavigate.then(() => {
|
||||
info("Navigation to the iframe has started, the inspector should be empty");
|
||||
assertMarkupViewIsEmpty(inspector);
|
||||
});
|
||||
|
@ -30,7 +30,17 @@ window.onload = async function() {
|
||||
const firstBatch = await front.getPendingTicks();
|
||||
await waitFor(TICK);
|
||||
|
||||
const onWillNavigate = target.once("will-navigate");
|
||||
const { resourceCommand } = commands;
|
||||
const { onResource: onWillNavigate } = await resourceCommand
|
||||
.waitForNextResource(
|
||||
resourceCommand.TYPES.DOCUMENT_EVENT,
|
||||
{
|
||||
ignoreExistingResources: true,
|
||||
predicate(resource) {
|
||||
return resource.name == "will-navigate";
|
||||
},
|
||||
}
|
||||
);
|
||||
contentWin.location.reload();
|
||||
await onWillNavigate;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user