Ariya Hidayat 2014-09-17 21:57:42 -07:00
parent 9c7753189f
commit b36da277e9
3 changed files with 29 additions and 12 deletions

View File

@ -0,0 +1,20 @@
var assert = require('../../assert');
var webpage = require('webpage');
var ua = 'PHANTOMJS-TEST-USER-AGENT';
var page = webpage.create({
settings: {
userAgent: ua
}
});
assert.equal(page.settings.userAgent, ua);
page.open('http://localhost:9180/user-agent.html', function (status) {
assert.equal(status, 'success');
var agent = page.evaluate(function() {
return document.getElementById('ua').textContent;
});
assert.equal(agent, ua);
});

View File

@ -1290,18 +1290,6 @@ describe("WebPage construction with options", function () {
});
});
describe("specifying userAgent", function () {
var opts = {
settings: {
userAgent: "PHANTOMJS-TEST-USER-AGENT"
}
};
var page = new WebPage(opts);
it("should have userAgent as '"+opts.settings.userAgent+"'",function () {
expect(page.settings.userAgent).toEqual(opts.settings.userAgent);
});
});
describe("specifying viewportSize", function () {
var opts = {
viewportSize: {

9
test/www/user-agent.html Normal file
View File

@ -0,0 +1,9 @@
<html>
<head>
<title>User Agent</title>
</head>
<body>
<p>User agent is: <span id="ua">Unknown</span>.</p>
<script>document.getElementById('ua').textContent = navigator.userAgent</script>
</body>
</html>