Commit Graph

159 Commits (master)

Author SHA1 Message Date
Vitaliy Filippov f37c7e29e0 Remove QT source and make phantomjs compile with unmodified QT, fix binary encoding of web response 2015-02-07 01:48:33 +03:00
Vitaly Slobodin 12870d90ad Fix JPG image rendering.
To pass QString as a const char* we should call <QString>.toLocal8Bit().constData().

https://github.com/ariya/phantomjs/issues/12684
2014-11-14 08:22:52 -08:00
Ariya Hidayat 5768b705a0 Implement clearMemoryCache() on a web page to clear the cache.
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
2014-09-25 07:09:33 -07:00
Ariya Hidayat 8cabfed4b3 Remove GIF format for screen capture export (render).
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
2014-08-23 09:20:20 -07:00
John Gozde de2a19da9c Use Array.prototype.slice in window.callPhantom.
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
2014-08-18 00:15:08 -07:00
Vitaliy Slobodin cf12fc4a23 Long live PhantomJS 2!
https://github.com/ariya/phantomjs/issues/10448
2014-07-27 07:47:34 -07:00
Sven Eckelmann 800fbe8452 Don't scale the unit px to 1/2.54 points for PDFs
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")
2014-05-31 08:23:13 -07:00
Rikke Simonsen bda8838698 Fix for crash bug caused by Iframe NULL reference
https://github.com/ariya/phantomjs/issues/10947
https://github.com/ariya/phantomjs/issues/11103
https://github.com/ariya/phantomjs/pull/11984
2014-02-19 21:30:11 -08:00
Joseph Rollinson 244cf251cd Adds support for multiple Cookie Jars.
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
2014-01-10 16:12:39 -08:00
James McParlane dca15d7ff6 Added onRepaint callback to webpage API.
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
2014-01-06 23:05:30 +00:00
Ivan De Marino 9bfe22b428 Merge pull request #11784 from vvavrychuk/parse-error
fix lack of parse time errors location info
2014-01-06 11:30:29 -08:00
Brad Daily e40ebb93d7 Pass modifier to mouse events for click/dblclick
A fix for the issue described here:

https://github.com/ariya/phantomjs/issues/11867
2014-01-01 11:06:11 -05:00
Vitaliy Slobodin efcc6c7861 Define the new page callback for interrupting a long-running JavaScript
Issues:
https://github.com/ariya/phantomjs/issues/11198
https://github.com/ariya/phantomjs/issues/11183
https://github.com/ariya/phantomjs/issues/11189
2013-11-23 22:09:39 -08:00
Vasyl Vavrychuk c8e4215097 fix lack of parse time errors location info
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
2013-11-24 01:43:10 +02:00
Vitaliy Slobodin 1a25383307 Use Qt::transparent to resolve graphical artifacts with images with transparent background.
We need to use QImage::Format_ARGB32_Premultiplied on Windows to preserve a text hinting and antialiasing. Using the function `qRgba()` leads to wrong pixel values on a target image. Since, `QImage::fill(uint pixel)` doesn't handle the QImage::Format_ARGB32_Premultiplied format, so we need to use the another overload `QImage::fill(const QColor &color)`

Issues:
https://github.com/ariya/phantomjs/issues/11276
https://github.com/ariya/phantomjs/issues/11007
https://github.com/ariya/phantomjs/issues/11366
2013-06-24 01:07:24 +04:00
Tom Aizenberg 52883ced68 WebPage: network timeout setting.
Fixes issue #11129.

https://github.com/ariya/phantomjs/issues/11129
2013-03-19 22:57:26 -07:00
Max Desyatov 357dbf46d2 Support for specifying request body encoding for WebPage::openUrl
doesn't break existing functionality and currently supports only
"utf-8" and "utf8" encodings

Fixes http://code.google.com/p/phantomjs/issues/detail?id=1043
2013-03-18 21:43:00 -07:00
Ivan De Marino 9740990990 New "page.loading" and "page.loadingProgress".
Now you can know about the Page Loading Progress
using 2 property:
- [bool] page.loading
- [int: 0-100] page.loadingProgress

Implements #1091: http://code.google.com/p/phantomjs/issues/detail?id=1091
2013-03-17 16:24:47 +00:00
Ariya Hidayat 43ab20d4ae Prevent possible crash on pages with iframes.
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
2013-01-28 21:13:47 -08:00
bongole 0734811514 Add rendering to stdout and stderr.
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
2013-01-21 21:44:18 -08:00
Vitaliy Slobodin 6d81933941 Pass the resource URL to the resourceError handler.
http://code.google.com/p/phantomjs/issues/detail?id=997
2013-01-21 21:42:10 -08:00
Ivan De Marino 4dec091ac2 FIX: Check file exist when attempting upload.
Both "page.uploadFile()" and "onFilePicker = function() {}" check file exists before accepting them.
If file don't exists, they are "ignored".

Fixes issue #941: https://code.google.com/p/phantomjs/issues/detail?id=941
2013-01-17 23:45:34 +00:00
Ariya Hidayat d58eae54d7 Ensure we describe onNavigationRequested behavior properly.
http://code.google.com/p/phantomjs/issues/detail?id=562
2013-01-09 20:26:55 -08:00
Vitaliy Slobodin 09e929d599 Allow to abort network requests.
Issue: http://code.google.com/p/phantomjs/issues/detail?id=230
2013-01-04 23:39:23 -08:00
Vitaliy Slobodin fd700b0702 New WebPage callback: onResourceError.
This callback is invoked when the WebPage was unable to request the resource

