diff --git a/lib/actions.js b/lib/actions.js index e40fa0b..c6f6daa 100644 --- a/lib/actions.js +++ b/lib/actions.js @@ -86,6 +86,24 @@ exports.open = function(url, method) { }); }; +/** + * Load HTML content with fake URL in Phantom. + * @param {string} html HTML Content to set + * @param {string} url URL to use for page + * @see {@link http://phantomjs.org/api/webpage/method/set-content.html|PhantomJS API} + */ +exports.setContent = function(html, url) { + var self = this; + self.targetUrl = url; + + return this.ready.then(function() { + debug('.setContent()', html, url); + return HorsemanPromise.fromCallback(function(done) { + self.page.setContent(html, url, done); + }); + }); +}; + /** * Set headers sent to the remote server during an 'open'. * @param {Object[]} headers diff --git a/test/files/set-content-test.html b/test/files/set-content-test.html new file mode 100644 index 0000000..a35b2ee --- /dev/null +++ b/test/files/set-content-test.html @@ -0,0 +1,10 @@ + + +
+ +