blob: 5c08370321afd3826bf0baf51c179be681409cea (
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
|
<!doctype html>
<head>
<title>Test for initial selection and caret at turning on the designMode with user interaction</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
</head>
<p>foo</p>
<button onclick="document.designMode = 'on'">click</button>
<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(() => {
synthesizeMouseAtCenter(document.querySelector("button"), {});
is(
document.activeElement,
document.body,
"The <body> element should be active"
);
is(
getSelection().focusNode,
document.body.firstChild.firstChild,
"The focus node should be the text node in the first paragraph"
);
is(
getSelection().anchorNode,
document.body.firstChild.firstChild,
"The anchor node should be the text node in the first paragraph"
);
is(
getSelection().focusOffset,
0,
"The focus offset should be 0"
);
is(
getSelection().anchorOffset,
0,
"The anchor offset should be 0"
);
function getHTMLEditor() {
return SpecialPowers.wrap(window).docShell.editingSession?.getEditorForWindow(window);
}
ok(
getHTMLEditor().selectionController.getCaretEnabled(),
"The caret should be enabled"
);
ok(
getHTMLEditor().selectionController.caretVisible,
"The caret should be visible"
);
document.designMode = "off";
SimpleTest.finish();
});
</script>
|