tmpvar/jsdom — pull request #936 by rgrove (2014-11-04 20:55:22+00:00)
Title: History: Initial length should be 1, not 0, and pushState() / replaceState() shouldn't fire popstate events

Two `window.history` bug fixes, the first of which was necessary to properly test the second:

## Initial history.length should be 1, not 0

This brings jsdom in line with both the spec and with browsers, and fixes an issue where calling `history.pushState()` and then `history.back()` would fail to trigger a `popstate` event for the `back()` call, since there was no initial history entry to navigate back to.

From https://html.spec.whatwg.org/multipage/browsers.html#browsing-context:

> When a browsing context is first created, it must be created with a single Document in its session history [...]

## pushState() and replaceState() shouldn't fire popstate events

The spec doesn't say that `pushState()` or `replaceState()` should trigger a `popstate` event, and browsers don't fire a `popstate` event after a `pushState()` or `replaceState()` call. `popstate` should only be fired during traversal.

See https://html.spec.whatwg.org/multipage/browsers.html#history-1