blob: 6b3644a0a02d91586cda5b0f80419e62407d8bb7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=419527
-->
<head>
<title>Test for Bug 419527</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"/>
</head>
<body>
<template id="template"><span>Foo</span></template>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=419527">Mozilla Bug 419527</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[
/** Test for Bug 419527 **/
customElements.define("custom-element", class extends HTMLElement {
constructor() {
super();
const template = document.getElementById("template");
const shadowRoot = this.attachShadow({mode: "open"})
.appendChild(template.content.cloneNode(true));
}
connectedCallback() {
var win = window;
var span = this.shadowRoot.children[0];
win.ok(span.textContent == "Foo", "Right span.");
win.ok(span.localName == "span", "Wrong anon node!");
var range = document.createRange();
range.selectNode(span.firstChild);
win.ok(range.startContainer == span, "Wrong start container!");
win.ok(range.endContainer == span, "Wrong end container!");
var newSubTree = win.newSubTree;
newSubTree.appendChild(this);
range.setStart(newSubTree.firstChild, 0);
win.ok(range.startContainer == newSubTree.firstChild,
"Range should have been collapsed to newSubTree.firstChild!");
win.ok(range.endContainer == newSubTree.firstChild,
"Range should have been collapsed to newSubTree.firstChild!");
SimpleTest.finish();
}
});
var d;
function runRangeTest() {
window.newSubTree = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
newSubTree.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "div"));
d = document.createElementNS("http://www.w3.org/1999/xhtml", "custom-element");
document.body.appendChild(d);
}
SimpleTest.waitForExplicitFinish();
setTimeout(runRangeTest, 0);
]]>
</script>
</pre>
</body>
</html>
|