Bug 123983

Summary: window.Location is undefined
Product: WebKit Reporter: Tom Van Goethem <tomvangoethem>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WORKSFORME    
Severity: Normal CC: ap, mathias
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.8   

Description Tom Van Goethem 2013-11-07 03:08:47 PST
The following script will throw a TypeError ('undefined' is not a valid argument for 'instanceof' (evaluating 'window.location instanceof window.Location')) because window.Location is undefined
<script>
if (window.location instanceof window.Location) {
  console.log('ok');
}
</script>

Other browsers I tested (Chrome 30.0/FireFox 24.0) do not have this issue.
Comment 1 Mathias Bynens 2013-11-07 03:20:18 PST
Minimal test case:

data:text/html,<script>var%20result%20=%20'FAIL';%20try%20{%20if%20(window.location%20instanceof%20window.Location)%20{%20result%20=%20'PASS';%20}%20}%20catch(e)%20{}%20document.write(result);</script>

FWIW, I get PASS on WebKit nightly r158804.
Comment 2 Tom Van Goethem 2013-11-07 03:29:00 PST
> Minimal test case:
> 
> data:text/html,<script>var%20result%20=%20'FAIL';%20try%20{%20if%20(window.location%20instanceof%20window.Location)%20{%20result%20=%20'PASS';%20}%20}%20catch(e)%20{}%20document.write(result);</script>
> 
> FWIW, I get PASS on WebKit nightly r158804.

This returns FAIL on Safari 6.0.5 (8536.30.1), Mac OS X 10.8.5 and Safari 6.0 (8536.25), iOS 6.1.3
Comment 3 Alexey Proskuryakov 2013-11-07 09:32:12 PST
window.Location has been supported for a long time. There might have been some issue with instanceof, but Safari 6.0.5 is ancient history, and so is iOS 6.

This test works as expected in Safari 7.