Issue: http://code.google.com/p/phantomjs/issues/detail?id=954
2013-01-04 21:24:30 -08:00
execjosh d906bc3819 Automate lazy generation of REPL completion lists
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
2013-01-04 21:23:58 -08:00
qubird f6a91a8813 New WebPage#setContent api - makes possible to specify location along with content
http://code.google.com/p/phantomjs/issues/detail?id=909
2012-12-16 15:43:10 -08:00
Vitaliy Slobodin 5eb0f64e6b Fix window.location.
Description:
Web Page can't navigate to a relative url using the property 'window.location'.

Upstream bug:
https://bugs.webkit.org/show_bug.cgi?id=47978

Issues:
http://code.google.com/p/phantomjs/issues/detail?id=632
http://code.google.com/p/phantomjs/issues/detail?id=530
2012-12-12 17:03:37 +04:00
Jon Leighton 487fbf3035 Enable multiple files to be uploaded to a file input
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
2012-12-11 21:41:02 -08:00
Ivan De Marino 9ba13ba989 Implementing "goBack", "goForward" and "go".
Completing work for [Issue #808](http://code.google.com/p/phantomjs/issues/detail?id=808).
2012-11-18 16:11:25 -08:00
Ivan De Marino eadb03a978 Adding "page.onFilePicker" callback.
This addresses [Issue #843](http://code.google.com/p/phantomjs/issues/detail?id=843).
Important: this doesn't change the ability to use
"page.uploadFile", that will keep working as expected.
2012-11-03 18:41:18 +00:00
Ivan De Marino b113993314 MINOR: Avoid frame switching if already there.
Useless to change frame if it's already the right one.
Makes it clearer what is going on when debugging.
2012-11-03 14:38:22 +00:00
Ivan De Marino 3fe308bf8c Adding Navigation methods.
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.
2012-11-03 14:38:22 +00:00
Ivan De Marino e31528adfe "onLoadFinished" works regardless of "page.open"
Addresses [Issue #801](http://code.google.com/p/phantomjs/issues/detail?id=801)
2012-11-03 14:38:21 +00:00
Ivan De Marino 3f874067f5 Add properties "page.title" and "page.frameTitle"
Addresses [Issue #799](http://code.google.com/p/phantomjs/issues/detail?id=799)
2012-11-03 14:38:21 +00:00
Jim Evans 395af9cada Correcting keycodes sent for lowercase characters
http://code.google.com/p/phantomjs/issues/detail?id=852
2012-11-02 20:41:57 -07:00
Jim Evans c2df526110 Fixing sending of double-click events
http://code.google.com/p/phantomjs/issues/detail?id=848
2012-11-01 07:18:40 -07:00
Ivan De Marino f2628b32fe Fix compilation issue on Ubuntu.
Reported [here](https://github.com/ariya/phantomjs/commit/402a8d9753395edffb4811aa1834ff31a051e27#commitcomment-2079231).
Conversion from `NULL` to `QVariant()` doesn't work implicitly on Ubuntu.

http://code.google.com/p/phantomjs/issues/detail?id=835
2012-10-31 20:38:16 -07:00
Jim Evans f402a8d975 Implementing modifier keys in sendEvent()
http://code.google.com/p/phantomjs/issues/detail?id=835
2012-10-28 20:56:46 -07:00
Johan Sköld b7ca845327 Gave page a maxAuthAttempts setting.
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
2012-10-24 00:02:59 -07:00
Ariya Hidayat 63e06cbcbf Revert breaking behavior in commit ecda224233.
Keeping the page alive instead of destroying causes unexpected behavior
compared to version 1.6 and earlier. See the discussion:
https://groups.google.com/d/topic/phantomjs/C84fmd21LDk/.

http://code.google.com/p/phantomjs/issues/detail?id=719
2012-09-24 07:31:27 -07:00
Shawn Krisman ecda224233 Revert "Fix crash on exit (Issues #136, #148 and #149)"
This reverts commit 5acaa6b42d.

Conflicts:

	src/phantom.cpp
	src/phantom.h

removed m_page deletion.

http://code.google.com/p/phantomjs/issues/detail?id=719
2012-09-21 00:07:09 -07:00
Ariya Hidayat 9f8056334e Keep ARGB32 premultiplied format for Windows for the time being.
http://code.google.com/p/phantomjs/issues/detail?id=785
2012-09-21 00:05:18 -07:00
Ariya Hidayat 18ca114111 Windows: Use ARGB32 premultiplied to have better font rendering.
Thanks to Vitaliy Slobodin for the analysis.

http://code.google.com/p/phantomjs/issues/detail?id=785
2012-09-20 23:52:05 -07:00
Ivan De Marino 26583740c8 Made the "Callbacks injection" recursive.
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).
2012-09-18 22:46:14 +01:00
Ivan De Marino b1185cd22a Redesign the Cookies API (part 2)
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.
2012-09-18 08:42:13 +01:00
Harry Waye 4f7df7073a Maintain m_currentFrame as opposed to using QWebPage's currentFrame().
Currently focused frame made available with page.focusedFrameName and page.switchToFocusedFrame.

http://code.google.com/p/phantomjs/issues/detail?id=683
2012-09-17 21:59:05 -07:00
Ivan De Marino bd21373732 Redesign the Cookies API
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.
2012-09-07 00:03:03 -07:00
Ivan De Marino 6217d6b960 Adding "url" and some frame-related Q_PROPERTIES
* 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)
2012-09-05 21:14:59 -07:00
Ivan De Marino 5b25c6feea Adding support for more Mouse Events.
Support for Mouse Events: Left-click, Right-Click, Middle-Click and Double-Click.
Addresses [Issue 712](http://code.google.com/p/phantomjs/issues/detail?id=712)
2012-09-04 09:49:25 -07:00