Skip to content

Instantly share code, notes, and snippets.

@bernardeli
Created June 13, 2014 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernardeli/619732037624c1a8872d to your computer and use it in GitHub Desktop.
Save bernardeli/619732037624c1a8872d to your computer and use it in GitHub Desktop.
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