
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
}


