Bug 847840 - TEST-UNEXPECTED-FAIL | tests/test-selection.test Selection Listener on frame

Tried to wait the `document-shown` notification before resolve the window, and also move the shutdown functions (`close`, `loader.unload`, `done`) for the test that sometimes is failing.

Not sure this will fix the issue because I'm not able to reproduce it, but let's give a try.