<script>
function LayoutTestController() {
  this.wait_until_done_ = false;
  this.dumpAsText = function () { };
  this.waitUntilDone = function () {
    this.wait_until_done_ = true;
  };
  this.notifyDone = function () {
    var cookie = "%COOKIE%=" + encodeURIComponent(document.firstChild.innerText);
    document.cookie = cookie;
  };
  this.OnTimerEvent = function () {
    // Some layout tests do not call waitUntilDone.  If this is true, we should
    // assume the test is done when it's finished loading.
    if (!this.wait_until_done_)
      layoutTestController.notifyDone();
  };
  this.OnLoadEvent = function (event) {
    // Do a timeout to ensure that we run after all other onload handlers have
    // finished.
    setTimeout(layoutTestController.OnTimerEvent, 0);
  };
}
window.layoutTestController = new LayoutTestController();
window.addEventListener('load', layoutTestController.OnLoadEvent, false);
</script>

<script>
function LayoutTestController() {
  this.dump_as_text_ = false;
  this.wait_until_done_ = false;
  this.dumpAsText = function () {
    this.dump_as_text_ = true;
  };
  this.waitUntilDone = function () {
    this.wait_until_done_ = true;
  };
  this.notifyDone = function () {
    var cookie = "%COOKIE%=" + encodeURIComponent(document.firstChild.innerText);
    document.cookie = cookie;
  };
  this.OnCheckFinishEvent = function () {
    // Some layout tests do not call waitUntilDone.  If this is true, we should
    // assume the test is done when it's finished loading.
    if (!layoutTestController.wait_until_done_)
      layoutTestController.notifyDone();
  };
  this.OnTimerEvent = function () {
    // Some layout tests put the script in the body part which causes it to be
    // executed after onload being triggered. To handle this, we check first if
    // dumpAsText() is called.
    if (layoutTestController.dump_as_text_)
      layoutTestController.OnCheckFinishEvent();
    else
      setTimeout(layoutTestController.OnTimerEvent, 200);
  };
  this.OnLoadEvent = function (event) {
    // Do a timeout to ensure that we run after all other onload handlers have
    // finished.
    setTimeout(layoutTestController.OnTimerEvent, 0);
  };
}
window.layoutTestController = new LayoutTestController();
window.addEventListener('load', layoutTestController.OnLoadEvent, false);
</script>

Fix layout test controller simulation script to make it work for worker UI test.
Fix layout test controller simulation script to make it work for worker UI test.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/160670

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@22527 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
