summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/default-bidi-css-rules.html
blob: 556f79e040c7643c7daeefcb39dc1afb2ea51990 (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
<!DOCTYPE html>
<html>
<body>
<script src="../js/resources/js-test-pre.js"></script>
<p>This test checks <a href="http://dev.w3.org/html5/spec/Overview.html#bidirectional-text">the default rules for direction and unicode-bidi CSS properties</a>.</p>
<div id="container"></div>
<div id="console"></div>
<script>

var container = document.getElementById('container');

function styleOf(name, attributes) {
    var element = document.createElement(name);
    for (var name in attributes) {
        var value = attributes[name];
        element.setAttribute(name, value);
    }
    container.appendChild(element);
    return getComputedStyle(element);
}

var tests = [
    ['div', {}, 'ltr', '-webkit-isolate'],
    ['div', {'dir': 'ltr'}, 'ltr', 'embed'],
    ['div', {'dir': 'rtl'}, 'rtl', 'embed'],
    ['div', {'dir': 'auto'}, 'ltr', '-webkit-isolate'],
    ['div', {'dir': ''}, 'ltr', 'embed'],

    ['span', {}, 'ltr', 'normal'],
    ['span', {'dir': 'ltr'}, 'ltr', 'embed'],
    ['span', {'dir': 'rtl'}, 'rtl', 'embed'],
    ['span', {'dir': 'auto'}, 'ltr', '-webkit-isolate'],
    ['span', {'dir': ''}, 'ltr', 'embed'],

    ['bdi', {}, 'ltr', '-webkit-isolate'],
    ['bdi', {'dir': 'ltr'}, 'ltr', '-webkit-isolate'],
    ['bdi', {'dir': 'rtl'}, 'rtl', '-webkit-isolate'],
    ['bdi', {'dir': 'auto'}, 'ltr', '-webkit-isolate'],
    ['bdi', {'dir': ''}, 'ltr', '-webkit-isolate'],

    ['output', {}, 'ltr', '-webkit-isolate'],
    ['output', {'dir': 'ltr'}, 'ltr', '-webkit-isolate'],
    ['output', {'dir': 'rtl'}, 'rtl', '-webkit-isolate'],
    ['output', {'dir': 'auto'}, 'ltr', '-webkit-isolate'],
    ['output', {'dir': ''}, 'ltr', '-webkit-isolate'],

    ['bdo', {}, 'ltr', 'bidi-override'],
    ['bdo', {'dir': 'ltr'}, 'ltr', 'bidi-override'],
    ['bdo', {'dir': 'rtl'}, 'rtl', 'bidi-override'],
    ['bdo', {'dir': 'auto'}, 'ltr', 'bidi-override -webkit-isolate'],
    ['bdo', {'dir': ''}, 'ltr', 'bidi-override'],

    ['textarea', {}, 'ltr', 'normal'],
    ['textarea', {'dir': 'ltr'}, 'ltr', 'embed'],
    ['textarea', {'dir': 'rtl'}, 'rtl', 'embed'],
    ['textarea', {'dir': 'auto'}, 'ltr', '-webkit-plaintext'],
    ['textarea', {'dir': ''}, 'ltr', 'embed'],

    ['pre', {}, 'ltr', 'normal'],
    ['pre', {'dir': 'ltr'}, 'ltr', 'embed'],
    ['pre', {'dir': 'rtl'}, 'rtl', 'embed'],
    ['pre', {'dir': 'auto'}, 'ltr', '-webkit-plaintext'],
    ['pre', {'dir': ''}, 'ltr', 'embed'],
].forEach(function (test) {
    shouldBe('styleOf("' + test[0] + '", ' + JSON.stringify(test[1]) + ').direction', '"' + test[2] + '"');
    container.innerHTML = '';
    shouldBe('styleOf("' + test[0] + '", ' + JSON.stringify(test[1]) + ').unicodeBidi', '"' + test[3] + '"');
    container.innerHTML = '';
});

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