зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1768475 - [devtools] WalkerActor watchRootNode should not check isDocumentReady r=devtools-reviewers,nchevobbe
If the walker actor was initialized, we assume the document is ready enough and a root node can be returned if available. A new test was added for a slow loading document. Differential Revision: https://phabricator.services.mozilla.com/D146464
This commit is contained in:
Родитель
b637180d67
Коммит
e4e4e73bb9
|
@ -26,7 +26,7 @@ const TEST_URL =
|
|||
</html>
|
||||
`);
|
||||
|
||||
add_task(async function() {
|
||||
add_task(async function testSlowLoadingFrame() {
|
||||
const loadingTab = BrowserTestUtils.addTab(gBrowser, TEST_URL);
|
||||
gBrowser.selectedTab = loadingTab;
|
||||
|
||||
|
@ -67,3 +67,96 @@ add_task(async function() {
|
|||
inspector
|
||||
);
|
||||
});
|
||||
|
||||
const DOCUMENT_DELAY = 5000;
|
||||
|
||||
add_task(async function testSlowLoadingDocument() {
|
||||
info("Create a test server serving a slow document");
|
||||
const httpServer = createTestHTTPServer();
|
||||
httpServer.registerContentType("html", "text/html");
|
||||
|
||||
httpServer.registerPathHandler(`/`, async function(request, response) {
|
||||
response.processAsync();
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
|
||||
// Split the page content in 2 parts:
|
||||
// - opening body tag and the "#start" div will be returned immediately
|
||||
// - "#end" div and closing body tag are returned after a delay.
|
||||
const page_start = "<body><div id='start'>start</div>";
|
||||
const page_end = "<div id='end'>end</div></body>";
|
||||
const page = page_start + page_end;
|
||||
|
||||
response.setHeader("Content-Type", "text/html; charset=utf-8", false);
|
||||
response.setHeader("Content-Length", page.length + "", false);
|
||||
response.write(page_start);
|
||||
|
||||
await wait(DOCUMENT_DELAY);
|
||||
response.write(page_end);
|
||||
response.finish();
|
||||
});
|
||||
|
||||
const port = httpServer.identity.primaryPort;
|
||||
const TEST_URL_2 = `http://localhost:${port}/`;
|
||||
|
||||
// Same as in the other task, we cannot wait for the full load.
|
||||
info("Open a new tab on TEST_URL_2 and select it");
|
||||
const loadingTab = BrowserTestUtils.addTab(gBrowser, TEST_URL_2);
|
||||
gBrowser.selectedTab = loadingTab;
|
||||
|
||||
info("Wait for the #start div to be available in the document");
|
||||
await TestUtils.waitForCondition(async () => {
|
||||
try {
|
||||
return await ContentTask.spawn(gBrowser.selectedBrowser, {}, () =>
|
||||
content.document.getElementById("start")
|
||||
);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const { inspector } = await openInspector();
|
||||
|
||||
info("Check that the inspector is not blank and only shows the #start div");
|
||||
await assertMarkupViewAsTree(
|
||||
`
|
||||
body
|
||||
div id="start"`,
|
||||
"body",
|
||||
inspector
|
||||
);
|
||||
|
||||
// Navigate to about:blank to clean the state.
|
||||
await navigateTo("about:blank");
|
||||
|
||||
await navigateTo(TEST_URL_2, { waitForLoad: false });
|
||||
info("Wait for the #start div to be available as a markupview container");
|
||||
await TestUtils.waitForCondition(async () => {
|
||||
const nodeFront = await getNodeFront("#start", inspector);
|
||||
return nodeFront && getContainerForNodeFront(nodeFront, inspector);
|
||||
});
|
||||
|
||||
info("Check that the inspector is not blank and only shows the #start div");
|
||||
await assertMarkupViewAsTree(
|
||||
`
|
||||
body
|
||||
div id="start"`,
|
||||
"body",
|
||||
inspector
|
||||
);
|
||||
|
||||
info("Wait for the #end div to be available as a markupview container");
|
||||
await TestUtils.waitForCondition(async () => {
|
||||
const nodeFront = await getNodeFront("#end", inspector);
|
||||
return nodeFront && getContainerForNodeFront(nodeFront, inspector);
|
||||
});
|
||||
|
||||
info("Check that the inspector will ultimately show the #end div");
|
||||
await assertMarkupViewAsTree(
|
||||
`
|
||||
body
|
||||
div id="start"
|
||||
div id="end"`,
|
||||
"body",
|
||||
inspector
|
||||
);
|
||||
});
|
||||
|
|
|
@ -43,7 +43,6 @@ loader.lazyRequireGetter(
|
|||
[
|
||||
"allAnonymousContentTreeWalkerFilter",
|
||||
"findGridParentContainerForNode",
|
||||
"isDocumentReady",
|
||||
"isNodeDead",
|
||||
"noAnonymousContentTreeWalkerFilter",
|
||||
"nodeDocument",
|
||||
|
@ -291,7 +290,7 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
|
|||
},
|
||||
|
||||
watchRootNode() {
|
||||
if (this.rootNode && isDocumentReady(this.rootDoc)) {
|
||||
if (this.rootNode) {
|
||||
this.emit("root-available", this.rootNode);
|
||||
}
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче