<!doctype html>
<html>
<head>
  <title>Inserted Fragment Touch Target</title>
  <style>
  body {
      margin: 0;
      padding: 0;
  }

  .container {
      position: absolute;
      top: 10px;
      left: 10px;
      width: 50px;
      height: 50px;
      border: 1px solid green;
  }

  .target {
      width: 40px;
      height: 40px;
      background-color: red;
  }

  #results {
    position: absolute;
    top: 100px;
  }
  </style>
  <script src="resources/misc-touch-helpers.js"></script>
  <script>

    // While this isn't a particularly nice approach to the solution,
    // it is a direct copy from the original bug report.
    function createElementsFromString(input) {
        var div = document.createElement("div");
        div.innerHTML = input;
        var children = div.children;
        var fragment = document.createDocumentFragment();
        for (var i = 0, length = children.length; i < length; i++) {
            fragment.appendChild(children[0])
        }
        return fragment.firstChild;
    }

    function targetTouched(event) {
        logTouch(event);
        debug("PASSED");
        if (window.testRunner)
            testRunner.notifyDone();
    }

    function init() {
        var target = createElementsFromString("<div class='target'>This is the <strong>touch target</strong>.</div>");
        target.addEventListener("touchstart", targetTouched, false);
        var container = document.querySelector(".container");
        container.appendChild(target);
        debug("Should see a single touch at 20,20");
        tapSoon(20, 20);
    }

    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    window.addEventListener("load", init, false);
</script>
</head>
<body>
  <div class="container">
  </div>
  <div id="results">
  </div>
</body>
</html>
