File: test_MochiKit-Color.html

package info (click to toggle)
mochikit 1.4.2-4
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 2,272 kB
  • ctags: 1,419
  • sloc: xml: 40; makefile: 6
file content (84 lines) | stat: -rw-r--r-- 2,343 bytes parent folder | download | duplicates (4)
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
<html>
<head>
    <script type="text/javascript" src="../lib/MochiKit/Base.js"></script>
    <script type="text/javascript" src="../lib/MochiKit/Iter.js"></script>
    <script type="text/javascript" src="../lib/MochiKit/DOM.js"></script>
    <script type="text/javascript" src="../lib/MochiKit/Style.js"></script>
    <script type="text/javascript" src="../lib/MochiKit/Logging.js"></script>
    <script type="text/javascript" src="../lib/MochiKit/Color.js"></script>
    <script type="text/javascript" src="SimpleTest/SimpleTest.js"></script>        
    <link rel="stylesheet" type="text/css" href="SimpleTest/test.css">
    <style type="text/css">.redtext {color: red}</style>
</head>
<body>
<div style="position:absolute; top: 0px; left:0px; width:0px; height:0px">
    <span style="color: red" id="c_direct"></span>
    <span class="redtext" id="c_indirect"></span>
</div>
<pre id="test">
<script type="text/javascript" src="test_Color.js"></script>
<script type="text/javascript">
try {
        
    var t = {ok:ok, is:is};
    tests.test_Color({ok:ok, is:is});
    is(
        Color.fromText(SPAN()).toHexString(),
        "#000000",
        "fromText no style"
    );

    is(
        Color.fromText("c_direct").toHexString(),
        Color.fromName("red").toHexString(),
        "fromText direct style"
    );

    is(
        Color.fromText("c_indirect").toHexString(),
        Color.fromName("red").toHexString(),
        "fromText indirect style"
    );

    is(
        Color.fromComputedStyle("c_direct", "color").toHexString(),
        Color.fromName("red").toHexString(),
        "fromComputedStyle direct style"
    );

    is(
        Color.fromComputedStyle("c_indirect", "color").toHexString(),
        Color.fromName("red").toHexString(),
        "fromComputedStyle indirect style"
    );

    is(
        Color.fromBackground((SPAN(null, 'test'))).toHexString(),
        Color.fromName("white").toHexString(),
        "fromBackground with DOM"
    );


    // Done!

    ok( true, "test suite finished!");
    
} catch (err) {
    
    var s = "test suite failure!\n";
    var o = {};
    var k = null;
    for (k in err) {
        // ensure unique keys?!
        if (!o[k]) {
            s +=  k + ": " + err[k] + "\n";
            o[k] = err[k];
        }
    }
    ok ( false, s );

}
</script>
</pre>
</body>
</html>