Bug 1043648 Calling `window.stop` in page-worker's content script cause error in console

- Set `contentWorker` before add the listeners for `pageshow` / `pagehide`
- Unit test added
Merge pull request #1564 from ZER0/worker-null/1043648

fix Bug 1043648 Calling `window.stop` in page-worker's content script cause error in console r=@jsantell