Files
sousa-gecko/devtools/server/tests/mochitest/test_webconsole-node-grip.html
T
2018-03-12 13:44:41 -05:00

69 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>