Add protocol implementation for js/Window conditionally

Phantomjs has no js/Window, so generated code would fail on load without
the check.