Skip to content

Latest commit

 

History

History
439 lines (367 loc) · 26.2 KB

API_COMPAT.md

File metadata and controls

439 lines (367 loc) · 26.2 KB

SlimerJS will implement all the API of Phantomjs.

Here are compatibility tables and other specific API to SlimerJS.

Main differences with PhantomJS 1.9.x

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
--help or -h Implemented
--ignore-ssl-errors=[yes|no]
--load-images=[yes|no] Implemented
--local-storage-path=/path/to/file not applicable. Use profiles instead.
--local-storage-quota=number Implemented
--local-to-remote-url-access=[yes|no]
--max-disk-cache-size=size Implemented
--output-encoding=encoding
--proxy=address:port Implemented
--proxy-auth=username:password Implemented
--proxy-type=[http|socks5|none|auto|system|config-url]Implemented
--remote-debugger-port=number
--remote-debugger-autorun=[yes|no]
--script-encoding=encoding
--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.
--version or -v Implemented
--webdriver or --wd or -w
--webdriver=ip:port
--webdriver-logfile=/path/to/logfile
--webdriver-loglevel=[ERROR|WARN|INFO|DEBUG]
--webdriver-selenium-grid-hub=url
--web-security=[yes|no]
script path Implemented
script arguments Implemented

phantom object

properties

args Implemented (deprecated)
cookies Implemented
cookiesEnabled Implemented
defaultPageSettings Implemented
libraryPath Implemented (deprecated)
outputEncoding
page Not implemented. Irrelevant for SlimerJS
scriptName Implemented
version Implemented. Gives the PhantomJS version which is compatible to the SlimerJS implementation.
webdriverMode

methods

addCookie(cookie) Implemented
clearCookies() Implemented
defaultErrorHandler(message, stack) Implemented
deleteCookie(cookieName) Implemented
exit(returnValue) Implemented
injectJs(filename) Implemented
onerror(msg, trace) Implemented

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

properties

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
customHeaders Implemented
event Implemented
focusedFrameName Implemented
frameContent Implemented
frameName Implemented
framePlainText Implemented
frameTitle Implemented
frameUrl Implemented
framesCount Implemented
framesName Implemented
libraryPath 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.javascriptEnabled Implemented
settings.loadImages Implemented
settings.localToRemoteUrlAccessEnabled
settings.XSSAuditingEnabled
settings.webSecurityEnabled
settings.javascriptCanOpenWindows
settings.javascriptCanCloseWindows
settings.userAgent Implemented
settings.userName Implemented
settings.password Implemented
settings.maxAuthAttempts Implemented
settings.resourceTimeout
settings.plainTextAllContent Implemented (SlimerJS only)
title Implemented
url Implemented
viewportSize Implemented
windowName Implemented
zoomFactor Implemented

methods

addCookie(Cookie) Implemented
childFramesCount() Implemented. deprecated
childFramesName() Implemented. deprecated
clearCookies() Implemented
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
stop() Implemented
stopJavascript() Implemented
switchToFocusedFrame() Implemented
switchToFrame(frameName) Implemented
switchToFrame(framePosition) Implemented
switchToChildFrame(frameName) Implemented. deprecated
switchToChildFrame(framePosition) Implemented. deprecated
switchToMainFrame() Implemented
switchToParentFrame() Implemented
uploadFile(selector, filename) Implemented

callbacks

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
onNavigationRequested Implemented.
SlimerJS issue: navigationType is always "Undefined" and isMainFrame is irrelevant
onPageCreated Implemented
onPrompt Implemented
onResourceError Implemented
onResourceRequested Implemented
onResourceReceived Implemented
onResourceTimeout
onUrlChanged Implemented

Methods that send signals (private methods):

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

resourceError object received by onResourceError

id Implemented
url Implemented
errorCode Implemented
errorString Implemented

request object received by onResourceRequested

id Implemented
method Implemented
url Implemented
time Implemented
headers Implemented

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

Module: system

System object

properties

pid Not Implemented. Always returns 0. It seems Mozilla doesn't provide an API for that
platform Implemented
os Implemented. SlimerJS only: an additional method isWindows()
env Implemented
args Implemented

Module: FileSystem

fs object

properties

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

methods

<tr><td>makeDirectory(path)                 </td><td>Implemented</td></tr>
<tr><td>removeDirectory(path)               </td><td>Implemented</td></tr>
<tr><td>makeTree(path)                      </td><td>Implemented</td></tr>
<tr><td>removeTree(path)                    </td><td>Implemented</td></tr>
<tr><td>copyTree(source, destination)       </td><td>Implemented</td></tr>

<tr><td>list(path)                          </td><td>Implemented</td></tr>
<tr><td>readLink(path)                      </td><td>Implemented</td></tr>

<tr><td>lastModified(path) Date             </td><td>Implemented</td></tr>
<tr><td>exists(path)                        </td><td>Implemented</td></tr>
<tr><td>isFile(path)                        </td><td>Implemented</td></tr>
<tr><td>isDirectory(path)                   </td><td>Implemented</td></tr>
<tr><td>isLink(path)                        </td><td>Implemented</td></tr>
<tr><td>isReadable(path)                    </td><td>Implemented</td></tr>
<tr><td>isWritable(path)                    </td><td>Implemented</td></tr>

<tr><td>absolute(path)                      </td><td>Implemented</td></tr>
<tr><td>join(base)                          </td><td>Implemented</td></tr>
<tr><td>split(path)                         </td><td>Implemented</td></tr>

<tr><td>size(path)                          </td><td>Implemented</td></tr>

<tr><td>isAbsolute(path)                    </td><td>Implemented (not a CommonJS FileSystem method)</td></tr>
<tr><td>isExecutable(path)                  </td><td>Implemented (not a CommonJS FileSystem method)</td></tr>

<tr><td>changeWorkingDirectory(path)        </td><td>Implemented</td></tr>
<tr><td>fromNativeSeparators(path)          </td><td></td></tr>
<tr><td>toNativeSeparators(path)            </td><td></td></tr>
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

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

<tr><td>listTree(path)                      </td><td></td></tr>
<tr><td>listDirectoryTree(path)             </td><td></td></tr>

<tr><td>link(source, target)                </td><td></td></tr>
<tr><td>hardLink(source, target)            </td><td></td></tr>

<tr><td>same(source, target)                </td><td></td></tr>

<tr><td>workingDirectoryPath()              </td><td></td></tr>

<tr><td>normal(path)                        </td><td></td></tr>
<tr><td>canonical(path)                     </td><td></td></tr>
<tr><td>directory(path)                     </td><td>Implemented</td></tr>
<tr><td>base(path)                          </td><td>Implemented</td></tr>
<tr><td>extension(path)                     </td><td>Implemented</td></tr>
rename(path, name) Implemented

stream object

atEnd()
read() Implemented
readLine()
write(data) Implemented
writeLine(data)
flush() Implemented
close() Implemented

Module: webserver

create() Implemented

WebServer object

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