Code and specs for onPopState