Fix Chrome error when placing caret on focus

This also adds a `givenContentOf` helper in the tests, which clicks in the
editor and then sets the content, and also wraps it in a `given` block.