This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c1a2950
Showing
51 changed files
with
3,781 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of the <organization> nor the | ||
names of its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# [PhantomJS](http://phantomjs.org) - Scriptable Headless WebKit | ||
|
||
PhantomJS ([phantomjs.org](http://phantomjs.org)) is a headless WebKit scriptable with JavaScript. The latest [stable release](http://phantomjs.org/release-2.0.html) is version 2.0. | ||
|
||
**Note**: Please **do not** create a GitHub pull request **without** reading the [Contribution Guide](https://github.com/ariya/phantomjs/blob/master/CONTRIBUTING.md) first. Failure to do so may result in the rejection of the pull request. | ||
|
||
## Use Cases | ||
|
||
- **Headless web testing**. Lightning-fast testing without the browser is now possible! | ||
- **Page automation**. [Access and manipulate](http://phantomjs.org/page-automation.html) web pages with the standard DOM API, or with usual libraries like jQuery. | ||
- **Screen capture**. Programmatically [capture web contents](http://phantomjs.org/screen-capture.html), including CSS, SVG and Canvas. Build server-side web graphics apps, from a screenshot service to a vector chart rasterizer. | ||
- **Network monitoring**. Automate performance analysis, track [page loading](http://phantomjs.org/network-monitoring.html) and export as standard HAR format. | ||
|
||
## Features | ||
|
||
- **Multiplatform**, available on major operating systems: Windows, Mac OS X, Linux, and other Unices. | ||
- **Fast and native implementation** of web standards: DOM, CSS, JavaScript, Canvas, and SVG. No emulation! | ||
- **Pure headless (no X11) on Linux**, ideal for continuous integration systems. Also runs on Amazon EC2, Heroku, and Iron.io. | ||
- **Easy to install**: [Download](http://phantomjs.org/download.html), unpack, and start having fun in just 5 minutes. | ||
|
||
## Questions? | ||
|
||
- Explore the complete [documentation](http://phantomjs.org/documentation/). | ||
- Read tons of [user articles](http://phantomjs.org/buzz.html) on using PhantomJS. | ||
- Join the [mailing-list](http://groups.google.com/group/phantomjs) and discuss with other PhantomJS fans. | ||
|
||
PhantomJS is free software/open source, and is distributed under the [BSD license](http://opensource.org/licenses/BSD-3-Clause). It contains third-party code, see the included `third-party.txt` file for the license information on third-party code. | ||
|
||
PhantomJS is created and maintained by [Ariya Hidayat](http://ariya.ofilabs.com/about) (Twitter: [@ariyahidayat](http://twitter.com/ariyahidayat)), with the help of [many contributors](https://github.com/ariya/phantomjs/contributors). Follow the official Twitter stream [@PhantomJS](http://twitter.com/PhantomJS) to get the frequent development updates. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# PhantomJS 2.1.1 - Scriptable Headless WebKit | ||
## Built for Linux armv7l. | ||
|
||
This deployment was built on a fresh Raspbian Jessie Lite 2016-11-25 running on a Raspberry Pi Raspberry Pi 2 Model B. The operating system was fully up to date at the time of the build which was started on December 1st, 2016. It was built using the instructions located on the official PhantomJS website. The following are the commands which were used to build this deployment package. | ||
|
||
### Build Steps | ||
|
||
Install the packages needed to build PhantomJS using apt-get. | ||
``` | ||
sudo apt-get install build-essential g++ flex bison gperf ruby perl \ | ||
libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \ | ||
libpng-dev libjpeg-dev python libx11-dev libxext-dev | ||
``` | ||
Obtain the source code needed to build PhantomJS using Git. | ||
``` | ||
git clone git://github.com/ariya/phantomjs.git | ||
cd phantomjs | ||
git checkout 2.1.1 | ||
git submodule init | ||
git submodule update | ||
``` | ||
I changed the next command in order to get a good compile without any out of memory errors. By limiting the jobs to one processor things were apparently slowed down enough that the Raspberry Pi 2 Model B was able to keep up while swapping out memory thus allowing for a build which did not encounter any out of memory errors. This made for a VERY LONG compile time measurable in hours but resulted in a good build. | ||
``` | ||
python build.py -j 1 | ||
``` | ||
The final step was to package the files. | ||
``` | ||
./deploy/package.sh | ||
``` | ||
The archive loccated on the release page are the untouched results of the build. |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
var system = require('system'); | ||
if (system.args.length === 1) { | ||
console.log('Try to pass some args when invoking this script!'); | ||
} else { | ||
system.args.forEach(function (arg, i) { | ||
console.log(i + ': ' + arg); | ||
}); | ||
} | ||
phantom.exit(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use strict"; | ||
var spawn = require("child_process").spawn | ||
var execFile = require("child_process").execFile | ||
|
||
var child = spawn("ls", ["-lF", "/rooot"]) | ||
|
||
child.stdout.on("data", function (data) { | ||
console.log("spawnSTDOUT:", JSON.stringify(data)) | ||
}) | ||
|
||
child.stderr.on("data", function (data) { | ||
console.log("spawnSTDERR:", JSON.stringify(data)) | ||
}) | ||
|
||
child.on("exit", function (code) { | ||
console.log("spawnEXIT:", code) | ||
}) | ||
|
||
//child.kill("SIGKILL") | ||
|
||
execFile("ls", ["-lF", "/usr"], null, function (err, stdout, stderr) { | ||
console.log("execFileSTDOUT:", JSON.stringify(stdout)) | ||
console.log("execFileSTDERR:", JSON.stringify(stderr)) | ||
}) | ||
|
||
setTimeout(function () { | ||
phantom.exit(0) | ||
}, 2000) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"use strict"; | ||
var page = require('webpage').create(); | ||
page.viewportSize = { width: 400, height : 400 }; | ||
page.content = '<html><body><canvas id="surface"></canvas></body></html>'; | ||
page.evaluate(function() { | ||
var el = document.getElementById('surface'), | ||
context = el.getContext('2d'), | ||
width = window.innerWidth, | ||
height = window.innerHeight, | ||
cx = width / 2, | ||
cy = height / 2, | ||
radius = width / 2.3, | ||
imageData, | ||
pixels, | ||
hue, sat, value, | ||
i = 0, x, y, rx, ry, d, | ||
f, g, p, u, v, w, rgb; | ||
|
||
el.width = width; | ||
el.height = height; | ||
imageData = context.createImageData(width, height); | ||
pixels = imageData.data; | ||
|
||
for (y = 0; y < height; y = y + 1) { | ||
for (x = 0; x < width; x = x + 1, i = i + 4) { | ||
rx = x - cx; | ||
ry = y - cy; | ||
d = rx * rx + ry * ry; | ||
if (d < radius * radius) { | ||
hue = 6 * (Math.atan2(ry, rx) + Math.PI) / (2 * Math.PI); | ||
sat = Math.sqrt(d) / radius; | ||
g = Math.floor(hue); | ||
f = hue - g; | ||
u = 255 * (1 - sat); | ||
v = 255 * (1 - sat * f); | ||
w = 255 * (1 - sat * (1 - f)); | ||
pixels[i] = [255, v, u, u, w, 255, 255][g]; | ||
pixels[i + 1] = [w, 255, 255, v, u, u, w][g]; | ||
pixels[i + 2] = [u, u, w, 255, 255, v, u][g]; | ||
pixels[i + 3] = 255; | ||
} | ||
} | ||
} | ||
|
||
context.putImageData(imageData, 0, 0); | ||
document.body.style.backgroundColor = 'white'; | ||
document.body.style.margin = '0px'; | ||
}); | ||
|
||
page.render('colorwheel.png'); | ||
|
||
phantom.exit(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
var t = 10, | ||
interval = setInterval(function(){ | ||
if ( t > 0 ) { | ||
console.log(t--); | ||
} else { | ||
console.log("BLAST OFF!"); | ||
phantom.exit(); | ||
} | ||
}, 1000); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Detect if a web page sniffs the user agent or not. | ||
|
||
"use strict"; | ||
var page = require('webpage').create(), | ||
system = require('system'), | ||
sniffed, | ||
address; | ||
|
||
page.onInitialized = function () { | ||
page.evaluate(function () { | ||
|
||
(function () { | ||
var userAgent = window.navigator.userAgent, | ||
platform = window.navigator.platform; | ||
|
||
window.navigator = { | ||
appCodeName: 'Mozilla', | ||
appName: 'Netscape', | ||
cookieEnabled: false, | ||
sniffed: false | ||
}; | ||
|
||
window.navigator.__defineGetter__('userAgent', function () { | ||
window.navigator.sniffed = true; | ||
return userAgent; | ||
}); | ||
|
||
window.navigator.__defineGetter__('platform', function () { | ||
window.navigator.sniffed = true; | ||
return platform; | ||
}); | ||
})(); | ||
}); | ||
}; | ||
|
||
if (system.args.length === 1) { | ||
console.log('Usage: detectsniff.js <some URL>'); | ||
phantom.exit(1); | ||
} else { | ||
address = system.args[1]; | ||
console.log('Checking ' + address + '...'); | ||
page.open(address, function (status) { | ||
if (status !== 'success') { | ||
console.log('FAIL to load the address'); | ||
phantom.exit(); | ||
} else { | ||
window.setTimeout(function () { | ||
sniffed = page.evaluate(function () { | ||
return navigator.sniffed; | ||
}); | ||
if (sniffed) { | ||
console.log('The page tried to sniff the user agent.'); | ||
} else { | ||
console.log('The page did not try to sniff the user agent.'); | ||
} | ||
phantom.exit(); | ||
}, 1500); | ||
} | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// echoToFile.js - Write in a given file all the parameters passed on the CLI | ||
"use strict"; | ||
var fs = require('fs'), | ||
system = require('system'); | ||
|
||
if (system.args.length < 3) { | ||
console.log("Usage: echoToFile.js DESTINATION_FILE <arguments to echo...>"); | ||
phantom.exit(1); | ||
} else { | ||
var content = '', | ||
f = null, | ||
i; | ||
for ( i= 2; i < system.args.length; ++i ) { | ||
content += system.args[i] + (i === system.args.length-1 ? '' : ' '); | ||
} | ||
|
||
try { | ||
fs.write(system.args[1], content, 'w'); | ||
} catch(e) { | ||
console.log(e); | ||
} | ||
|
||
phantom.exit(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use strict"; | ||
var feature, supported = [], unsupported = []; | ||
|
||
phantom.injectJs('modernizr.js'); | ||
console.log('Detected features (using Modernizr ' + Modernizr._version + '):'); | ||
for (feature in Modernizr) { | ||
if (Modernizr.hasOwnProperty(feature)) { | ||
if (feature[0] !== '_' && typeof Modernizr[feature] !== 'function' && | ||
feature !== 'input' && feature !== 'inputtypes') { | ||
if (Modernizr[feature]) { | ||
supported.push(feature); | ||
} else { | ||
unsupported.push(feature); | ||
} | ||
} | ||
} | ||
} | ||
|
||
console.log(''); | ||
console.log('Supported:'); | ||
supported.forEach(function (e) { | ||
console.log(' ' + e); | ||
}); | ||
|
||
console.log(''); | ||
console.log('Not supported:'); | ||
unsupported.forEach(function (e) { | ||
console.log(' ' + e); | ||
}); | ||
phantom.exit(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
var fibs = [0, 1]; | ||
var ticker = window.setInterval(function () { | ||
console.log(fibs[fibs.length - 1]); | ||
fibs.push(fibs[fibs.length - 1] + fibs[fibs.length - 2]); | ||
if (fibs.length > 10) { | ||
window.clearInterval(ticker); | ||
phantom.exit(); | ||
} | ||
}, 300); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"use strict"; | ||
console.log('Hello, world!'); | ||
phantom.exit(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Use 'page.injectJs()' to load the script itself in the Page context | ||
|
||
"use strict"; | ||
if ( typeof(phantom) !== "undefined" ) { | ||
var page = require('webpage').create(); | ||
|
||
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this") | ||
page.onConsoleMessage = function(msg) { | ||
console.log(msg); | ||
}; | ||
|
||
page.onAlert = function(msg) { | ||
console.log(msg); | ||
}; | ||
|
||
console.log("* Script running in the Phantom context."); | ||
console.log("* Script will 'inject' itself in a page..."); | ||
page.open("about:blank", function(status) { | ||
if ( status === "success" ) { | ||
console.log(page.injectJs("injectme.js") ? "... done injecting itself!" : "... fail! Check the $PWD?!"); | ||
} | ||
phantom.exit(); | ||
}); | ||
} else { | ||
alert("* Script running in the Page context."); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use strict"; | ||
var page = require('webpage').create(), | ||
system = require('system'), | ||
t, address; | ||
|
||
if (system.args.length === 1) { | ||
console.log('Usage: loadspeed.js <some URL>'); | ||
phantom.exit(1); | ||
} else { | ||
t = Date.now(); | ||
address = system.args[1]; | ||
page.open(address, function (status) { | ||
if (status !== 'success') { | ||
console.log('FAIL to load the address'); | ||
} else { | ||
t = Date.now() - t; | ||
console.log('Page title is ' + page.evaluate(function () { | ||
return document.title; | ||
})); | ||
console.log('Loading time ' + t + ' msec'); | ||
} | ||
phantom.exit(); | ||
}); | ||
} |
Oops, something went wrong.