[webkit-help] call window.open from console with relative url doesn't work

Rafael Hengles delorean.br at gmail.com
Mon Mar 12 07:44:29 PDT 2012


Hello,

I'm developing a Safari extension to make automated tests on a site.
Basically, I need to verify that all external links (which url is on
another domain) trigger a "onclick" handler and open a window with a
message like "you're leaving this site. [ok] [cancel]".

The problem is, the "onclick" handler that is on the site is calling
window.open with a relative url (without the domain). Example:
[code]
<script>
function speedbump(url) {
    window.open('/speedbump?'+url, '_blank', 'width=300');
    return false;
}
</script>
<a href="http://domain.tld/>" onclick="return
speedbump(this.href);">External Link</a>
[/code]

When I try to call that onclick from the console, the popup open blank
and with this message in its console:
Not allowed to load local resource: file:///speedbump?http://domain.tld/

But if I click normally on the link, the popup load correctly.

Is this behaviour expected or is it a bug? Why calling window.open
from the console with a relative url doesn't load relative to the
page's address?

Also, this works on Chrome - the popup load from the current page's
domain. Why the difference between Safari and Chrome?

Thanks.


More information about the webkit-help mailing list