Fetching contributors…
Cannot retrieve contributors at this time
543 lines (456 sloc) 32.4 KB

SlimerJS is implementing almost the API of Phantomjs.

Here are compatibility tables and other specific API to SlimerJS.

Main differences with PhantomJS 2.1

You'll found in the documentation a list of differences. of behaviors in the APIs implementation and in the web platform.

Command-line arguments and options

--config=/path/to/config.json Implemented
--cookies-file=/path/to/cookies.txt not applicable. Use profiles instead.
--debug=[yes|no] Implemented, but not everything is displayed. With SlimerJS, it accepts also name of what to debug
--disk-cache=[yes|no] Implemented
--disk-cache-path (phjs 2.1)
--help or -h Implemented
--load-images=[yes|no] Implemented
--local-storage-path=/path/to/file not applicable. Use profiles instead.
--local-storage-quota=number Implemented
--local-url-access (phjs 2.0)
--max-disk-cache-size=size Implemented
--offline-storage-path not applicable. Use profiles instead.(phjs 2.1)
--offline-storage-quota (phjs 2.1)
--output-encoding=encoding Implemented
--proxy=address:port Implemented
--proxy-auth=username:password Implemented
--script-language=[language] (phjs 2.0)
--ssl-protocol=[SSLv3|TLSv1|TLSv1.1|TLSv1.2|any|TLS] Implemented. No support of sslv2. By default TLS.
--ssl-certificates-path=/path/to/dir not applicable. Use profiles instead.
--ssl-ciphers (phjs 2.0)
--ssl-client-certificate-file (phjs 2.1)
--ssl-client-key-file (phjs 2.1)
--ssl-client-key-passphrase (phjs 2.1)
--version or -v Implemented
--webdriver or --wd or -w Implemented (experimental)
--webdriver=ip:port Implemented (experimental)
--webdriver-logfile=/path/to/logfile Implemented (experimental)
--webdriver-loglevel=[ERROR|WARN|INFO|DEBUG]Implemented (experimental)
--webdriver-selenium-grid-hub=url Implemented (experimental)
script path Implemented
script arguments Implemented

phantom object


args Implemented (deprecated, removed in phjs 2.0)
cookies Implemented
cookiesEnabled Implemented
defaultPageSettings Implemented
libraryPath Implemented (deprecated)
outputEncoding Implemented (with support of special value 'binary' for system.stdout, Slimerjs only)
page Not implemented. Irrelevant for SlimerJS
remoteDebugPort (phjs 2.1)
scriptName Implemented (deprecated, removed in phjs 2.0)
version Implemented. Gives the PhantomJS version which is compatible to the SlimerJS implementation.
webdriverMode Implemented
aboutToExit Implemented


addCookie(cookie) Implemented
clearCookies() Implemented
defaultErrorHandler(message, stack) Implemented
deleteCookie(cookieName) Implemented
debugExit(returnValue) Implemented
exit(returnValue) Implemented
fullyDecodeUrl(url) Implemented (phjs 2.1)
injectJs(filename) Implemented
loadModule(moduleSource, filename)
onerror(msg, trace) Implemented
proxy() Implemented (phjs 2.1)
resolveRelativeUrl(url, base) Implemented (phjs 2.1)
setProxy(host, port, proxyType, user, password) Implemented (phjs 2.0)
The first parameter may be a hostname, IP address or auto-config URL (PAC; for config-url proxy type; SlimerJS only).

slimer object

It will contain API that does not exists in PhantomJS.

version Implemented. Gives the version of SlimerJS
clearHttpAuth() Implemented.
exit() Implemented.

CommonJS API

require(modulename) Implemented
require.paths Implemented. SlimerJS only. Array of path where modules can be found

Module: webpage

create() Implemented

WebPage object


canGoBack Implemented
canGoForward Implemented
clipRect Implemented
content Implemented.
captureContent Implemented. list of regexp matching content
types of resources for which you want to retrieve
the content. The content is then set on the body
property of the response object received by your
onResourceReceived callback (SlimerJS only)
cookies Implemented (phjs 2.0)
cookieJar (phjs 2.0)
customHeaders Implemented
event Implemented
focusedFrameName Implemented
frameContent Implemented
frameName Implemented
framePlainText Implemented
frameTitle Implemented
frameUrl Implemented
framesCount Implemented
framesName Implemented
libraryPath Implemented
loading Implemented
loadingProgress Implemented
navigationLocked Implemented
offlineStoragePath Implemented
offlineStorageQuota Implemented
ownsPages Implemented
pages Implemented
pagesWindowName Implemented
paperSize Implemented. 'header' and 'footer' properties are not supported yet.
plainText Implemented
scrollPosition Implemented
settings Implemented
settings.allowMedia Implemented. SlimerJS only. Attribute stating whether or not media (audio / video) should be loaded.
settings.javascriptEnabled Implemented
settings.loadImages Implemented
settings.userAgent Implemented
settings.userName Implemented
settings.password Implemented
settings.proxy (phjs 2.1)
settings.maxAuthAttempts Implemented
settings.resourceTimeout Implemented
settings.plainTextAllContent Implemented (SlimerJS only)
title Implemented
url Implemented
viewportSize Implemented
windowName Implemented
zoomFactor Implemented


