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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
# Test script for Tkhtml
#
# This file contains test cases that ensure the handling of syntax
# errors in stylesheets is consistent with other interpretations of
# the various CSS specs.
#
# Interfaces:
#
# pathName style TEXT
# pathName parse -final TEXT
# pathName search SELECTOR
# nodeHandle property PROPERTY-NAME
#
# Standard test file code.
proc sourcefile {file} {
set fname [file join [file dirname [info script]] $file]
uplevel #0 [list source $fname]
}
sourcefile common.tcl
html .h -defaultstyle ""
proc syntaxtest {name args} {
array set a $args
.h reset
.h parse -final $a(-document)
.h style $a(-style)
tcltest::test $name {} -body $a(-body) -result $a(-result)
}
#---------------------------------------------------------------------
# The following tests - syntax-1.* - come from the selectors
# in the acid2 page.
#
syntaxtest syntax-1.0 -style {
div {
background: yellow /* comment */ no-repeat /* comment */ ;
}
} -document {
<div></div>
} -body {
set node [lindex [.h search div] 0]
$node property background-color
} -result yellow
syntaxtest syntax-1.1 -style {
[class~=one].first.one {color: red}
} -document {
<div class="first one">
} -body {
set node [lindex [.h search div] 0]
$node property color
} -result red
syntaxtest syntax-1.2 -style {
[class~=one][class~=first] [class=second\ two][class="second two"]
{color : red}
} -document {
<div class="first one">
<div id="1" class="second two">
} -body {
set node [lindex [.h search {#1}] 0]
$node property color
} -result red
syntaxtest syntax-1.4 -style {
/* Note the syntax error in the next line! */
[class=second two] { background: red; }
.eyes { position: absolute }
} -document {
<div class="eyes">
} -body {
set node [lindex [.h search .eyes] 0]
$node property position
} -result absolute
#---------------------------------------------------------------------
# The selector in this test case - syntax-2.0 - comes from
# "http://www.freenigma.com". This should just be handled as a
# syntax error (ignore the whole declaration):
#
# a:* {
# text-decoration: none;
# color: #436976;
# }
#
syntaxtest syntax-2.0 -style {
* {color: black;}
a:* {
text-decoration: none;
color: #436976;
}
} -document {
<a>Hello</a>
} -body {
set node [lindex [.h search a] 0]
$node property color
} -result black
#
# Also from www.freenigma.com:
#
# @CHARSET "UTF-8";
#
# div.content h1 { color: red }
#
#---------------------------------------------------------------------
# The selector in this test case - syntax-3.0 - tests a problem found at
# "http://www.yahoo.com". The lines prefixed with "*" should be skipped,
# the others respected.
#
# Apparently people have figured out that the following are all legal
# ways of commenting out a property/value pair in CSS:
#
# selector {
# *prop: value;
# # prop: value;
# // prop: value;
# }
#
syntaxtest syntax-3.0 -style {
div {
text-decoration:underline;
*color:red;
color:green;
*text-decoration:strikethrough;
}
} -document {
<div>Hello</div>
} -body {
set node [lindex [.h search div] 0]
list [$node property color] [$node property text-decoration]
} -result {green underline}
syntaxtest syntax-3.1 -style {
div {
text-decoration:underline;
// color:red;
color:green;
# text-decoration:strikethrough;
}
} -document {
<div>Hello</div>
} -body {
set node [lindex [.h search div] 0]
list [$node property color] [$node property text-decoration]
} -result {green underline}
#---------------------------------------------------------------------
syntaxtest syntax-4.0 -style {
@media all and (min-width: 0px) {
#primary {
margin-left: 0px;
padding-left: 0;
}
}
div {color:green}
} -document {
<div>Hello</div>
} -body {
set node [lindex [.h search div] 0]
$node property color
} -result {green}
finish_test
|