  win.history.back();
  });
}

let DELAY = 500;

promise_test(t => {
  // Create a new window so we can navigate it later.
  return with_window_by_name('foo').then(win => {
    // Schedule a timer within the new window.  Our intent is
    // to navigate the window before the timer fires.
    let delayFired = false;
    let innerDelay = delay(win, DELAY);
    innerDelay.then(_ => {
      delayFired = true;
    });

    return navigate_by_name(win, 'bar').then(_ => {
      // Since the window has navigated th