PhantomJS rewriting URL in backgroundImage property to local file system -
i using phantomjs rewriting of html. i'm adding background-image
property element. when write out resulting dom, url has been rewritten local url. i've boiled down following test case:
js
var page = require('webpage').create(); page.open("test.html",function(){ settimeout(function(){ page.evaluate(function(){ document.getelementbyid("test").style.backgroundimage="url(test.png)"; }); console.log(page.content); phantom.exit(); },1000); });
html
<html> <body> <div id="test"></div> </body> </html>
output
$ phantomjs test.js <html><head></head><body> <div id="test" style="background-image: url(file:///c:/cygwin/tmp/test.png); "> </div> </body></html>
update
the problem remains if specify
./test.png
or//test.png
. however,http://example.com/test.png
left unchanged, might expected.if html document opened in chrome, ,
background-image
property addeddiv
element in style inspector, url unmodified, whether document inspected in elements tab in devtools, or viadocument.body.innerhtml
displayed in console, or copying html.
update 2
i found out if document located in chrome, , command elt.style.backgroundimage="url(test.png");
issued in console, url rewritten. @ end of day appears not phantomjs issue, although still don't understand behavior.
obviously, don't want url rewritten in fashion, , don't understand why phantomjs feels need this. ideas?