<!doctype html>
<script>
var o = opener;

var frameloaded = null;

o.t.step(function() {o.assert_equals(history.length, 1)});

onload = function () {
  o.t.step(function() {
    o.assert_equals(history.length, 1);
    o.t.done();
  });

  o.t1.step(function() {
    var iframe = document.createElement("iframe");
    iframe.src = "filler.html?id=2";
    document.body.appendChild(iframe);
    frameloaded = o.t1.step_func(function () {
      o.assert_equals(history.length, 1);
      setTimeout(o.t1.step_func(function () {
        o.assert_equals(history.length, 1);
        iframe.src = "filler.html?id=3";
        frameloaded = o.t2.step_func(function() {
          o.assert_equals(history.length, 2);
          history.go(-1);
          frameloaded = o.t3.step_func(function() {
            o.assert_equals(history.length, 2);
            var parts = iframe.contentWindow.location.href.split("/")
            o.assert_equals(parts[parts.length - 1], "filler.html?id=2");
            o.t3.done();
            o.t4.step(function() {
              var iframe0 = document.getElementsByTagName("iframe")[0];
              iframe0.src = "filler.html?id=4"
              frameloaded = o.t4.step_func(function() {
                o.assert_equals(history.length, 2);
                var parts = iframe0.contentWindow.location.href.split("/")
                o.assert_equals(parts[parts.length - 1], "filler.html?id=4");
                //This is the point at which gecko and webkit stop running tests
                history.go(-1);
                frameloaded = o.t5.step_func(function() {
                  o.assert_equals(history.length, 2);
                  var parts = iframe0.contentWindow.location.href.split("/")
                  o.assert_equals(parts[parts.length - 1], "filler.html?id=1");
                  var parts = iframe.contentWindow.location.href.split("/")
                  o.assert_equals(parts[parts.length - 1], "filler.html?id=2");
                  history.go(1);
                  frameloaded = o.t6.step_func(function() {
                    o.assert_equals(history.length, 2);
                    var parts = iframe0.contentWindow.location.href.split("/")
                    o.assert_equals(parts[parts.length - 1], "filler.html?id=4");
                    var parts = iframe.contentWindow.location.href.split("/")
                    o.assert_equals(parts[parts.length - 1], "filler.html?id=2");
                    o.t6.done();
                  });
                  o.t5.done();
                });
                o.t4.done();
              });
            });
          });
          o.t2.done();
        });
        o.t1.done();
      }, 500))
    });
  });

}
</script>

<iframe src="filler.html?id=1"></iframe>
