nnnjjj123
2020-11-17 1b2c1edb61190eeb19f465ff031eaa3b2a1b8dbc
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
95
96
97
98
define([
    'intern!tdd',
    'intern/chai!assert',
    'intern/dojo/node!leadfoot/helpers/pollUntil',
    'intern/dojo/node!leadfoot/keys',
    'require'
], function (test, assert, pollUntil, keys, require) {
    var tabKey = keys.TAB;
    test.suite('Keyboard tab key functional tests', function () {
        test.before(function () {
            // Get our html page. This page should load all necessary scripts
            // since this functional test module runs on the server and can't load
            // such scripts. Further, in the html page, set a global "ready" var
            // to true to tell the runner to continue.
            return this.remote
                .get(require.toUrl('./KeyboardTab.html'))
                .then(pollUntil(function () {
                    return window.ready;
                }, null, 5000));
        });
 
        test.test('grids with and without headers -> tab key', function () {
            return this.remote
                .getActiveElement()
                    .getAttribute('id')
                    .then(function (id) {
                        assert.strictEqual(id, 'showHeaderButton', 'Focus is on the button: ' + id);
                    })
                    .type(tabKey)
                    .end()
                .getActiveElement()
                    .getAttribute('role').then(function (role) {
                        assert.strictEqual(role, 'columnheader', 'Focus is on a column header: ' + role);
                    })
                    .type(tabKey)
                    .end()
                .getActiveElement()
                    .getAttribute('role').then(function (role) {
                        assert.strictEqual(role, 'gridcell', 'Focus is on a grid cell: ' + role);
                    })
                    .getVisibleText()
                    .then(function (text) {
                        assert.strictEqual(text, '0', 'The cell with focus contains 0: ' + text);
                    })
                    .type(tabKey)
                    .end()
                .getActiveElement()
                    .getAttribute('role').then(function (role) {
                        assert.strictEqual(role, 'gridcell', 'Focus is on a grid cell: ' + role);
                    })
                    .getVisibleText()
                    .then(function (text) {
                        assert.strictEqual(text, '10', 'The cell with focus contains 10: ' + text);
                    })
                    .end()
                .findById('showHeaderButton')
                    .click()
                    .end()
                .getActiveElement()
                    .getAttribute('id')
                    .then(function (id) {
                        assert.strictEqual(id, 'showHeaderButton', 'Focus is on the button: ' + id);
                    })
                    .type(tabKey)
                    .end()
                .getActiveElement()
                    .getAttribute('role').then(function (role) {
                        assert.strictEqual(role, 'columnheader', 'Focus is on a column header: ' + role);
                    })
                    .type(tabKey)
                    .end()
                .getActiveElement()
                    .getAttribute('role').then(function (role) {
                        assert.strictEqual(role, 'gridcell', 'Focus is on a grid cell: ' + role);
                    })
                    .getVisibleText()
                    .then(function (text) {
                        assert.strictEqual(text, '0', 'The cell with focus contains 0: ' + text);
                    })
                    .type(tabKey)
                    .end()
                .getActiveElement()
                    .getAttribute('role').then(function (role) {
                        assert.strictEqual(role, 'columnheader', 'Focus is on a column header: ' + role);
                    })
                    .type(tabKey)
                    .end()
                .getActiveElement()
                    .getAttribute('role').then(function (role) {
                        assert.strictEqual(role, 'gridcell', 'Focus is on a grid cell: ' + role);
                    })
                    .getVisibleText()
                    .then(function (text) {
                        assert.strictEqual(text, '10', 'The cell with focus contains 10: ' + text);
                    });
        });
    });
});