addCookie(Cookie) Implemented
childFramesCount() Implemented. deprecated
childFramesName() Implemented. deprecated
clearCookies() Implemented
clearMemoryCache() (phjs 2.0)
close() Implemented
currentFrameName() Implemented. deprecated
deleteCookie(cookieName) Implemented
evaluateJavascript(str) implemented
evaluate(function, arg1, arg2,...) implemented
evaluateASync(function, arg1, arg2,...)implemented
getPage(windowName) Implemented
go(index) Implemented
goBack() Implemented
goForward() Implemented
includeJs(url, callback) implemented
injectJs(filename) Implemented
open(url) Implemented. SlimerJS only: it returns a promise
open(url, callback) Implemented. SlimerJS only: it returns a promise
open(url, httpConf) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
open(url, httpConf, callback) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
open(url, operation, data) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
open(url, operation, data, callback)Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
open(url, operation, data, headers, callback)Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
openUrl(url, httpConf, settings) Implemented. SlimerJS only: it returns a promise. Only GET and POST method are supported.
release() Implemented
reload() Implemented
render(filename, options) Implemented. Only PNG, JPG, BMP, ICO and PDF are supported for now.
renderBytes(format, options) Implemented. SlimerJS only. Only PNG, BMP, ICO and JPG are supported for now.
renderBase64(format, options) Implemented. Only PNG and JPG are supported for now.
sendEvent(mouseEventType, mouseX, mouseY, button='left')Implemented
sendEvent(keyboardEventType, keyOrKeys)Implemented
setContent(content, url) Implemented
setCookieJar(cookieJar) (phjs 2.0)
setCookieJarFromQObject(Qobject) not implemented, irrelevant (phjs 2.0)
setProxy(url) (phjs 2.1)
stop() Implemented
stopJavascript() Implemented (phjs 2.0)
switchToFocusedFrame() Implemented
switchToFrame(frameName) Implemented
switchToFrame(framePosition) Implemented
switchToChildFrame(frameName) Implemented. deprecated
switchToChildFrame(framePosition) Implemented. deprecated
switchToMainFrame() Implemented
switchToParentFrame() Implemented
uploadFile(selector, filename) Implemented


onAlert Implemented
onAuthPrompt Implemented (SlimerJS only)
onCallback Implemented
onClosing Implemented
onConfirm Implemented
onConsoleMessage Implemented (SlimerJS only: the callback receives the lineNumber and the sourceID, contrary to PhantomJS)
onError Implemented (SlimerJS issue: For errors from the webpage directly, the stack is not available..)
onFilePicker Implemented
onInitialized Implemented
onLoadFinished Implemented
SlimerJS only: the callback receives 3 parameters: the status ("success" or "fail"), the url and true if this is a frame that is loaded
onLoadStarted Implemented
SlimerJS only: the callback receives 2 parameters: the url and true if this is a frame that is loaded
onLongRunningScript Implemented (phjs 2.0)
onNavigationRequested Implemented.
SlimerJS issue: navigationType is always "Undefined" and isMainFrame is irrelevant
onPageCreated Implemented
onPrompt Implemented
onRepaintRequested (phjs 2.0)
onResourceError Implemented
onResourceRequested Implemented
onResourceReceived Implemented
onResourceTimeout Implemented
onUrlChanged Implemented

Methods that send signals (private methods):

closing(page) Implemented
initialized() Implemented
javaScriptAlertSent(message) Implemented
loadFinished(status) Implemented
loadStarted() Implemented
navigationRequested(url, navigationType, navigationLocked, isMainFrame)Implemented
rawPageCreated(page) Implemented
repaintRequested() (phjs 2.0)
resourceError(resourceError) Implemented
resourceReceived(request) Implemented
resourceRequested(resource) Implemented
urlChanged(url) Implemented

resourceError object received by onResourceError

id Implemented (phjs 2.0)
url Implemented
errorCode Implemented
errorString Implemented
status Implemented (phjs 2.0)
statusText Implemented (phjs 2.0)

request object received by onResourceRequested

id Implemented
method Implemented
url Implemented
time Implemented
headers Implemented

request controller object received by onResourceRequested

