Bug 958170: Check selectedWindow exists before using it. r=mbrubeck