Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

location.href is evaluated as JavaScript code #379

Closed
vschoettke opened this Issue · 0 comments

2 participants

@vschoettke

When a javascript: link executes a function that sets the location.href the new location is evaluated as JavaScript instead of loading the url

Here is a simple example:

var zombie = require('zombie');
var browser = new zombie.Browser();
browser.evaluate('function test() { location.href="/test/page.html"; }');
browser.evaluate('document.write(\'<a href="javascript:test()">Test</a>\');');
browser.clickLink('a');

browser.error will be:
[SyntaxError: Invalid flags supplied to RegExp constructor 'page']

The cause seems to be that the url context of the executed script is not the page url but rather the url of the execution ("javascript:"). So when a script that was called via a javascript: url sets the location.href zombie.js will try to execute the content of location.href because url.protocol is still "javascript:". See history.coffee 's _pageChanged and _resource functions.

@assaf assaf closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.