Apart from being undesirable that debugging messages are always
written to stdout, the information is redundant as a similar message
is logged at debug level.
https://github.com/ariya/phantomjs/issues/12681
The default is 'true'. When set 'false', file: and qrc: URLs are
treated as invalid (unknown scheme) rather than opening local files,
as requested in issue #12752.
In order to test this, I added a mechanism to test/run-tests.py
allowing individual tests to be annotated with command-line
options to pass to phantomjs or the script.
Unfortunately, due to Qt and WebKit limitation, this is technically
clearing all the cache used by every web page instance. It is the
best we can have right now.
https://github.com/ariya/phantomjs/issues/10357
This is available via the new property called `release`. A very simple
example to demonstrate it:
var system = require('system');
console.log('Kernel release', system.os.release);
which will print (on OS X 10.7.5 Lion):
Kernel release 11.4.2
https://github.com/ariya/phantomjs/issues/12587
This means you don't have to wait 30 seconds in between invocations of
run-tests.py.
Also, if the test server fails to bind its port, print the actual
OS-level error message rather than guessing what the problem is.
issue #12439
* correctly fake a package to hold all the response-hook modules
* use StringIO correctly in the response hooks
* prevent .py(c) files in test/www/ from being accessed directly
* prevent test/www/__init__ from being treated as a response hook
* add a test case that makes sure the existing hooks _can_ return 200 OK
(issue #12439; buggy commit 4d60e94)
If there are any positional arguments to test/run-tests.py, they are matched
(verbatim, not as regular expressions) against each test's name. Only those
tests whose names contain at least one of the positional arguments will be
run. Thus, for instance, you can run just the webpage tests with
./test/run-tests.py module/webpage
or one specific test with
./test/run-tests.py exact/name/of/test.js
or the basics and standards tests with
./test/run-tests.py basics standards
If no tests at all match, run-tests.py will print "ALL TESTS SKIPPED" and
exit unsuccessfully.
Ongoing work on issue #12439.
Rather than add all the special URLs we'll ever want to run-tests.py,
the embedded HTTP server now supports scripts in test/www/. If you
try to load http://localhost:9180/path and test/www/path doesn't exist
but test/www/path.py does, then test/www/path.py is loaded as a module.
That module must export one function, handle_request(), which is called
to produce the response.
handle_request() has the same semantics as
SimpleHTTPRequestHandler.send_head(). That is, it takes one argument,
the SimpleHTTPRequestHandler object, conventionally named 'req'.
It should call the send_response(), send_header(), and end_headers()
methods of that object as appropriate. And it should return a readable
filelike whose contents are taken as the body of the response.
If either module import or handle_request() throws any exception, the
HTTP response will be a 500 Internal Server Error with body provided
by cgitb.
Ongoing work on issue #12439.
We already have 'base_path' as a global variable, so use that (or rather,
a new derivative of that) instead of inspect.getfile(inspect.currentframe()).
Rather than splitting the path and then iterating over every component
trying to figure out if it's "special", take advantage of the fact that
posixpath.normpath() will reliably produce a path with all ../ and bare-/
components at the very beginning. Preserve the distinction between paths
with and without a trailing /, as SimpleHTTPRequestHandler expects.
So that paths containing unusual (e.g. non-ASCII, non-UTF-8) segments can
safely be tested, unquote and then requote the entire path. This means
that the *bytes* corresponding to the ASCII characters
0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz -_./
are guaranteed to be unquoted, and all other *bytes* are guaranteed to be
%-quoted. (Note especially that *whether or not* the tests are being run
on Windows, \ in the original URL will be represented as %5C, and will
*not* be treated as a pathname separator.)
So that the tests behave consistently whether or not the OS has a case-
sensitive filesystem, after the above transformation, lowercase the entire
path.
Ongoing work on issue #12439.
This means that there is no longer a need to add every individual test
to the list; only new *directories* have to be mentioned. New tests
can be added just by dropping .js files into appropriate directories.
Tests which are not meant to be run by default now live in tests/manual/.
Currently there is one such test, tests/manual/standards/ecma-test262.js,
which downloads and runs the ECMAScript conformance suite.
Ongoing work on issue #12439.
The HTTP server launched by the test runner has a new endpoint called
/echo. This simply echoes back some information (current on the made
request, in the future it will be expanded to further information)
formatted as JSON. This echo system facilitates easy testing for request
header manipulation feature.
https://github.com/ariya/phantomjs/issues/12439
The server runs on port 9180 and serves the content from test/www
directory. Any tests can use this base URL to load test content and
to exercise certain PhantomJS API.
https://github.com/ariya/phantomjs/issues/12439
The use of phantom.scriptName has been deprecated since System#args was
introduce (version 1.5, March 2012). Any old scripts need to migrate to
System#args.
https://github.com/ariya/phantomjs/issues/12529
The use of phantom.args has been deprecated (see commit 545a3f7)
since a long time ago (version 1.5, March 2012). Any old scripts
need to switch to use System#args instead.
https://github.com/ariya/phantomjs/issues/12527
New option --ssl-ciphers takes a colon-separated list of OpenSSL
cipher names and sets the client cipher list to exactly that list.
The default for this option is arranged to match Chromium 35, which
has had its cipher selection optimized for the modern Web
(see https://briansmith.org/browser-ciphersuites-01.html for
rationales). (Newer versions are the same except that they also add
ChaCha20-based ciphersuites, which OpenSSL 1.0.1 hasn't yet picked up.)
* --ssl-protocol= option now accepts 'tlsv1.2', 'tlsv1.1', 'tlsv1.0'
and 'default' as well as the existing 'tlsv1', 'sslv3', and 'any'.
* The default is now none of the above, but rather QSsl::SecureProtocols,
which means "whatever subset of ANY is still considered secure and also
supported by the OpenSSL library in use". (As of this writing, Qt's idea
of "still considered secure" includes everything from SSLv3 on up, which
is technically wrong -- SSLv3 has known breaks -- but we can live with.
Qt currently doesn't have a way to select "TLSv1.0 and up".)
This mostly matters when system sqlite is selected; that has the side
effect of enabling pkg-config which in turn causes QtWebkit to detect
the presence of system GStreamer and/or QtMultimedia and turn video on.
This way, the build is consistent across the board.
The affected libraries are fontconfig, freetype, harfbuzz, libpng, libjpeg,
sqlite, pcre, and zlib.
* On Darwin, by default, fontconfig is disabled and all of the other
libraries are bundled.
* On non-Darwin, by default, fontconfig is enabled and system-provided
freetype, libpng, libjpeg, and zlib are used. Harfbuzz, pcre, and sqlite
continue to be bundled.
* Individual libraries from the above list may now be enabled or disabled
on the build.sh command line with e.g. --freetype=system or
--freetype=bundled.
* The existing --system-qtdeps, --system-qt, --system-qtwebkit options
have been renamed --qtdeps=system, --qt=system, --qtwebkit=system
respectively. New option --qtdeps=bundled forces all available
bundled libraries to be used.
Also:
* Slight adjustments to organization of preconfig.sh.
* Can now disable PulseAudio and ALSA.
* Directly link OpenSSL instead of loading it at runtime.
* Clarify the pkg-config situation (it must be enabled if and only if
sqlite comes from the system).
* If the environment variable PHANTOMJS_DISABLE_CRASH_DUMPS
is set to any value, do not initialize Breakpad.
* On Mac and Linux, if the environment variable TMPDIR is set,
put the crash dumps there instead of in /tmp.
* On Windows, %TEMP% was already being honored, but streamline
the code for that.
* Move the code that initializes Breakpad, and the code to print
the crash messages, to their own module (src/crashdump.{h,cpp})
and RAII class (CrashHandler).
* Better wording of the crash message, particularly in the case where
Breakpad failed to write a minidump file; update URL of crash-reporting
guide.
* Generally less repetitive code. (Still way too many #ifdefs.)
By implementing a dummy platform native interface (for now, it may be
extended in the near future), QPlatformPrinterSupportPlugin will avoid
the path of loading the printer support plugin
(QCocoaPrinterSupportPlugin on OS X).
Related upstream bug (QCocoaPrinterSupportPlugin problem with static build):
https://bugreports.qt-project.org/browse/QTBUG-33109https://github.com/ariya/phantomjs/issues/12500
This Python script serves as a master test runner. It will run each test
script with a fresh instance of PhantomJS. The exit code of each script
determines its success or failure.
The existing tests (run-tests.js) are wrapped as one of the test
scripts. This permits a gradual migration to the new test system.
https://github.com/ariya/phantomjs/issues/12439
This is to reduce maintenance burden. A GIF representation of a web
page can be produced by converting its PNG capture. There are numerous
third-party tools which can do the job better (optimized palette,
minimized loss, etc).
https://github.com/ariya/phantomjs/issues/12480
To prevent unintended macro expansion, don't use the name
stdout/stdin/stderr in the native System object. Those properties are
achieved by shadowing it in the module interface (JavaScript side).
https://github.com/ariya/phantomjs/issues/12496
It cannot, nor should it, be selected on windows machines. There, we
stick to the Windows QPA which is required to get a lot of things up
and running, like an eventloop, socket integration etc. pp.
There was code in the phantom QPA to make it compile, but it never
actually worked since a lot of things where missing (such as
instantiating QWindowsContext among others).
https://github.com/ariya/phantomjs/issues/12494
Regression from #12431: the loop to clear all surviving pages
neglects to check for entries in `m_pages` which have already
been closed, fully destructed, and therefore replaced by NULL
pointers.
This code:
console.log("Hello World!");
phantom.exit();
console.log("Meh, noone should see me!");
currently produces this unexpected output:
Hello World!
Meh, noone should see me!
This patch fixes it to only output the first line, by loading a blank
page on phantom.exit(). Direct deletion of the web page can trigger
crashes, so this is a safe workaround.
https://github.com/ariya/phantomjs/issues/12431
The newer ConsoleReporter is very quiet by default, which is nice, but
this provides a way to get something more like the older one-line-per-test
output.
#12230 (Test suite improvements).
* Anything on the command line after "run-tests.sh" will be understood
as a regular expression (if there is more than one argument, they are
concatenated, with spaces in between) and only the tests whose "full
names" match that regexp will be run. The full name of a test is the
"describe" string plus a space plus the "it" string. Note well that,
unlike the test-runner output, there is no colon in there.
* run-tests.sh and run-tests.js now correctly handle being invoked from
an arbitrary directory; the cwd does not have to be the project root.
* Shell portability fixes for run-tests.sh.
#12230 (Test suite improvements).
The new Jasmine includes a version of this formerly external add-on, but it
is buggy and doesn't print details of failing tests.
#12230 (Test suite improvements).
The newer jasmine-console behavior requires minor adjustments to the
ConsoleReporter we create in run-tests.js. Also, en passant fix for
a bug in the final callback: exiting with status equal to the number
of failed tests does not work, because the _exit() system call takes
only the low eight bits of the value passed. If a test run happened
to have 256 failing tests, the old code would have spuriously exited
successfully. Instead, just exit(1) if any tests fail.
#12230 (Test suite improvements).
Three tests were (potentially) dumping text to console.log during the
run, which they should never do.
Fixing that revealed that one of them, the test for interrupting a
long-running JS script, was not actually testing what it was supposed
to test. Fixing *that* revealed that the long-running-script hook is
broken and does not actually interrupt JS infinite loops; that test
has been temporarily disabled.
#12230 (Test suite improvements).
Two tests were spuriously failing because they tried to load pages on
`github.com` that were no longer structured as expected. Use a local
webserver instead.
#12230 (Test suite improvements).
The PhantomJS QPA hardcoded usage of QFontconfigDatabase on
Unix-not-OSX, causing build failures in "bundle all the libraries" mode.
Use QGenericUnixFontDatabase instead, which is QFontconfigDatabase if
fontconfig is enabled, and QBasicFontDatabase if it isn't. This means
that the bundled-qtdeps build will use only the fonts bundled with Qt,
and won't be able to find them on a machine that doesn't have the source
tree, which is suboptimal, but at least this makes the bundled-qtdeps
build complete successfully again.
Part of issue #12467.
In this mode, system-provided libraries will be used for all of
Qt's dependencies, but Qt and QtWebkit themselves are still the
bundled copies. This mode actually works.
Now that this mode exists, disable fontconfig in the "everything
bundled" mode, because it drags in the system freetype and several
other system libraries. (There is no bundled fontconfig.)
Part of issue #12467.
This is how we arrange for QtWebkit to use QtBase's bundled copy of
sqlite; without it, QtWebkit will attempt to use a system-provided
library instead, and if headers are unavailable, the build will fail.
Part of issue #12467.
As with the system-qtwebkit option, this does not actually work at this
point, but it enables experimentation toward getting it to work.
Part of issue #12467.
* build.sh now handles building qt and qtwebkit.
* preconfig.sh is now only responsible for accumulating arguments
to pass to qt's configure script.
* preconfig.sh doesn't have command line arguments of its own;
anything on its command line will be passed directly to qt's
configure script.
* first pass of adjustments to the qt configure parameters
to try to get a more static build - unfortunately, system
sqlite, libz, libpng, and libexpat are still getting pulled
in somehow (mostly via fontconfig, I think).
Part of issue #12467.
Invoking build.sh with --system-qtwebkit will skip the build of Qt and
QtWebkit and use the qmake in $PATH to build PhantomJS proper.
This doesn't actually *work* at the moment because the bundled
copy of Webkit has patches not yet merged upstream, but it's still
useful to have for testing purposes.
Part of issue #12467.
* Allow any patchlevel of Qt 5.3.x.
* Do it in the master .pro file instead of main.cpp; this makes the build
fail immediately rather than after compiling a bunch of stuff.
Part of issue #12467.
* Ignore src/phantomjs_plugin_import.cpp, which is now created during
the build.
* Add leading slashes to a bunch of files that should not be ignored if
they crop up in subdirectories.
Part of issue #12467.
window.callPhantom formerly used Array.prototype.splice for cloning
its arguments to the internal _phantom.call. This relied on
non-standard behaviour of the splice method when only a single
argument was passed to it (it requires 2 arguments).
The correct method for cloning the arguments array is to use
Array.prototype.slice, which accepts a single argument (index) and
returns a new array from the specified index.
https://github.com/ariya/phantomjs/issues/12306
Currently, the build script will continue to try to build PhantomJS
even when either QtBase or QtWebKit failed to compile. In such a
case, the script should return early and emit an error message.
https://github.com/ariya/phantomjs/issues/12433
The last reference test.pdf in the tests was using a complete different region
of the input "image.jpg" because the used phantomjs version used to generate it
had a bug. This bug was fixed in 833eb824f5bae07f1b157d6757e7e3c98343f812
("Don't scale the unit px to 1/2.54 points for PDFs") and
1daa2eb4dd49efb848ff96e37f298a774520cc9b ("Disable page shrinking for pdf
printing to create accurate output").
The new version should now use the same region of the input image as the other
generated files for the gif, jpg and png tests. The only difference is the
extra height is still displayed on a second page but this is currently expected
by phantomjs.
https://github.com/ariya/phantomjs/issues/11590 ("page.paperSize is not
accurate for .pdf")
PDFs are not rendered like PNG or other image formats by phantomjs because it
uses the printer functionality of Qt+Webkit. But Webkit uses some printer
"optimization" to save paper by shrinking the output. Such shrinking results in
too small content on a page.
https://github.com/ariya/phantomjs/issues/11590 ("page.paperSize is not
accurate for .pdf")
The unit px is one point inside the HTML source page but phantomjs handles it
without reason as 1/2.54 points. This makes the page smaller than expected when
trying to render a page as PDF.
https://github.com/ariya/phantomjs/issues/11590 ("page.paperSize is not
accurate for .pdf")
Exotic text (e.g. attempting to render a binary file such as .zip
or .exe as a webpage) can trigger an assertion failure in the
Harfbuzz code. Chromium developers also noticed this issue and
committed a patch to fix it:
http://lists.freedesktop.org/archives/harfbuzz/2009-August/000354.html
This patch has not been accepted by upstream, but this (old) version
of Harfbuzz has been abandoned and superceded by Harfbuzz-NG.
Issue #11264
Since this example was written the phantomjs home page has been redesigned and the targeted ID no longer exists. This tweaks the example so that it can again find content to report.
Related to #11952.
Those tests use "http://phantomjs.org" as fixture.
The website "/images" directory has been renamed "/img",
breaking the tests.
Maybe not the greatest way to go about it, but
for now it will do. We probably need to have fixtures
served by a local server.
Yes, 1.1.0 has just been imported.
But the key feature in 1.1.1 is Session Isolation in WebDriver: something that has been requested many times,
particularly when using GhostDriver with Selenium Grid.
Includes the following fixes taken from trvrnrths-qt:
- Ensure we have a first cell to measure when checking required table
height
- Handle page break edge case with exactly fitting last table row
In the case where the last table row on a page fitted exactly no
extra offset was afforded to the next row. This resulted in no
space being left for the painting of the table header on the next
page.
- Fix segfault when checking heights for pagination if table body does
not have a cell at 0,0
See https://github.com/ariya/phantomjs/pull/11291 and
https://github.com/ariya/phantomjs/pull/11490.
Previously, there was a single global cookie jar shared between all web pages.
Now, one can have separate cookie jars for different web pages.
Makes CookieJar a normal class, not a singleton.
Moves many public CookieJar methods to public slots.
Adds default cookie jar to Phantom.
Adds the CookieJar module that provides access to cookie jars in javascript.
Adds cookie jar module tests.
Usage:
var jar = require('cookiejar').create();
var webpage = require('webpage').create();
webpage.cookieJar = jar;
...
webpage.close();
jar.close();
JS API changes:
Webpage:
var jar = page.cookieJar; -- assigns 'jar' the given webpage's cookie jar.
page.cookiejar = jar; -- sets 'jar' as the given webpage's cookie jar.
CookieJar:
var jar = require('cookiejar').create(path)
creates a cookie jar with persistent storage at the given file path
(path not mandatory).
var cookies = jar.cookies; -- assign's 'jar' the list of cookies in the
cookie jar.
jar.cookies = [c1, c2]; -- sets the cookie jar's cookies as the ones in the
list.
jar.addCookie(cookie) -- adds cookie 'cookie' to the cookie jar.
https://github.com/ariya/phantomjs/issues/11417
Previously the test suite 'WebPage render image' made a series of
webpage.open without waiting them to complete. This effected next
runned tests because on load handlers for pages were fired after
'WebPage render image' test finish.
https://github.com/ariya/phantomjs/issues/11780
Enables subscription to RepaintRequested events.
When the callback is invoked the time that the repaint was requested as well as the x,y and width,height of the repainted rectangle are provided as parameters.
Usage: page.onRepaint = function(time, x, y, width, height) { }
https://github.com/ariya/phantomjs/issues/11793
CHANGELOG for v1.1.0 (https://github.com/detro/ghostdriver/issues?labels=1.1.0&state=closed)
JavaScript Driver (Core)
* ENHANCEMENT: `/maximize` window will set the window size to 1336x768,
currently most common resolution online (see http://gs.statcounter.com/#resolution-ww-monthly-201307-201312)
* ENHANCEMENT #275: Implemented Browser and Network (HAR) Logging types
* FIXED#284: Attempt to wait for Page to Load if input causes form submit
* FIXED#291: Throw exception when attempting to set invalid timeout value
* FIXED#259: Fix issue regarding mouse clicks
* ENHANCEMENT #290: Enabled support for "Keep Alive" HTTP connections
* ENHANCEMENT #262: Allow access to PhantomJS API from WebDriver (Driver part)
* ENHANCEMENT #293: Import Selenium 2.39.0 WebDriver Atoms
Java Binding
* MINOR #251: Minor compilation issues for Binding
* ENHANCEMENT #262: Allow access to PhantomJS API from WebDriver (Java Binding part)
Tested using GhostDriver validation tests (https://github.com/detro/ghostdriver/tree/master/test).
https://github.com/ariya/phantomjs/pull/11877
This tests mousedown, mouseup, click, and doubleclick for clicks with
modifier events. The mousedown/mouseup tests pass in 1.9.2, the
click/doubleclick do not. All pass with a build from this branch.
As it seems that project Mongoose has been relicensed from MIT to GPL2. The link provided is leading to the new licensing agreement but as today version 3.1 of Mongoose is used which is licensed under MIT therefore correct reference to a license should be provided.
https://github.com/ariya/phantomjs/issues/10718
Location information of parse time error is given to javaScriptError not
with stack by with separate lineNumber and sourceID arguments. Put this info
to stack if it is empty so that it will be visible to user.
https://github.com/ariya/phantomjs/issues/11640
Exotic text (e.g. attempting to render a binary file such as .zip
or .exe as a webpage) can trigger an assertion failure in the
Harfbuzz code. Chromium developers also noticed this issue and
committed a patch to fix it:
http://lists.freedesktop.org/archives/harfbuzz/2009-August/000354.html
This patch has not been accepted by upstream, but this (old) version
of Harfbuzz has been abandoned and superceded by Harfbuzz-NG.
Issue #11264
To achieve this, Request Headers are stored in both "original" and "lowercase".
In this way we don't mangle with the request object we have received, while
still be able to handle headers when NOT in the classic "Camel-Case" format.
Fixes#11421.
For whatever reason, swapping the order with the render() tests solve the
intermittent random failures. Also, split the tests between loading
start and finish checks (to better recognize which one is failing, if
there is a failure), also make the tests more asynchoronous.
https://github.com/ariya/phantomjs/issues/11091
`m_resourceTimeout` is declared before of other
private variables, and the compiler was complaining
the initialisation order could not be respected.
This caused annoying (but innocuous) warnings at compile time.
Issue #10158: https://github.com/ariya/phantomjs/issues/10158
This bug introduced by the marco max( ) defined in <windef.h>.
It replaces max( ) with another statement but still preceeded by numberic_limits<Type>::
The workaround is to use the parenthesis
This fixes issue #11162.
`File` constructor takes a `QTextCodec *`, codec; but, if codec is
`NULL`, then it assumes "binary" mode, which causes non-ASCII
characters to be converted to NUL (`\0`) in `File::write`.
This change passes the codec for UTF-8 to the `File` constructor for
the `std{in,out,err}` instances, thus opening them in *text mode*.
If the wrapped `QFile` was opened with `QIODevice::Unbuffered`, any
writes should be unbuffered. However, as currently implemented,
using `QTextStream` when the `File` is in "text" mode causes all
reads/writes to be buffered.
This modification forces a flush in `File::write` if the wrapped
`QFile` was opened with `QIODevice::Unbuffered`.
Necessary to fix issue #11162https://github.com/ariya/phantomjs/issues/11162.
webkit (thus phantomjs) load() does not call loadFinished at the expected timing when running concurrently. The example is changed to run non-concurrently as a work around.
Issue: http://code.google.com/p/phantomjs/issues/detail?id=1021
require.stub() can now accept a factory function instead of an object
so that stubbed modules are initialized lazily:
require.stub('zlib', function() {
// initialized once, when zlib first required
return {
createGzip: function() { ... }
};
});
http://code.google.com/p/phantomjs/issues/detail?id=1044
In some cases, setupFrame() has not been invoked (due to the queued
signal-slot connection) after the frame is destroyed and thus leads
to the crash. We prevent this from happening by making sure it is a
direct connection instead and therefore setupFrame() will be executed
as soon as possible.
Investigation + patch by Vitaliy Slobodin <vitaliy.slobodin@gmail.com>.
http://code.google.com/p/phantomjs/issues/detail?id=947
This feature renders PDF, GIF and other format supported by Qt to
stdout or stderr.
*NOTE*
"/dev/stdout" and "/dev/stderr" are converted to System::stdout and
System::stderr on Windows.
Issue: https://code.google.com/p/phantomjs/issues/detail?id=973
The goal is to use old glibc so that it can reach more audience (in
particular, RHEL and CentOS users).
Also, we don't compress the executable (using UPX) so that it can be
inspected with ldd. Bonus: no more decompression overhead, faster
startup.
http://code.google.com/p/phantomjs/issues/detail?id=963
All invokable methods, slots, signals, and properties visible from
JavaScript, but which do not start with an underscore, are lazily
(only when necessary) added to the completion list through dynamic
reflection.
This leverages `QMetaObject` for reflection of `QObject`s. As such,
there is now no need to inherit `REPLCompletable` and it has been
removed.
http://code.google.com/p/phantomjs/issues/detail?id=943
This is just a workaround. We simply avoid removing the custom font
(intentionally leak it, a small price to pay) because otherwise it will
invalidate Qt's font cache, which in turns trigger the crash at
CoreText's CTFontCopyGraphicsFont.
http://code.google.com/p/phantomjs/issues/detail?id=690
The [IO/A spec][1] for `read` is as follows:
> Read up to n bytes from the stream, or until the end of the stream
> has been reached. [If] n is null, reads up to the block size of the
> underlying device, or up to 1024 bytes if the block size is not
> discernible. If n is not specified, this method always reads the
> full stream until its end is reached. ...
Since discovering the block size of the underlying device is
non-trivial, we will just default to 1024.
**NOTE**
The initial implementation of `File::read()` saves the current
(original) position, seeks to the beginning of the stream,
`readAll`s to the end, and then resets to the original position.
I think that this behavior is unexpected and should be changed--it
should read from the current position to the end of the stream and
stay there. The user should explicitly `seek` to the beginning of
the stream when necessary.
With the current implementation, the user should note that the
position *will not change* after calling `read()` with no arguments.
[1]: http://wiki.commonjs.org/wiki/IO/A#Instance_Methodshttp://code.google.com/p/phantomjs/issues/detail?id=938
For our QPA/Lighthouse platform screen, apparently we need to specify the
physical screen size because otherwise the default 100 dpi will be used.
This also brings font rendering on headless Linux to 72 dpi.
http://code.google.com/p/phantomjs/issues/detail?id=659
Modern browser mostly limit re-directs to 20. The current limit in PhantomJS is 10 which is not in line with most browsers. This patch is a simple increase of gMaxRedirections from 10 to 20.
http://code.google.com/p/phantomjs/issues/detail?id=849
We were previously adding the certificates on each instantiation of
NetworkAccessManager, causing memory consumption to grow unbounded.
I have also removed the Qt version check. It's unnecessary as we only
build against a fixed Qt version.
https://code.google.com/p/phantomjs/issues/detail?id=882
Obviously, the input must have the multiple attribute for this to work.
The API is:
page.uploadFile('#file_input', ['file1', file2'])
I haven't implemented support for multiple files in the page.filePicker
API because I couldn't work out how to get a return value of an array
of strings through the JS/C++ bridge.
https://code.google.com/p/phantomjs/issues/detail?id=256
Added CoffeeScript examples where missing, minor other fixes such as spacing standardization (2 spaces is the standard in CoffeeScript via Ruby). Also a small set of minor JS example fixes and additional comments.
Fixes http://code.google.com/p/phantomjs/issues/detail?id=907
Finally. After so much work, this is finally a reality.
To launch PhantomJS in "Remote WebDriver mode":
```bash
$ phantomjs --webdriver=OPTIONAL_IP:OPTIONAL_PORT
```
Also, GhostDriver brings along support for Selenium Grid: now PhantomJS can register itself to a Selenium Grid HUB.
Just launch it in Webdriver Mode with the following extra options:
```bash
$ phantomjs --webdriver=OPTIONAL_IP:OPTIONAL_PORT --webdriver-selenium-grid-hub=http://url.to.selenium.grid.hub:port
```
http://code.google.com/p/phantomjs/issues/detail?id=49
Although it is mentioned in http://phantomjs.org/build.html, many people
are not aware this, they compile from source (even if a binary package
is available) and get shocked to realize the build takes ages.
The build script is thus modified to give the initial warning.
Unattended build is still possible, just use --confirm flag.
http://code.google.com/p/phantomjs/issues/detail?id=862
Addresses [Issue #808](http://code.google.com/p/phantomjs/issues/detail?id=808)
* back() [method]
* canGoBack [property - boolean]
* forward() [method]
* canGoForward [property - boolean]
* reload() [method]
* stop() [method]
This is to fill a small gap we ought to deal with.
IMPORTANT: this API is asynchronous. Events
like "onLoadStarted" and "onLoadFinished" are
ideal to monitor the activity of those methods.
QtWebKit normally loops infinitely trying to authenticate when it receives a
401 code, preventing all callbacks (onLoadFinished, onResourceReceived, etc).
This commit changes it to only try a set amount of times before aborting.
https://code.google.com/p/phantomjs/issues/detail?id=826
Lots of discussions on the ML could be easily put
to rest if people could run something like this
and see the result.
It's not a real fix or improvement, just a "cute"
example and as such I didn't raise a "proper"
issue.
* Using the "QTimer::singleShot" bites back in the ass
* The "script" takes priority and runs before the SLOT is actually invoked
Why was I using a Timer?
Not sure anymore: it must have slipped in while I was trying to work out
all the other issues I had with QNetworkCookieJar, and I left it there.
http://code.google.com/p/phantomjs/issues/detail?id=790
In the callback function passed to `waitFor`, the call to `page.evaluate`
returns a 1 or 0, and this is then passed to `phantom.exit` (with a 1
indicating at least one test failed, 0 indicating all tests passed).
http://code.google.com/p/phantomjs/issues/detail?id=792
Changed the CSS selectors used to identify failed tests.
The old selector was `div.jasmine_reporter > div.suite.failed`,
but this no longer seems to match any elements.
The new selector is `.results > #details > .specDetails.failed`. For each
failing test the `.description` and `.resultMessage.fail` elements are
used to output the failures to the console.
http://code.google.com/p/phantomjs/issues/detail?id=792
When using the jasmine 1.2.0 standalone version, `.runner .description`
doesn't seem to match any elements.
I noticed pending tests can be found using the CSS selector
`.symbolSummary .pending`, so changed the testFx callback to check
that no elements are left matching this selector.
http://code.google.com/p/phantomjs/issues/detail?id=792
Before this, only the first level of child frames had the possibility to use
the Callbacks object. Now is injected recursively in all of them.
This is an extension of coverage for [Issue #683](http://code.google.com/p/phantomjs/issues/detail?id=683).
Addresses [Issue #761](http://code.google.com/p/phantomjs/issues/detail?id=761).
This is a combination of 5 commits.
1. Date in Cookie can be set via "seconds since epoch" as well.
* In addition to the current string format, we can now set cookies via integer of msec since epoch
* Expiration date can be set via "expires" or "expiry" option ("expires" has priority)
* Returned cookie will contain "expires" as string and "expiry" as msec since epoch
I believe this can simplify code that uses cookies and it doesn't change the functionality.
2. Applying the "--debug" command line options as early as possible.
3. Fixing bug and behaviour in the CookieJar
* It's not possible to set a cookie without a domain: will default to the domain of the page it's set on
* "page.clearCookies()" was broken
* "cookiejar.deleteCookie("name", url)" reimplemented because deleting via "expiration" doesn't work
4. Improving (and more fixing) in the CookieJar
* Purging Session or Expired Cookies now works
* Added boolean return values to inform if the requested cookie operation succeeded
* Timestamps for "expiry/expires" in Milliseconds, as JS does by default
* Improved detection that a cookie has been accepted or rejected by the cookiejar
NOTE: Unfortunately, the Qt provided QNetworkCookieJar is a very limited
and not extremely well designed solution. It doesn't provide any "nice
and clean" CRUD API, and you are only left with a SET/GET to deal with.
Mechanism to understand when and when not a cookie is added are hidden,
and require extra work in the sub-class (our CookieJar) to fill the gap.
5. Methods on the "phantom" object to manipulate the CookieJar.
* phantom.cookies (array of JSON/Cookies)
* phantom.cookiesEnabled (boolean)
* phantom.addCookie
* phantom.deleteCookie
* phantom.clearCookies
Those methods operate on the CookieJar directly and have no URL restriction.
In other words, if page P1 can see set of cookies C1, and page P2 can see set of
cookies C2, "phantom.cookies" can see (i.e. operate upon) both C1 and C2.
This fixes CapserJS which builds a command line like this:
phantomjs bin/bootstrap.js --casper-path=~/capserjs --cli
That works on Phantom 1.6 but not on master due to the qcommandline
port.
Fix by extending qcommandlne to take a ParameterFence flag which causes
it to treat any options after a parameter as arguments. Switch
"scriptname" to use that so the 1.6 behaviour is restored.
http://code.google.com/p/phantomjs/issues/detail?id=55
This is a patch to resolve issue i reported in ticket 773 <http://code.google.com/p/phantomjs/issues/detail?id=773>.
I did build it and run tests seems to be working fine.
I hope this helps a bit :) Also i'm sending friday hugs to everyone on the team.
Addresses [Issue #761](http://code.google.com/p/phantomjs/issues/detail?id=761).
This is a squash of 5 commits.
1. Complete reimplementation of the CookieJar and the Cookie API - Part 1.
The save/load mechanism is inspired by the Qt Demo "browser".
More info: http://doc.qt.nokia.com/4.7-snapshot/demos-browser.html
2. Making the CookieJar a singleton.
We need to have multiple NetworkAccessManager to monitor the network activity of the page,
but we also need to maintain 1 CookieJar: in this way we now have a shared bucket of Cookies.
3. Exposing the new Cookies API to the JS space.
* Updated the completions.
* Ensured backward compatibility of the API.
* It's now possible to "phantom.cookieEnabled = false" to disable cookies completely.
* New methods: addCookie, deleteCookie, clearCookies
4. Provided some internal Doc for the new Cookies API
5. Ensuring the "page.deleteCookie(name)" method works only if a cookie name is given.
* url - current page url
* frameUrl - current frame url
* frameContent - current frame HTML content
* framePlainText - current frame content in Plain Text (no tags)
Fixes [Issue #758](http://code.google.com/p/phantomjs/issues/detail?id=758)
When set to "true", any page that gets created, is
owned by the "page" that control it's lifetime.
Also, the pages can be found in the "page.pages[]" array.
Default value is "true".
Addresses [Issue #151](http://code.google.com/p/phantomjs/issues/detail?id=151)
* Addresses [Issue 678](http://code.google.com/p/phantomjs/issues/detail?id=678)
* "page.close()" deprecated "page.release()"
* the callback "onClosing(page)" gets back the reference to the closing page - that can be ideal to have 1 handler for all the page that close
* It works both when closing directly the page, or if the page closes by itself
* If parent closes, child close too
Tests provided.
http://code.google.com/p/phantomjs/issues/detail?id=603
Squashed commit of the following:
commit 2087320b9549aa2bba53d73e8a681133e5b4fe96
Author: neraliu <neraliu@gmail.com>
Date: Sat Jul 14 20:55:17 2012 +0800
Improve the readability of the function CookieJar::setCookies and CookieJar::cookies.
commit 7ef076e9df488c8f82863cb9c6e31350af5eaad8
Author: neraliu <neraliu@gmail.com>
Date: Fri Jul 13 18:08:07 2012 +0800
Fix the indentation problem in the file cookiejar.cpp.
Remove some commented code segment in cookiejar.cpp.
commit d8fd7f49eb1ba0fb47c27aec9b3dcd36ca14f301
Author: neraliu <neraliu@gmail.com>
Date: Fri Jul 13 18:04:41 2012 +0800
Simplify the implementation of CookieJar::setCookiesFromUrl to use the same security policy of QNetworkCookieJar::setCookiesFromUrl in QtWebkit
commit f5e34d2b787bb9714c45a8ad0baff8b5282d3249
Author: neraliu <neraliu@gmail.com>
Date: Fri Jul 13 17:20:38 2012 +0800
Simplify the implementation of CookieJar::cookiesForUrl to use the same security policy of QNetworkCookieJar::cookiesForUrl in QtWebkit.
commit 5b10e3788cce7bd69bb71c7ee06f0b49e1e92228
Author: Nera Liu <neraliu@gmail.com>
Date: Mon Jun 25 10:56:32 2012 +0800
Remove the clearAllCookies() api by allowing to clear cookies by page.cookies = [] Javascript syntax.
commit a1f12b2913b6f3a3f11a2d22b5eb8c35bf62bf48
Author: Nera Liu <neraliu@gmail.com>
Date: Sun Jun 24 21:48:49 2012 +0800
Implement in-memory cookies storage for CookieJar allowing dynamic cookie manipulation via Javascript for issue 603.
Add sanity check for the in-memory cookies storage for CookieJar.
http://code.google.com/p/phantomjs/issues/detail?id=603
C4900 (Object declared as a struct is defined as a class), C4100 (A formal
parameter to a function is not referenced in the function body), and
C4189 (A variable is declared and initialized, but not used).
http://code.google.com/p/phantomjs/issues/detail?id=744
http://code.google.com/p/phantomjs/issues/detail?id=733
Squashed commit of the following:
commit c6b984442c8631ac13308f5d72fd35973bd964d1
Author: Ilya Grigorik <ilya@igvita.com>
Date: Sun Aug 26 12:23:03 2012 -0700
add onLoad to pageTimings
commit d2bb53cd7340e920c62bed557bef4e3a1cdc62b2
Author: Ilya Grigorik <ilya@igvita.com>
Date: Sun Aug 26 12:01:57 2012 -0700
add mising pageref attr to each entry
Squashed commit of the following:
commit 947ee621067258adc5af382b496868ea6da6a589
Author: Vitaliy Slobodin <vitaliy.slobodin@gmail.com>
Date: Fri Aug 17 10:34:34 2012 +0400
Format code according to http://qt-project.org/wiki/Qt_Coding_Style
commit 5aaaa5338370c77dbd7bf7026949b637da536216
Author: Vitaliy Slobodin <vitaliy.slobodin@gmail.com>
Date: Thu Aug 16 13:12:05 2012 +0400
Add breakpad support for Windows (crashdumps).
Issue: http://code.google.com/p/phantomjs/issues/detail?id=576
Previously, a static build would produce three separate files:
QtWebKit.a, libjscore.a and libwebcore.a. These seem to have
dependencies on each other and this caused the build errors on Linux.
This change means that the sources of jscore and webcore are both built
directly into the QtWebKit.a target. libjscore.a and libwebcore.a are no
longer built. It is then possible to create a static binary on Linux.
http://code.google.com/p/phantomjs/issues/detail?id=413
We use the Qt Meta Object system to create an easily accessible QVariantMap
representation of the Key enumerator, such that we can now write something
like for example
page.sendEvent(keypress, phantom.keys.Backspace);
http://code.google.com/p/phantomjs/issues/detail?id=492
This addresses [Issue #151](http://code.google.com/p/phantomjs/issues/detail?id=151).
Summary of the new API:
- page.pages[]
- page.pagesWindowName[]
- page.getPage(windowName)
- page.windowName
- page.onPageCreated = function(newPage) { ... }
The page object created by the user holds responsibility of the "child" pages it creates.
If a page closes (i.e. window.close()) or a call to "page.pages[i].release()" is done,
the array "page.pages[]" will automatically update to contain only the pages still open.
This is still needed so that injectJs() methods work with CoffeeScript
and so that the main script file can be in CoffeeScript.
It causes duplication of code and some consideration is needed as to
how we could refactor the old inject code so that it uses modules
underneath. Lots of the module functionality written in JS could replace
the old C++ code (CSConverter, most functions in Utils).
http://code.google.com/p/phantomjs/issues/detail?id=47
Instead of using a C++ wrapper, I used a Node version of CoffeeScript
with a small JS wrapper (src/modules/_coffee-script.js). This way, since
the module system is similar enough to the Node.js module system, I only
need to require CoffeeScript in bootstrap.js and all the support for
.coffee is added by CoffeeScript itself.
To include a newer version of CoffeeScript in the source tree, see
tools/import-coffee-script.sh.
http://code.google.com/p/phantomjs/issues/detail?id=47
nativeRequire() has been refactored so that native modules are also
wrapped in Module objects. Additionally, native modules are also
cached and included in stack traces if an error occures inside them.
Phantom::loadModuleSource() has been renamed to
Phantom::readNativeModule() so that it's clear that it's used only to
load native modules.
Finally, all the require() code has been move after setting error
handlers in bootstrap.js so that if an error occurs in the require()
code, the stack trace is printed.
http://code.google.com/p/phantomjs/issues/detail?id=47
Instead of trying to use sourceId to determine what module threw an
error, we now load module's source code using modified
QWebFrame::evaluateJavaScript and leverage PhantomJS's stack traces.
http://code.google.com/p/phantomjs/issues/detail?id=47
Most of the tests passed after merging almost unchanged phantomjs-nodify
code, some needed small changes. The one that is still failing is for
CoffeeScript modules.
http://code.google.com/p/phantomjs/issues/detail?id=47
http://code.google.com/p/phantomjs/issues/detail?id=599
Squashed commit of the following:
commit 2cdcf8a47567f3c067958383843cccf858af531c
Author: Jon Leighton <j@jonathanleighton.com>
Date: Sat Jul 7 19:37:38 2012 +0100
Make lib-bundling/brandelf optional in deploy/package.sh
This configuration has had some problems and we don't wish to use it in
the official packages.
Enable it with --bundle-libs.
commit 2a2155a4e1f5873aa8624859cead9d66750747f4
Author: Jon Leighton <j@jonathanleighton.com>
Date: Sat Jul 7 19:24:40 2012 +0100
notify user if upx is missing
commit 9656a99df0ff101150276dc88e0127f68041f617
Author: Jon Leighton <j@jonathanleighton.com>
Date: Sat Jul 7 19:23:36 2012 +0100
stripping symbols after upx probably doesn't work, reorder that
commit c5f425dc17069c89e7d2ff274309006c728ffab4
Author: Jon Leighton <j@jonathanleighton.com>
Date: Sat Jul 7 19:17:07 2012 +0100
fix logical fail
For some reason, it seems that checking CONFIG(static) inside
src/phantomjs.pro is not reliable. That caused the STATIC_BUILD define
not to be set, and hence Q_INIT_RESOURCE would never get called in
main.cpp.
Instead of using Q_INIT_RESOURCE, let's just compile the resources
directly into the phantomjs binary. This means we don't need to detect
whether Qt is linked statically or dynamically.
https://code.google.com/p/phantomjs/issues/detail?id=430
We are linking against e.g. libQtCore.so.4 rather than
libQtCore.so.4.8.2, and this affects symbol generation. (I am not sure
if this changed at some point, but this change should make it generate
the correct symbol files regardless.)
Also makes it less dependent on the Qt version.
Debug mode turns off all optimisations. This make PhantomJS considerably
slower.
Instead, we build in 'release' mode, but generate debugging symbols at
the same time.
This may present some problems analysing crashes, if the optimisations
make that difficult. However, in my testing I was able to get useful
debug output even with optimisations enabled. So we should see how we go
- if it becomes a problem we can produce seperate debug binaries with no
optimisations.
https://code.google.com/p/phantomjs/issues/detail?id=599
This provides support for compiling the breakpad client into PhantomJS,
and generifies that Linux packaging scripts so that they also apply to
OS X and automate the symbol generation.
Building the Breakpad tool programs seems to be less than
straightforward on OS X, and documentation is poor. We have managed to
produce tools/dump-syms-mac.pro which allows building the dump_syms
program for dumping the debugging symbols. This needed a couple of
modifications to breakpad in order to compile successfully.
We have run out of time to work on making the minidump_stackwalk program
build. However, this is solely a developer tool and so it can wait until
after the 1.6 release before we complete this work.
Testing is welcome!
https://code.google.com/p/phantomjs/issues/detail?id=576
When console.error was called, there was a segfault because it was
treated as an uncaught exception, but did not have the correct stack
trace information (I am not sure why, but still...)
Now that we are generating the stackTrace in WebCore::reportException,
the MessageType gets set correctly, so we can use this to differentiate
between uncaught exceptions and other messages.
https://code.google.com/p/phantomjs/issues/detail?id=47
On reflection, this approach seems like a bad idea and a source of bugs.
I think passing object references between pages seems inherently
problematic, and we are better off just passing data to the onError
handler. If users need the actual object reference, they are able to use
try ... catch within the page.
This change also means that we are no longer breaking backwards
compatibility with the page.onError function signature.
WebCore already has a bunch of plumbing to pass around stacks. This
exists for the inspector/console. However, we need to actually retrieve
the error stack in WebCore::reportException.
To achieve this, I am attaching a stackArray property to the error
object. This is not as clean as I'd like, but seems ok for now. (We
should not document stackArray though.)
https://code.google.com/p/phantomjs/issues/detail?id=166
1. Passing JavaScript eval and other related actions to the CurrentFrame, not the MainFrame.
2. Added different methods to navigate between frames
3. With a call to "window.frames[0].focus()", the "currentFrame" changes: commands after that are sent to the new frame under focus.
4. The navigation between frames allows to walk over the "tree of frames" contained in the page.
This commit also adds examples (both in JS and CoffeeScript) and Unit Test.
http://code.google.com/p/phantomjs/issues/detail?id=573
The callback is harmless: if the user registers a "page.onCallback = [Function]",
that will receive any JS type passed via "phantomCallback()".
Also, if the handler for ".onCallback" returns a value, that is passed back as a
return value of "phantomCallback()".
Also, added "page.onConfirm" and "page.onPrompt".
This solves [Issue #133](http://code.google.com/p/phantomjs/issues/detail?id=133).
This is useful in case:
* we don't care about the result of the evaluate
* we don't need to have the result of the evaluate on the spot
* we need the stack of execution to begin WITHIN the page
Also, linting code: everyone should use a linter when writing Javascript. Everyone.
http://code.google.com/p/phantomjs/issues/detail?id=593
This removes the need to build breakpad as a separate step.
PhantomJS developers will still need to cd src/breakpad && ./configure
&& make in order to analyse crash dumps, but it is not longer necessary
in order to build PhantomJS itself.
https://code.google.com/p/phantomjs/issues/detail?id=576
This adds a new WebPage::zoomFactor property, which can be used to
zoom the page, i.e.:
page.zoomFactor = 1.5; // zoom by 50% in
page.zoomFactor = 0.5; // zoom by 50% out
The rasterize.js example is adapted to take an optional fourth argument
to set the zoom factor. Furthermore, the webpage-spec is extended with
a simple test case for the new property.
ISSUE: 579 (http://code.google.com/p/phantomjs/issues/detail?id=579)
Note that for errors that occur within subpages, this object is not the
real error object, but a copy. This is because the real object exists
within the subpage, but the page.onError handler runs within the main
context, so we have to pass it through as data.
https://code.google.com/p/phantomjs/issues/detail?id=166
Info.plist is needed to surpress the dock icon. Up to now, we need to have
the file available at run-time. With this change, the contents of
Info.plist are embedded in the executable at the linking stage, thus
there is no need to deploy the Info.plist file anymore.
Credit to Smokey Ardisson for the tip.
http://code.google.com/p/phantomjs/issues/detail?id=528
ISSUE: 460 (http://code.google.com/p/phantomjs/issues/detail?id=460)
this is a backport from qtbase:
commit 89cfe9eb01ad75c14121dbd6038b7c791226acf1
Author: Jiang Jiang <jiang.jiang@nokia.com>
Date: Thu Nov 10 18:01:56 2011 +0100
We need to reregister fonts in initializeDb because basic font db
doesn't have an internal record like fontconfig does, so just
repopulating the font database won't work. db->reregisterAppFonts
is now used properly as intended (reregister application fonts
after the system font database has been cleared).
Also, static variable 'initialized' in initializeDb() is removed
since we check privateDb()->count to see if it needs to be populated
again.
Task-number: QTBUG-22063
Change-Id: Ifc66392b56b72acbe08b99256c61421c204be5d7
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
After the change to system.args which has the app as first element,
the rasterize example was not properly adapted. Due to that, one
could not pass a size parameter to it anymore, resulting in PDFs
without page breaks.
ISSUE: 523 (http://code.google.com/p/phantomjs/issues/detail?id=523)
The comment now explains how to delegate the header/footer setup
to the loaded HTML page by giving an explicit HTML example that
defines the required PhantomJSPrinting object
ISSUE: 512 (http://code.google.com/p/phantomjs/issues/detail?id=512)
The script now copies all required shared libraries found via ldd
to the deployment folder.
Furthermore, a run-script is created that runs the phantomjs binary
through the copied build-host's ld-linux.so to ensure all symbols
are properly resolved.
Last but not least, we now include a very slightly modified brandelf.c
from FreeBSD. This version can be compiled on Linux machines and is
used to change the ELF ABI of the binary and libs in the deployment
folder, such that they all use the old SYSV OS ABI for compatibility.
Usage:
$ package-linux-dynamic.sh
$ scp phantomjs-$version.tar.bz2 yourhost
$ ssh yourhost
$ tar -xf phantomjs-$version.tar.bz2
$ ./phantomjs-$version/phantomjs.sh
CC ISSUE: 413 (http://code.google.com/p/phantomjs/issues/detail?id=413)
(proper static build would still be desirable eventually if possible)
Especially on machines that are connected to a compile farm, the
MAKEFLAGS env var is usually set to configure the default number
of jobs that should be used. This way, one can just call the
PhantomJS build script without passing the number of jobs every
time.
ISSUE: 503 (http://code.google.com/p/phantomjs/issues/detail?id=503)
Usage:
page.paperSize = {
margin: "1cm",
header: {
height: "1cm",
contents: phantom.callback(function(pageNum, numPages) {
return "<h1>" + pageNum + " / " + numPages + "</h1>";
})
},
footer: {
height: "0.5cm",
contents: phantom.callback(function(pageNum, numPages) {
return "<h2>" + pageNum + " / " + numPages + "</h1>";
})
}
};
Note: The contents can return arbitrary HTML but since we cannot
re-layout the whole website for every page, the header/footers
must have the static height defined in the height property.
Note: The new example printheaderfooter.js shows the usage. It
also shows how one could delegate the above to a JavaScript
function on the loaded website, which allows one to print pages
and let the actually printed page decide how the header/footer
should look like.
Note: The page-counter can be reset by adding the class "phantomjs_reset_pagination"
to HTML block-elements that should reset the counter.
ISSUE: 410 (http://code.google.com/p/phantomjs/issues/detail?id=410)
commit c373ac4d17814588f4e3344f634ec469e56c0303
Author: Danny Wang <wangyang0123@gmail.com>
Date: Tue Apr 10 12:38:13 2012 +0800
moved i and l delarations to the top of page.evaluate()
commit bf24d4d1ecdb9e06c7bf461e87c222b10b74bc9d
Author: Danny Wang <wangyang0123@gmail.com>
Date: Tue Apr 10 08:54:55 2012 +0800
fixed defects in evaluate() pointed out by detro
commit 0bb8cff7803b70fe60fd761b1b748b5510705ee0
Author: Danny Wang <wangyang0123@gmail.com>
Date: Fri Apr 6 19:21:47 2012 +0800
added passing variables to function for page.evaluate
http://code.google.com/p/phantomjs/issues/detail?id=132
[Issue 439](http://code.google.com/p/phantomjs/issues/detail?id=439).
This works for all kind of "Content Body" but with raw bytes: the issue is that QtWebKit doesn't know how to convert a "QByteArray" to a "QVariant" (to inject it in the JavaScript space), resulting in a malformed conversion (somehow it decides to create a map where byte position is the 'key' and the byte at that position is the 'value').
This fix covers most scenarios (hopefully) but we are blocked on solving it completely.
Stop passing around lineNumber and sourceID as they are unused and don't
contain useful information.
Also declare Q_UNUSED on them to fix compiler warnings.
The hasHandler flag passed to JSC::Debugger::exception only applies to
the current stack frame. It does not indicate if there are exception
handlers in earlier stack frames.
Therefore, we are saving the frame when an exception occurs, but only
reporting the exception if it is still present once the stack has been
fully unwound.
http://code.google.com/p/phantomjs/issues/detail?id=166
add a default error handler on all pages. people can override if they
need.
ensure error handler can be removed without errors.
Hack ScriptSourceCode so we can pass in a raw string and not have it
validated as a URL
change source location hint for webpage.evaluate().
http://code.google.com/p/phantomjs/issues/detail?id=166
Please enter the commit message for your changes. Lines starting
In non-static build, JPEG is built as plugin. We force to have JPEG
support built-in by explicitly change a variable in the configure
script (unfortunately this can't be done via command-line options).
http://code.google.com/p/phantomjs/issues/detail?id=163
These classes are from the official Qt 4.8.0 platform plugins with some
tweaks:
* By default, use Fontconfig font database.
* No need to save the captured screen on every flush.
* Enlarge the screen to make it more like a typical desktop size.
http://code.google.com/p/phantomjs/issues/detail?id=163
This addresses [Issue #409](http://code.google.com/p/phantomjs/issues/detail?id=409).
The script:
* Get the latest code. Since LineNoise is pretty small, grabbing the tarball straight from the repo should be just fine.
* Extract and place the files in the right directory (src/linenoise).
* Remove unnecessary stuff (project files etc).
* Update the src/linenoise/README.md to refer to the revision being imported.
The recent patch that brought asynchronous webserver response handling
made it impossible to have proper keep-alive support in the server.
We want the server to support keep-alive though, which is especially
useful when writing a PhantomJS script that allows one to "remote control"
PhantomJS, using the WebServer API, without flooding the TCP connections.
Also the performance might be improved.
Note: This patch reverts commit bbce8920d0,
and resets the Mongoose code to the vanilla 3.0 version. Instead we now
support the async handling of HTTP requests using some QWaitCondition
magic.
Note: keep-alive support is optional, and disabled by default. To enable
it, use something like:
server.listen(port, {"keep-alive": true}, function(request, response) {...});
Like before, calling response.close() is crucial. Furthermore though, a
server that has keep-alive enabled *must* set a proper "Content-Length: ..."
header in it's response, otherwise clients will not be able to know when
the response has finished.
fix memory leaks in webserver
ISSUE: 416 (http://code.google.com/p/phantomjs/issues/detail?id=416)
Compositing depends on Graphics View and/or GL-based texture mapper.
Since we don't plan to support either of them, at least for the near
future, we might as well disable compositing.
http://code.google.com/p/phantomjs/issues/detail?id=414
In the current state of our imported minimalistic Qt, some header files
are missing. Since the module include like <QtGui> just includes
everything, this leads to a preprocessor error.
The solution is to include only needed headers from particular class.
http://code.google.com/p/phantomjs/issues/detail?id=226
This covers [Issue 252](http://code.google.com/p/phantomjs/issues/detail?id=252)
The commit is composed of 12 squashed commits:
commit efdc6ba4f143c30a690fd97d92d80fa412e79999
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Mon Feb 27 00:19:36 2012 +0000
Pretty-pringing and Completion Caching done!
* This completes pretty-printing for the result of evaluated
* expressions in the REPL.
* Also, now we cache the "possible completions", to speed things up
* a bit (nothing fancy though).
* Minor tweaks to the internal doc and the way we "mock"
* pretty-printing for QObjects/REPLCompletanle
* All tests passing :)
commit 1f9ef690e112a535b431fca409b77bb9c09d1c70
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Feb 26 22:35:00 2012 +0000
Moving most of REPL shim JavaScritp code in a separate file. Way
easier to work on.
commit 02d460a16fee14e7096ae7d899c03902c5b8a9c6
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sat Feb 25 20:25:18 2012 +0000
Initialisation of the Completions is now done in a pure virtual.
This means that every REPLCompletable object will ACTUALLY register
completion strings, ONLY if we are running a REPL
and that object is ACTUALLY created.
Otherwise, why bother?
Adding completions for all exposed REPLCompletable objects
Also, fixed an issue with _getCompletions()
commit 412c3778fb04aa1c7379f8e760afce702b0428dd
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Feb 21 00:49:17 2012 +0000
Few more tweaks to the REPL:
- Now 'phantom' is the first QObject with proper completion
- No repetition in QObject completions
- LVAL of any user expression is now correctly prettified and
printed
Major things left to do:
- Cache completions (using QCache?)
- Add completions for the other QObject
- When the LVAL of a user expression is a QObject, print what's
expected, not the QObject "real" structure
commit 46f04713c8165d898055e15478bb31403f8c93f1
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Feb 7 10:13:23 2012 -0800
Pretty-print expressions result
Still not done though: there are issues with the NON-Native JS
objects.
commit 98b2fe67651dc750b62c6fa9cf1d80317fd9ae06
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Fri Feb 3 00:22:52 2012 -0800
Introducing REPLCompletable.
This class should be inherited by any JavaScript-exposed QObject, to
ensure correct Auto-Completion.
Correct auto-completion for QObjects.
- Now even QObjects can correctly provide auto-completion, and avoid
showing "not for users" methods
- The strings used for the auto-completion are stored in a single
Index: minimum memory footprint
- Still, there is optimization that should be done (when "searching"
for the right completion by prefix)
- Completion for the objects not set up yet, but now it's just a
trivial sequence of "addCompletion('bla')" in their constructors
commit 9bd48618154b1530a37b41f4060440184e23253d
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Thu Feb 2 00:20:25 2012 -0800
Changing the way we import Linenoise.
Will just import a specific commit, and update manually when needed.
commit cfc9bae9fbdab13b01019b34b7cbd565e3153780
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 29 23:22:26 2012 -0800
Made the REPL into a Singleton. With Auto-completion!.
Reasons:
1) Needed a pointer to function (i.e. a static method) to be used
with Linenoise to provide auto-completions
2) It makes more sense, as it's not like we are going to have 2 REPL
running at the same time, are we?
There are problems to address:
- the enumeration in JS seems to return only the native interface of
our objects
- the function completions contain argument types of those functions
- "private" methods are exposed
commit c78bd32e17f8e0e4cc4a0066858de8cc81d33b97
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 29 22:10:20 2012 -0800
Migrating from the original, now [unmantained
Linenoise](https://github.com/antirez/linenoise) to the fairly active
[tadmarshall fork](https://github.com/tadmarshall/linenoise).
Also now the project is imported as a Git Submodule.
Having migrated to the latest Linenoise (see prev. commit), now this
_SHOULD_ work on Windows too.
But, of course, this needs testing. :)
commit 43713c5723d7c5ed446ba41ae8d6f8c9feba7f9b
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Tue Jan 24 23:17:06 2012 -0800
Now that the basics work, I'm adding support for REPL history.
This is something almost everyone today is accustomed to.
Also, now REPL history works!
And I found some useful resources to solve pending TODOs.
commit 31e5f88b044a5b4a823c67527ef8c245d2ac7863
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Sun Jan 22 20:56:36 2012 -0800
Adding Linenoise Project (https://github.com/antirez/linenoise).
For now is included as a drop-in set of files.
Later on, if the Linenoise project has frequent
updates, we might prefer to do it as a
git-submodule.
commit 4be9c15c65db4767e482fba0be13f8aab286d5f3
Author: Ivan De Marino <ivan.de.marino@gmail.com>
Date: Thu Jan 5 15:31:13 2012 +0000
First simple REPL implementation.
- Not complete
- Still doesn't handle arrow keys (needed for history)
in such cases, DISABLE_HEADLESS was unset and hence
the expansion -a -eq 0 resulted in a bash error:
bash: [: too many arguments
this is fixed now by using string-based comparison
http://code.google.com/p/phantomjs/issues/detail?id=197
This is done via the tools/import-qt.sh script. Note that the script
also removes some unnecesary stuff. In practice, src/qt is not as
big as the plain vanilla Qt source tree.
http://code.google.com/p/phantomjs/issues/detail?id=226
CommonJS proposal: http://wiki.commonjs.org/wiki/Filesystem/A.
It's called "raw".
http://code.google.com/p/phantomjs/issues/detail?id=400
Squashed commit of the following:
commit dd5fab4778bb7b67f1eca26a07d430aadd458c6e
Author: Milian Wolff <milian.wolff@kdab.com>
Date: Thu Feb 23 16:19:21 2012 +0100
the "mode" string is now properly parsed, and not only the first
char evaluated. This allows us to do fancy things like
fs.open(file, "rw+"); // read/write/append
Furthermore .read() is adapted such that it will always return the
full file contents, no matter where we have seeked to before (i.e.
by passing + we seek to the end, hence read() would always return
an empty string).
To open a binary file, pass "b" in the mode string to fs.open, e.g.:
fs.open(file, "rb"); // read binary
fs.open(file, "wb"); // write binary
fs.open(file, "rwb+"); // read/write binary, append
alternatively, one can use these shortcuts:
fs.write(file, contents, "b"); // write binary
fs.read(file, "b"); // read binary
Unit tests are extended and the echoToFile.js example fixed (it did not
close the file, which lead to the contents never getting written
on-disk since flush() is never called).
Also note that the FileSystem::open method was cleaned up and at least
one memory leak (if QFile* could not open) was fixed. The code should
now also be more C++-like.
commit 41139951138491459accefab22d48eba7b0b9900
Author: Milian Wolff <milian.wolff@kdab.com>
Date: Wed Feb 15 16:39:23 2012 +0100
use QString instead of QByteArray for raw binary data
QByteArray is simply unusable in JavaScript, since functions like
e.g. window.btoa expect a string. Also there is no sane way to
create a byte array in javascript, as ArrayBuffer e.g. is not
supported by QScript (at least there is no conversion in place).
If we use QString and some custom read/write code this all works
as expected though, we can use window.btoa to base64 encode binary
data and we can create random binary data using String.fromCharCode
also adds a unit test
commit e45673486ef27daf916902153217f9e5001b68c9
Author: Milian Wolff <milian.wolff@kdab.com>
Date: Wed Feb 15 14:39:15 2012 +0100
make it possible to read/write raw/binary files
this adds File::readRaw and File::writeRaw functions,
as well as 'shimmed' versions FS::readRaw and FS::writeRaw
these functions directly use QFile and QByteArray instead of
QTextStream and QString, making it possible to read and write
binary data, e.g. images and such.
Currently trying to use the remote debugger with sub-pages created in
the phantomjs session will result in a segfault inside QtWebKit. With
this patch, it works.
http://code.google.com/p/phantomjs/issues/detail?id=6
Now the left/top/right/bottom print margins can be set separately
using the pageSize.margin property. You can either use
pageSize.margin = "10px"
or use a map to set the margins separately:
pageSize.margin = {
left: "10px",
top: "5cm",
right: "7in",
bottom: "13mm"
};
pageSize.border is now a synonym for pageSize.margin to keep
compatibility to existing scripts.
ISSUE: 388 (http://code.google.com/p/phantomjs/issues/detail?id=388)
For POST and PUT request we now read all data as defined by
the Content-Length header into request.rawData property.
This property is a QByteArray which neatly maps to an array
in javascript.
For POST requests with Content-Type = applicaiton/x-www-form-urlencoded
we furthermore provide a parsed, easy-to-use request.post property.
This one is a QVariantMap of the decoded form data.
There is a new postserver.js example that shows the usage.
The unit test is extended to test the new (and old) features
of the server.
TODO: test that verifies proper decoding of UTF8 data, which
is not yet possible since I see no way to do a post-request
using phantomjs with an explicitly defined charset
ISSUE: 340 (http://code.google.com/p/phantomjs/issues/detail?id=340)
Most command-line programs provide an option to display the usage
message. Currently, this is achieved by passing no options at all.
This change allows for a more intuitive way for users to check the
list of available options.
http://code.google.com/p/phantomjs/issues/detail?id=347
With Qt 4.8, POST request with an empty content type will make the
content type set to "application/octet-stream". Somehow this breaks
POST.
The fix is to set the content type to "application/x-www-form-urlencoded",
like the case with Qt 4.7.
Based on the suggestion by Leo Franchi.
http://code.google.com/p/phantomjs/issues/detail?id=337
Also make it always put the files in deploy/, regardless of where the
script is run from. (So use can run deploy/build-linux.sh from the root
directory.)
Code was added to WebKit to detect whether the click event on the file
input element is triggered by user action or by a script. If it's by a
script, the event is ignored. This prevented us from simulating a click
on the element.
This fix just patches WebKit to remove the detection.
The relevant WebKit commit is:
931870c11b
The associated WebKit bug is:
https://bugs.webkit.org/show_bug.cgi?id=47593
Our bug is:
http://code.google.com/p/phantomjs/issues/detail?id=307&q=upload
This page describes how to contribute changes to PhantomJS.
Please do **not** create a pull request without reading this guide first. Failure to do so may result in the **rejection** of the pull request.
## For The Impatients
**Work on a feature branch**.
If your changes need to be modified due to some reviews, it is less clutter to tweak an isolated feature branch and push it again.
**Create a ticket in the issue tracker**.
This serves as a placeholder for important feedback, review, or any future updates.
In the commit message:
* **Keep the first line < 72 characters**. Write additional paragraphs
if necessary.
* **Put the link to the issue** (see above). This is important for cross-referencing purposes.
## Communicate
*Second opinion is always important.*
**Bug fixing**. If you have a fix for a bug, please attach your patch in the corresponding issue in the [issue tracker](https://github.com/ariya/phantomjs/issues). If there is no entry for the bug yet, then please create a new one. If you are confident working with Git, see the Get Ready section below on how to submit your change.
**Improvement and feature request**. If you have an improvement idea, please send an email to the [mailing list](http://groups.google.com/group/phantomjs) (rather than contacting the developers directly) so that other people can give their insights and opinions. This is also important to avoid duplicate work.
**Task management**. Once the feature idea is agreed upon and translated into concrete actions and tasks, please use the [issue tracker](https://github.com/ariya/phantomjs/issues) to create an issue for each individual task. Further technical discussion about the task and the implementation details should be carried out in the issue tracker.
**Extending with new API**. Whenever you want to introduce a new API, please send an email to the mailing list along with the link to the issue. Consider good API name for the object or function, read the [API Design Principle](http://developer.qt.nokia.com/wiki/API_Design_Principles) article. It may require few iterations to agree on the final API and hence it is important to engage all interested parties as early as possible.
## Get Ready
For your proposed change, you need to have:
* **an issue** (in the issue tracker) which describe your bug or feature
* **a feature branch** in your git fork
### Refer the Issue
The commit message needs to link to the issue. This cross-reference is [very important](http://ariya.ofilabs.com/2012/01/small-scale-software-craftsmanship.html) for the following reasons.
First, the commit log is frozen and can not be changed. If it contains a mistake or outdated information, the log can not be amended. However, further updates can be still posted to the linked issue, which can be followed from the commit log itself.
Second, it provides a placeholder for code review and other feedback.
An example of a bad commit log:
Fix Mountain Lion
The above log is too short and useless in the long run. A better version (and note the issue link):
Better support for OS X Mountain Lion.
require('system').os.version should give "10.8 (Mountain Lion)".
https://github.com/ariya/phantomjs/issues/10688
### Use Feature Branch
To isolate your change, please avoid working on the master branch. Instead, work on a *feature branch* (often also known as *topic branch*). You can create a new branch (example here crash-fix) off the master branch by using:
git checkout -b crash-fix master
Refer to your favorite Git tutorial/book for further detailed help.
Some good practices for the feature branch:
* Give it a meaningful name instead of, e.g. `prevent-zero-divide` instead of just `fix`
* Make *granular* and *atomic* commits, e.g. do not mix a typo fix with some major refactoring
* Keep one branch for one specific issue. If you need to work on other unrelated issues, create another branch.
## Review and Merge
When your branch is ready, send the pull request.
While it is not always the case, often it is necessary to improve parts of your code in the branch. This is the actual review process.
It has **fast** and **native** support for DOM handling, CSS selector, JSON, Canvas, and SVG.
PhantomJS ([www.phantomjs.org](http://phantomjs.org)) is a headless WebKit scriptable with JavaScript. It is used by hundreds of [developers](http://phantomjs.org/buzz.html) and dozens of [organizations](http://phantomjs.org/users.html) for web-related development workflow.
PhantomJS is cross-platform, it can be compiled for Linux, Windows, FreeBSD, and Mac OS X.
Refer to the [build instructions](http://code.google.com/p/phantomjs/wiki/BuildInstructions)
for details.
The latest [stable release](http://phantomjs.org/release-2.0.html) is version 2.0.
**Note**: If you are on Mac OS X, [read the notice](http://code.google.com/p/phantomjs/wiki/BuildInstructions#Mac_OS_X)
before you start using `brew` or `port` to install Qt and/or PhantomJS.
**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.
PhantomJS scripts can be written in JavaScript or [CoffeeScript](http://jashkenas.github.com/coffee-script/).
## Use Cases
See also [quick start guide](http://code.google.com/p/phantomjs/wiki/QuickStart)
and more [advanced examples](http://code.google.com/p/phantomjs/wiki/ServiceIntegration)
which show various PhantomJS scripts, covering:
- **Headless web testing**. Lightning-fast testing without the browser is now possible! Various [test frameworks](http://phantomjs.org/headless-testing.html) such as Jasmine, Capybara, QUnit, Mocha, WebDriver, YUI Test, BusterJS, FuncUnit, Robot Framework, and many others are supported.
- **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.
* getting driving direction
* showing weather forecast conditions
* finding pizza in New York
* looking up approximate location based on IP address
* pulling the list of seasonal food
* running regression tests from command line
* producing PDF version of a Wikipedia article
* rasterizing SVG to image
## Features
Do not forget to consult the concise [API Reference](http://code.google.com/p/phantomjs/wiki/Interface).
- **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.
PhantomJS is based on [Qt](http://qt.nokia.com). There are two implementations, using C++ and Python.
## Ecosystem
PhantomJS needs not be used only as a stand-alone tool. Check also some excellent related projects:
- [CasperJS](http://casperjs.org) enables easy navigation scripting and common high-level testing.
- [Guard::Jasmine](https://github.com/netzpirat/guard-jasmine) automatically tests Jasmine specs on Rails when files are modified.
- [GhostDriver](http://github.com/detro/ghostdriver/) complements Selenium tests with a PhantomJS WebDriver implementation.
- [PhantomRobot](https://github.com/datakurre/phantomrobot) runs Robot Framework acceptance tests in the background via PhantomJS.
- [Mocha-PhantomJS](https://github.com/metaskills/mocha-phantomjs) run Mocha tests using PhantomJS.
and many others [related projects](http://phantomjs.org/related-projects.html).
## 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.
The latest [stable release](http://code.google.com/p/phantomjs/wiki/ReleaseNotes) is version 1.4 ("Glory of the Snow").
If you want to contribute, please read the [Contribution Guide](http://code.google.com/p/phantomjs/wiki/ContributionGuide).