abort() Implemented
changeUrl(url) Implemented
setHeader(key, value, merge) Implemented (phjs 2.0)

response object received by onResourceReceived

id Implemented
headers Implemented
body Implemented (SlimerJS only, see webpage.captureContent)
bodySize Implemented
contentType Implemented
contentCharset Implemented (SlimerJS only)
imageInfo Implemented (SlimerJS only, for images)
redirectURL Implemented
referrer Implemented (SlimerJS only)
stage Implemented
status Implemented
statusText Implemented
time Implemented
url Implemented

cookieJar object

cookies (phjs 2.0)
addCookie(cookie) (phjs 2.0)
addCookieFromMap(cookie, url) (phjs 2.0)
addCookiesFromMap(cookiesList, url)(phjs 2.0)
cookiesToMap(url) (phjs 2.0)
cookieToMap(name, url) (phjs 2.0)
deleteCookie(name, url) (phjs 2.0)
clearCookies() (phjs 2.0)
close() (phjs 2.0)

Module: CookieJar

create(path) -> cookieJar (phjs 2.0)

Module: system

System object


args Implemented
env Implemented
os Implemented. SlimerJS only: an additional method on this object: isWindows()
pid Implemented
platform Implemented
stdout Implemented
stdin Implemented
stderr Implemented
standardout Implemented (phjs 2.0)
standardin Implemented (phjs 2.0)
standarderr Implemented (phjs 2.0)

Module: FileSystem

fs object


separator Implemented
workingDirectory Implemented
Note that it is a property, to be compatible with PhantomJS. In the CommonJS FileSystem specification, it supposed to be a method


open(path, mode) Implemented
read(path) Implemented
write(path, content, mode) Implemented
copy(source, destination) Implemented
move(source, destination) Implemented
remove(path) Implemented
touch(path) Implemented
makeDirectory(path) Implemented
removeDirectory(path) Implemented
makeTree(path) Implemented
removeTree(path) Implemented
copyTree(source, destination) Implemented
list(path) Implemented
readLink(path) Implemented
lastModified(path) Date Implemented
exists(path) Implemented
isFile(path) Implemented
isDirectory(path) Implemented
isLink(path) Implemented
isReadable(path) Implemented
isWritable(path) Implemented
absolute(path) Implemented
join(base) Implemented
split(path) Implemented
size(path) Implemented
isAbsolute(path) Implemented (not a CommonJS FileSystem method)
isExecutable(path) Implemented (not a CommonJS FileSystem method)
changeWorkingDirectory(path) Implemented

Other additional methods not provided in PhantomJS, but that are part of the CommonJS FileSystem specification

rename(path, name) Implemented
link(source, target)
hardLink(source, target)
same(source, target)
directory(path) Implemented
base(path) Implemented
extension(path) Implemented

stream object

atEnd() Implemented
read() Implemented
readLine() Implemented
write(data) Implemented
writeLine(data) Implemented
flush() Implemented
close() Implemented
getEncoding() Implemented (phjs 2.0)
setEncoding(encoding) Implemented (phjs 2.0)

Module: webserver

create() Implemented

WebServer object

port Implemented
close() Implemented
listenOnPort(port, options)
listen(port, callback) Implemented. The callback is called for every http request. Don't give it if you use one of register* methods (it calls registerPrefixHandler("/", callback);)
listen(port, options, callback) This form of call is recognized but options are ignored in SlimerJS
registerFile(path, filePath) Implemented (SlimerJS only). Maps the given path to a file.
registerDirectory(path, directoryPath)Implemented (SlimerJS only). Maps a path to a dir (directoryPath)
registerPathHandler(path, callback) Implemented (SlimerJS only). Register a callback that will be called when an HTTP client request the given path.
registerPrefixHandler(prefixPath, callback)Implemented (SlimerJS only). Register a callback that will be called when an HTTP client request a path starting with prefixPath.

request object

method Implemented
url Implemented
httpVersion Implemented
headers Implemented
post Implemented
postRaw Implemented
path Implemented (SlimerJS only). Contains the path part of the URL (Readonly)
queryString Implemented (SlimerJS only). Contains the query part of the URL (Readonly)

response object

headers Implemented
header(name) Implemented
setHeader(name, value) Implemented
setEncoding(encoding) Implemented
statusCode Implemented
write(data) Implemented
writeHead(statusCode, headers) Implemented
close() Implemented
closeGracefully() Implemented

Module: child_process

spawn(cmd, args, opts)
exec(cmd, opts, cb) (not implemented in PhantomJS)
execFile(file, args, options, callback)
fork(modulePath, args, options) (not implemented in PhantomJS)

context object (returned by execFile and spawn)

on(event, callback)
stdout.on(event, callback)
stderr.on(event, callback)
stdin.write(chunk, encoding)