Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1345119</title>
<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();
};
var gWalker;
var gHTMLNode;
var gBodyNode;
addTest(async function setup() {
const url = document.getElementById("inspectorContent").href;
const { target } = await attachURL(url);
const inspector = await target.getFront("inspector");
gWalker = inspector.walker;
gBodyNode = await gWalker.querySelector(gWalker.rootNode, "body");
gHTMLNode = await gWalker.querySelector(gWalker.rootNode, "html");
runNextTest();
});
addTest(function() {
info("Try to get the offset parent for a dead node (null)");
gWalker.getOffsetParent(null).then(offsetParent => {
ok(!offsetParent, "No offset parent found");
runNextTest();
});
});
addTest(function() {
info("Try to get the offset parent for a node that is absolutely positioned inside a " +
"relative node");
gWalker.querySelector(gWalker.rootNode, "#absolute_child").then(node => {
return gWalker.getOffsetParent(node);
}).then(offsetParent => {
ok(offsetParent, "The node has an offset parent");
gWalker.querySelector(gWalker.rootNode, "#relative_parent").then(parent => {
ok(offsetParent === parent, "The offset parent is the correct node");
runNextTest();
});
});
});
addTest(function() {
info("Try to get the offset parent for a node that is absolutely positioned outside a" +
" relative node");
gWalker.querySelector(gWalker.rootNode, "#no_parent").then(node => {
return gWalker.getOffsetParent(node);
}).then(offsetParent => {
ok(offsetParent === gBodyNode || offsetParent === gHTMLNode,
"The node's offset parent is the body or html node");
runNextTest();
});
});
addTest(function() {
info("Try to get the offset parent for a relatively positioned node");
gWalker.querySelector(gWalker.rootNode, "#relative_parent").then(node => {
return gWalker.getOffsetParent(node);
}).then(offsetParent => {
ok(offsetParent === gBodyNode || offsetParent === gHTMLNode,
"The node's offset parent is the body or html node");
runNextTest();
});
});
addTest(function() {
info("Try to get the offset parent for a statically positioned node");
gWalker.querySelector(gWalker.rootNode, "#static").then(node => {
return gWalker.getOffsetParent(node);
}).then(offsetParent => {
ok(offsetParent === gBodyNode || offsetParent === gHTMLNode,
"The node's offset parent is the body or html node");
runNextTest();
});
});
addTest(function() {
info("Try to get the offset parent for a fixed positioned node");
gWalker.querySelector(gWalker.rootNode, "#fixed").then(node => {
return gWalker.getOffsetParent(node);
}).then(offsetParent => {
ok(offsetParent === gBodyNode || offsetParent === gHTMLNode,
"The node's offset parent is the body or html node");
runNextTest();
});
});
addTest(function() {
info("Try to get the offset parent for the body");
gWalker.querySelector(gWalker.rootNode, "body").then(node => {
return gWalker.getOffsetParent(node);
}).then(offsetParent => {
ok(!offsetParent, "The body has no offset parent");
runNextTest();
});
});
addTest(function() {
gWalker = null;
gBodyNode = null;
runNextTest();
});
</script>
</head>
<body>
<a id="inspectorContent" target="_blank" href="inspector_getOffsetParent.html">Test Document</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>