Html程序  |  41行  |  1.24 KB

<html>
  <head>
    <script>
      function getNextURL() {
        var url = location.href;
        var queryIndex = url.indexOf("?");
        var loadCount = 1;
        if (queryIndex >= 0) {
          loadCount = parseInt(url.substring(queryIndex + 1));
          if (loadCount >= 20)
            return "";

          url = url.substring(0, queryIndex);
        }
        return url + '?' + (loadCount + 1);
      }

      function start() {
        var video = document.getElementById('iframe1').contentDocument.querySelector('video');
        var documentElement = document.documentElement;
        document.body.appendChild(video);
        var iframe  = document.querySelector('#iframe1');
        iframe.parentNode.removeChild(iframe);

        var url = getNextURL();
        if (url.length == 0)
          return;

        location.href = url;
      }
    </script>
  </head>
  <body onload='start()'>
    <p>Test for <a href="https://code.google.com/p/chromium/issues/detail?id=230117">Bug 230117</a><br>
      This page should reload itself 20 times without crashing the tab. The test is complete when the page
      stops reloading itself and the page URL ends with a ?20.
    </p>
    <iframe id="iframe1" src="video-iframe.html"></iframe>
  </body>
</html>