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
|
# This test script tests some browser behaviour related to encodings
# (charsets). Test plan is as follows:
#
# encoding.1.* - Test that charsets specified as both HTTP
# Content-Type headers or their <meta> tag equivalents
# are handled.
#
# encoding.2.* - Test that Hv3 works around the polipo bug. This is
# only really important for Hv3.
#
set str "\xC0\xC1"
set encoding.1.javascript {
var div = document.getElementById("div");
var str = div.firstChild.data
return str.charCodeAt(0) + "." + str.charCodeAt(1)
}
#--------------------------------------------------------------------------
# START encoding.1.*
#
# Test with no <meta> tag and no Content-Type header.
#
do_browser_test encoding.1.1 -html [subst {
<DIV id="div">[encoding convertto iso8859-1 $str]</DIV>
}] -javascript ${encoding.1.javascript}
# Test with a <meta> tag only.
#
do_browser_test encoding.1.2 -html [subst {
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<DIV id="div">[encoding convertto utf-8 $str]</DIV>
}] -javascript ${encoding.1.javascript}
# Test with Content-Type header only.
#
do_browser_test encoding.1.3 -encoding utf-8 -html [subst {
<DIV id="div">[encoding convertto utf-8 $str]</DIV>
}] -javascript ${encoding.1.javascript}
# Test with Content-Type and matching <meta> tag.
#
do_browser_test encoding.1.4 -encoding utf-8 -html [subst {
<META http-equiv="Content-Type" content="text/html; charset=utf-8" >
<DIV id="div">[encoding convertto utf-8 $str]</DIV>
}] -javascript ${encoding.1.javascript}
# Test with Content-Type and conflicting <meta> tag. In this case the
# Content-Type should take precedence. Previous versions of Hv3 had
# this wrong.
#
do_browser_test encoding.1.5 -encoding utf-8 -html [subst {
<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
<DIV id="div">[encoding convertto utf-8 $str]</DIV>
}] -javascript ${encoding.1.javascript}
# Test with an incorrect <meta> tag only. In this case firefox does not
# do any encoding detection - it just uses the explicitly specified
# one in the same way as Hv3.
#
do_browser_test encoding.1.6 -html [subst {
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<DIV id="div">[encoding convertto utf-8 $str]</DIV>
}] -javascript ${encoding.1.javascript}
#
# END encoding.1.*
#--------------------------------------------------------------------------
proc enc_slow_css {channel} {
enc_slow_part1 $channel {
HTTP/1.1 200 OK
Content-type: text/css
Cache-Control: s-maxage=10
.hello { color: green }
} {
.tall { height: 500px }
}
}
proc enc_slow_part1 {channel data1 data2} {
puts -nonewline $channel [string trimleft $data1]
flush $channel
after 1000 [list enc_slow_part2 $channel $data2]
}
proc enc_slow_part2 {channel data} {
puts -nonewline $channel $data
flush $channel
close $channel
}
do_browser_test encoding.2.1 -html {
<style> @import "/tcl?script=enc_slow_css" ; </style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<DIV id="div" class="tall">...
</DIV>
} -javascript {
return document.getElementById("div").offsetHeight
}
|