summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/fallback-content.html
blob: 0f33521b73849639e9579a1b85484b9ce4134b70 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE HTML>
<html>
<body>
<script src="../js/resources/js-test-pre.js"></script>

<div>
  <a id="link1" href="#">Link</a>
  <button id="button1">Button</button>
  <input id="text1" type="text">
  <input id="checkbox1" type="checkbox">
  <input id="radio1" type="radio">
  <input id="slider1" type="range">
  <input id="submit1" type="submit">
  <select id="combobox1"><option>1<option>2</select>
  <select id="listbox1" multiple><option>1<option>2</select>
  <textarea id="textarea1"></textarea>
  <div id="focusable1" tabindex="0">Focusable</div>
</div>

<canvas id="myCanvas" width="300" height="300">
  <a id="link2" href="#">Link</a>
  <button id="button2">Button</button>
  <input id="text2" type="text">
  <input id="checkbox2" type="checkbox">
  <input id="radio2" type="radio">
  <input id="slider2" type="range">
  <input id="submit2" type="submit">
  <select id="combobox2"><option>1<option>2</select>
  <select id="listbox2" multiple><option>1<option>2</select>
  <textarea id="textarea2"></textarea>
  <div id="focusable2" tabindex="0">Focusable</div>
</canvas>

<canvas hidden id="hiddenCanvas" width="300" height="300">
  <a id="linkInHiddenCanvas" href="#">Link</a>
</canvas>

<div id="console"></div>
<script>
description("This test makes sure that focusable elements in canvas fallback content are focusable.");

if (window.testRunner)
    window.testRunner.dumpAsText();

var element;
function checkFocusable(id) {
    debug(id + " should be focusable.");
    element = document.getElementById(id);
    element.focus();
    shouldBe("document.activeElement == element", "true");
    debug("");
}

checkFocusable("link1");
checkFocusable("button1");
checkFocusable("text1");
checkFocusable("checkbox1");
checkFocusable("radio1");
checkFocusable("slider1");
checkFocusable("submit1");
checkFocusable("combobox1");
checkFocusable("listbox1");
checkFocusable("textarea1");
checkFocusable("focusable1");

checkFocusable("link2");
checkFocusable("button2");
checkFocusable("text2");
checkFocusable("checkbox2");
checkFocusable("radio2");
checkFocusable("slider2");
checkFocusable("submit2");
checkFocusable("combobox2");
checkFocusable("listbox2");
checkFocusable("textarea2");
checkFocusable("focusable2");

var previousFocusedElement;
function checkNotFocusable(id) {
    debug(id + " should not be focusable.");
    previousFocusedElement = document.activeElement;
    element = document.getElementById(id);
    element.focus();
    shouldBe("document.activeElement == previousFocusedElement", "true");
    debug("");
}

checkNotFocusable("linkInHiddenCanvas");

</script>

<script src="../js/resources/js-test-post.js"></script>
</body>
</html>