diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/server/tests/chrome/test_inspector-dead-nodes.html | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/chrome/test_inspector-dead-nodes.html')
-rw-r--r-- | devtools/server/tests/chrome/test_inspector-dead-nodes.html | 332 |
1 files changed, 332 insertions, 0 deletions
diff --git a/devtools/server/tests/chrome/test_inspector-dead-nodes.html b/devtools/server/tests/chrome/test_inspector-dead-nodes.html new file mode 100644 index 0000000000..53c8b7eb3d --- /dev/null +++ b/devtools/server/tests/chrome/test_inspector-dead-nodes.html @@ -0,0 +1,332 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1121528 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1121528</title> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> + <script type="application/javascript" src="inspector-helpers.js"></script> + <script type="application/javascript"> +"use strict"; + +window.onload = function() { + SimpleTest.waitForExplicitFinish(); + runNextTest(); +}; + +let gWalker = null; +let gDoc = null; +let gResourceWatcher = null; +let gRootNodeResolve = null; + +async function reloadTarget() { + const rootNodePromise = new Promise(r => (gRootNodeResolve = r)); + gDoc.defaultView.location.reload(); + await rootNodePromise; +} + +addAsyncTest(async function() { + const url = document.getElementById("inspectorContent").href; + const { target, doc } = await attachURL(url); + gDoc = doc; + const inspector = await target.getFront("inspector"); + gWalker = inspector.walker; + gResourceWatcher = createResourceWatcher(target); + + info("Start watching for root nodes and wait for the initial root node"); + const rootNodePromise = new Promise(r => (gRootNodeResolve = r)); + const onAvailable = rootNodeFront => gRootNodeResolve(rootNodeFront); + await gResourceWatcher.watchResources([gResourceWatcher.TYPES.ROOT_NODE], { + onAvailable, + }); + await rootNodePromise; + + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.children(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "body"); + + await reloadTarget(); + await gWalker.children(nodeFront); + + ok(true, "The call to walker.children() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.nextSibling(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.nextSibling(nodeFront); + + ok(true, "The call to walker.nextSibling() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.previousSibling(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.previousSibling(nodeFront); + + ok(true, "The call to walker.previousSibling() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.addPseudoClassLock(nodeFront) before the load completes " + + "shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.addPseudoClassLock(nodeFront, ":hover"); + + ok(true, "The call to walker.addPseudoClassLock() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.removePseudoClassLock(nodeFront) before the load completes " + + "shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.removePseudoClassLock(nodeFront, ":hover"); + + ok(true, "The call to walker.removePseudoClassLock() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.clearPseudoClassLocks(nodeFront) before the load completes " + + "shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.clearPseudoClassLocks(nodeFront); + + ok(true, "The call to walker.clearPseudoClassLocks() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.innerHTML(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.innerHTML(nodeFront); + + ok(true, "The call to walker.innerHTML() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.setInnerHTML(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.setInnerHTML(nodeFront, "<span>innerHTML changed</span>"); + + ok(true, "The call to walker.setInnerHTML() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.outerHTML(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.outerHTML(nodeFront); + + ok(true, "The call to walker.outerHTML() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.setOuterHTML(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.setOuterHTML(nodeFront, "<h1><span>innerHTML changed</span></h1>"); + + ok(true, "The call to walker.setOuterHTML() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.insertAdjacentHTML(nodeFront) before the load completes shouldn't " + + "fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.insertAdjacentHTML(nodeFront, "afterEnd", + "<span>new adjacent HTML</span>"); + + ok(true, "The call to walker.insertAdjacentHTML() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.removeNode(nodeFront) before the load completes should throw"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + let hasThrown = false; + try { + await gWalker.removeNode(nodeFront); + } catch (e) { + hasThrown = true; + } + + ok(hasThrown, "The call to walker.removeNode() threw"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.removeNodes([nodeFront]) before the load completes should throw"); + + const nodeFront1 = await gWalker.querySelector(gWalker.rootNode, "h1"); + const nodeFront2 = await gWalker.querySelector(gWalker.rootNode, "#longstring"); + const nodeFront3 = await gWalker.querySelector(gWalker.rootNode, "#shortstring"); + await reloadTarget(); + let hasThrown = false; + try { + await gWalker.removeNodes([nodeFront1, nodeFront2, nodeFront3]); + } catch (e) { + hasThrown = true; + } + + ok(hasThrown, "The call to walker.removeNodes() threw"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.insertBefore(nodeFront, parent, null) before the load completes " + + "shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + const newParentFront = await gWalker.querySelector(gWalker.rootNode, "#longlist"); + await reloadTarget(); + await gWalker.insertBefore(nodeFront, newParentFront); + + ok(true, "The call to walker.insertBefore() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.insertBefore(nodeFront, parent, sibling) before the load completes " + + "shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + const newParentFront = await gWalker.querySelector(gWalker.rootNode, "#longlist"); + const siblingFront = await gWalker.querySelector(gWalker.rootNode, "#b"); + await reloadTarget(); + await gWalker.insertBefore(nodeFront, newParentFront, siblingFront); + + ok(true, "The call to walker.insertBefore() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.editTagName(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.editTagName(nodeFront, "h2"); + + ok(true, "The call to walker.editTagName() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.hideNode(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.hideNode(nodeFront); + + ok(true, "The call to walker.hideNode() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.unhideNode(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.unhideNode(nodeFront); + + ok(true, "The call to walker.unhideNode() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.releaseNode(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "h1"); + await reloadTarget(); + await gWalker.releaseNode(nodeFront); + + ok(true, "The call to walker.releaseNode() didn't fail"); + runNextTest(); +}); + +addAsyncTest(async function() { + info("Getting a nodeFront, reloading the page, and calling " + + "walker.querySelector(nodeFront) before the load completes shouldn't fail"); + + const nodeFront = await gWalker.querySelector(gWalker.rootNode, "body"); + await reloadTarget(); + await gWalker.querySelector(nodeFront, "h1"); + + ok(true, "The call to walker.querySelector() didn't fail"); + runNextTest(); +}); + +addTest(function cleanup() { + gWalker = null; + gDoc = null; + gResourceWatcher = null; + runNextTest(); +}); + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=932937">Mozilla Bug 1121528</a> +<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +</pre> +</body> +</html> |