fune/devtools/server/tests/mochitest/test_webconsole-node-grip.html
Mark Banner 256aeb441c Bug 1362947 - Upgrade eslint-plugin-html to 2.0.3 to pick up --fix support. r=jaws
MozReview-Commit-ID: 5fVG7akPnGM

--HG--
extra : rebase_source : f1b9eeb1b2048b551ee8c0a596e6395d0031cc4d
2017-05-08 10:29:47 +01:00

68 lines
2.3 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>DOMNode Object actor test</title>
<script type="application/javascript" 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="webconsole-helpers.js"></script>
<script>
"use strict";
const TEST_URL = "data:text/html,<html><body>Hello</body></html>";
window.onload = async function () {
SimpleTest.waitForExplicitFinish();
try {
let {
consoleClient,
} = await attachURL(TEST_URL);
await testNotInTreeElementNode(consoleClient);
await testInTreeElementNode(consoleClient);
await testNotInTreeTextNode(consoleClient);
await testInTreeTextNode(consoleClient);
} catch (e) {
ok(false, `Error thrown: ${e.message}`);
}
SimpleTest.finish();
};
async function testNotInTreeElementNode(consoleClient) {
info("Testing isConnected property on a ElementNode not in the DOM tree");
let {result} = await consoleClient.evaluateJS("document.createElement(\"div\")");
is(result.preview.isConnected, false,
"isConnected is false since we only created the element");
}
async function testInTreeElementNode(consoleClient) {
info("Testing isConnected property on a ElementNode in the DOM tree");
let {result} = await consoleClient.evaluateJS("document.body");
is(result.preview.isConnected, true,
"isConnected is true as expected, since the element was retrieved from the DOM tree");
}
async function testNotInTreeTextNode(consoleClient) {
info("Testing isConnected property on a TextNode not in the DOM tree");
let {result} = await consoleClient.evaluateJS("document.createTextNode(\"Hello\")");
is(result.preview.isConnected, false,
"isConnected is false since we only created the element");
}
async function testInTreeTextNode(consoleClient) {
info("Testing isConnected property on a TextNode in the DOM tree");
let {result} = await consoleClient.evaluateJS("document.body.firstChild");
is(result.preview.isConnected, true,
"isConnected is true as expected, since the element was retrieved from the DOM tree");
}
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>