summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/chrome/test_inspector-dead-nodes.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /devtools/server/tests/chrome/test_inspector-dead-nodes.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.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.html350
1 files changed, 350 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..bb73d0d6de
--- /dev/null
+++ b/devtools/server/tests/chrome/test_inspector-dead-nodes.html
@@ -0,0 +1,350 @@
+<!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";
+
+// TODO: With server side target switching (devtools.target-switching.server.enabled),
+// this test is most likely irrelevant.
+// APIs that might survive a reload should be moved to commands instead of
+// target scoped fronts, because targets no longer survive a reload.
+// See https://bugzilla.mozilla.org/show_bug.cgi?id=1726597
+
+
+window.onload = function() {
+ // For some reason, this test fails more frequently when EFT is enabled.
+ if (Services.prefs.getBoolPref("devtools.every-frame-target.enabled")) {
+ ok(true, "EFT is enabled, don't run the test");
+ SimpleTest.finish();
+ return;
+ }
+
+ SimpleTest.waitForExplicitFinish();
+ runNextTest();
+};
+
+let gWalker = null;
+let gDoc = null;
+let gResourceCommand = null;
+let gRootNodeResolve = null;
+let gCommands = null;
+
+async function reloadTarget() {
+ const rootNodePromise = new Promise(r => (gRootNodeResolve = r));
+ gDoc.defaultView.location.reload();
+ await rootNodePromise;
+ gWalker = (await gCommands.targetCommand.targetFront.getFront("inspector")).walker;
+}
+
+addAsyncTest(async function() {
+ const url = document.getElementById("inspectorContent").href;
+ const { commands, doc } = await attachURL(url);
+ const target = commands.targetCommand.targetFront;
+ gDoc = doc;
+ const inspector = await target.getFront("inspector");
+ gWalker = inspector.walker;
+ gResourceCommand = commands.resourceCommand;
+ gCommands = commands;
+
+ 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 gResourceCommand.watchResources([gResourceCommand.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;
+ gResourceCommand = 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>