Let's go ahead and execute async js in frames too.

This commit is contained in:
Jason Carr
2013-04-02 09:51:44 -07:00
parent e97bf90c56
commit 794ca0f417
2 changed files with 24 additions and 2 deletions

View File

@@ -270,7 +270,7 @@ RemoteDebugger.prototype.executeAtomAsync = function(atom, args, frames, respons
for (var i = 0; i < frames.length; i++) {
script = this.wrapScriptForFrame(script, frames[i]);
}
script += "(" + args.join(',') + ")";
script += "(" + args.join(',') + ", " + asyncCallBack + ", true )";
} else {
logger.info("Executing atom in default context");
script += "(" + atomSrc + ")(" + args.join(',') + ", " + asyncCallBack + ", true )";

View File

@@ -608,13 +608,24 @@ module.exports.buildTests = function(webviewType) {
});
it('should be able to return multiple elements from javascript', function(done) {
loadWebView(h.driver, function() {
h.driver.execute('return document.getElementsByTagName("a")', function(err, res) {
h.driver.execute('return document.getElementsByTagName("a");', function(err, res) {
should.not.exist(err);
res[0].ELEMENT.should.equal('5000');
done();
});
});
});
it('should execute javascript in frame', function(done) {
loadWebView(h.driver, function() {
h.driver.frame("first", function(err) {
should.not.exist(err);
h.driver.execute("return document.title;", function(err, res) {
res.should.equal("Sub frame 1");
done()
});
});
}, testEndpoint + 'frameset.html', "Frameset guinea pig");
});
});
desc("executeAsync", function(h) {
@@ -649,6 +660,17 @@ module.exports.buildTests = function(webviewType) {
});
});
});
it.only('should execute async javascript in frame', function(done) {
loadWebView(h.driver, function() {
h.driver.frame("first", function(err) {
should.not.exist(err);
h.driver.executeAsync("arguments[arguments.length - 1](document.title);", function(err, res) {
res.should.equal("Sub frame 1");
done()
});
});
}, testEndpoint + 'frameset.html', "Frameset guinea pig");
});
});
desc('alerts', function(h) {