def action_follow(self, target, param): if isinstance(target, xpath): yield target._asjs(js.targetNode) else: yield livepage.var(js.targetNode, gid(target)), livepage.eol yield [ js.addLoadObserver(self.checkException()), livepage.eol, js.setContentLocation(js.targetNode.href)]
def action_visit(self, action, target, parameter): def observeLoading(client, location): if location.endswith(target): self.passed() else: self.failed() return ["addLoadObserver(function() {", livepage.handler( observeLoading, contentDocument.location), "});", js.setContentLocation(target)]
def action_visit(self, action, target, parameter): ## TODO: Figure out how to detect a 404 using javascript def observeLoading(client, location): if location.endswith(target): self.passed() else: self.failed() return [ "addLoadObserver(function() {", livepage.handler(observeLoading, contentDocument.location), "});", js.setContentLocation(target) ]
def action_follow(self, action, target, parameter): def observeFollowing(client, location, destination): if location.endswith(destination): self.passed() else: self.failed() return [ "var theTargetNode = ", contentDocument.getElementById(target), ";", "var theDestinationAddress = theTargetNode.href;", "addLoadObserver(function() {", livepage.handler(observeFollowing, contentDocument.location, js.theDestinationAddress), "});", js.setContentLocation(js.theDestinationAddress) ]
def action_follow(self, action, target, parameter): def observeFollowing(client, location, destination): if location.endswith(destination): self.passed() else: self.failed() return [ "var theTargetNode = ", contentDocument.getElementById(target), ";", "var theDestinationAddress = theTargetNode.href;", "addLoadObserver(function() {", livepage.handler( observeFollowing, contentDocument.location, js.theDestinationAddress), "});", js.setContentLocation(js.theDestinationAddress)]
def action_visit(self, target, param): yield js.addLoadObserver(self.checkException()), livepage.eol yield js.setContentLocation(target), livepage.eol