Created
June 13, 2014 06:56
-
-
Save bernardeli/619732037624c1a8872d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webpage = require('webpage'), | |
q = require('sdk/core/promise'); | |
var page = webpage.create(); | |
var render = function(){ | |
page.render("~/google-image.png"); | |
}; | |
var modify = function(){ | |
var deferred = q.defer(); | |
// Can't find a way to get the window object and this makes the firefox to hang up | |
page.window.document.write("<h1>Hey</h1>"); | |
if (page.window.readyState === 'complete') { | |
deferred.resolve(); | |
} | |
return deferred.promise; | |
}; | |
page.open("http://google.com").then(modify).then(render); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment