File: events.bt

package info (click to toggle)
tk-html3 3.0~fossil20110109-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,644 kB
  • ctags: 5,882
  • sloc: ansic: 48,994; tcl: 26,030; sh: 1,190; yacc: 161; makefile: 24
file content (93 lines) | stat: -rw-r--r-- 2,029 bytes parent folder | download | duplicates (5)
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

if 0 {_

#------------------------------------------------------------------------
# This is a "warm-body" test for the events module.
#
::browsertest::do_test events.1 -timeout 10000000 -html {
  <BODY>
    <SCRIPT>

      document.testlog = ""
      function log_node(elem) {
        if (document.testlog != "") document.testlog += " "
        document.testlog += elem.id
      }

    </SCRIPT>
      <DIV id="one" onclick="log_node(this)">
        <DIV id="two" onclick="log_node(this)">
          <DIV id="three" onclick="log_node(this)">
            Hello Hello

} -javascript {

  /* Create a synthetic mouse event. */
  var e = document.createEvent("MouseEvents")
  e.initMouseEvent(
      "click", true, true, window, 0, 0, 0, 0, 0, 
      false, false, false, false, 0, null
  );

  /* Dispatch the event to the <DIV id="three"> element. It should
   * bubble up through <DIV id="two"> and <DIV id="one" blocks.
   */
  document.getElementById("three").dispatchEvent(e)

  return document.testlog
} -expected "three two one"

}

proc slow_html {channel} {
puts SLOWHTML
  slow_part1 $channel {
HTTP/1.1 200 OK
Content-type: text/html
Cache-Control: no-cache

<p> Paragraph 1</p>
} {
<p> Paragraph 2</p>
}
}

proc slow_css {channel} {
  slow_part1 $channel {
HTTP/1.1 200 OK
Content-type: text/css
Cache-Control: no-cache

} {
.tall { height: 500px }
}
}

proc slow_part1 {channel data1 data2} {
  puts -nonewline $channel [string trimleft $data1]
  flush $channel
  after 1000 [list slow_part2 $channel $data2]
}

proc slow_part2 {channel data} {
  puts -nonewline $channel $data
  flush $channel
  close $channel
}

# This is to test that the browser waits until all stylesheets are 
# downloaded and applied before firing the "onload" event.
#
do_browser_test events.1 -timeout 10000000 -html {
  <STYLE> 
    @import "/tcl?script=slow_css";
    div { height: 50px }
  </STYLE>
  <BODY>
    <DIV class="tall" id="me">hello</DIV>
} -javascript {
  var div = document.getElementById("me")
  return div.offsetHeight
}