Commit Graph

225 Commits (master)

Author SHA1 Message Date
Zack Weinberg 1e7829db97 Fix crash on exit if pages have been closed (#12482)
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.
2014-08-20 14:38:45 -04:00
Ariya Hidayat b5626bff97 Add a simple test for exit behavior.
https://github.com/ariya/phantomjs/issues/12431
https://github.com/ariya/phantomjs/issues/12439
2014-08-20 05:51:19 -07:00
Zack Weinberg 26934f32a9 Add a -v/--verbose option to run-tests.{sh,js}.
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).
2014-08-19 20:24:28 -07:00
Zack Weinberg b524d53d36 Add ability to run tests selectively.
* 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).
2014-08-19 20:24:28 -07:00
Zack Weinberg 6fb347d296 Fix jasmine.ConsoleReporter.specFailureDetails.
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).
2014-08-19 20:24:27 -07:00
Zack Weinberg e6b67bddc5 Import Jasmine 1.3.1.
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).
2014-08-19 20:24:27 -07:00
Zack Weinberg 7102e87bf4 Eliminate console spam during normal test execution.
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).
2014-08-19 20:24:27 -07:00
Zack Weinberg 406f736e14 Do not use github.com in tests.
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).
2014-08-19 20:24:27 -07:00
Ariya Hidayat fbe8eefc29 Launcher for ECMA-262 test suite (test262.ecmascript.org).
https://github.com/ariya/phantomjs/issues/12439
2014-08-16 20:46:28 -07:00
Ariya Hidayat f532b73cb2 More tests for the arguments object.
https://github.com/ariya/phantomjs/issues/11845
https://github.com/ariya/phantomjs/issues/11558
https://github.com/ariya/phantomjs/issues/11746
https://github.com/ariya/phantomjs/issues/10315

https://github.com/ariya/phantomjs/issues/12439
2014-08-15 22:42:23 -07:00
Ariya Hidayat 3136898976 Some tests for JavaScript's Function.
https://github.com/ariya/phantomjs/issues/12439
https://github.com/ariya/phantomjs/issues/10522
2014-08-09 11:53:19 -07:00
Ariya Hidayat bbdaa9e884 A simple assertion for the fortcoming revamped test system.
https://github.com/ariya/phantomjs/issues/12439
2014-08-09 10:59:22 -07:00
Milian Wolff 0c55c0a9e0 Remove CoffeeScript references from unit tests
https://github.com/ariya/phantomjs/issues/12429
2014-08-06 15:08:24 +02:00
Ariya Hidayat e2682edf48 Disable some failing and/or crashing unit tests.
Also, reorder the tests since webpage-spec.js seems to be sensitive to
any previously executed tests.

https://github.com/ariya/phantomjs/issues/10448
2014-07-28 03:33:13 -07:00
Ariya Hidayat 1bf54d8776 Correct the unit tests of PhantomJS version.
https://github.com/ariya/phantomjs/issues/10448
2014-07-27 17:10:30 -07:00
Vitaly Slobodin d10b8dc583 Merge pull request #12287 from zackw/expose-http-status-to-onresourceerror
Expose HTTP status and reason to onResourceError (#12252).
2014-07-15 10:12:55 +04:00
Zack Weinberg d65601fe90 Expose HTTP status and reason to onResourceError (#12252). 2014-06-03 20:52:44 -04:00
Sven Eckelmann 13ad8a134e Use correctly rendered pdf for webpage-spec-renders tests
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")
2014-05-31 08:23:32 -07:00
Ivan De Marino 8f685818aa Fixed tests that dealt with manipulating request URLs.
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.
2014-03-09 01:02:49 +00:00
Ivan De Marino 77b5de1362 Run PhantomJS's tests as part of TravisCI
Related to #11952.
2014-03-09 01:02:49 +00:00
Ivan De Marino ba5998f74e Making GhostDriver test "quiet-er" (and parallel)
Also, trying to get the exit status of those tests reported, in case they fail.

Related to #11952.
2014-03-09 01:02:21 +00:00
Ivan De Marino 1797c146f1 Adding "test/ghostdriver-test" to run in Travis CI
Related to issue #11880
2014-03-08 23:37:47 +00: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
Vasyl Vavrychuk 3ae9d38d40 fixed test suite 'WebPage render image'
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
2014-01-09 17:47:11 -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 7659f2551c Adding tests for #11867
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.
2014-01-01 13:47:33 -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
hexid b1e181176e Add require.paths support
Issues: https://github.com/n1k0/casperjs/issues/462 https://github.com/ariya/phantomjs/issues/11339
2013-09-01 07:53:08 -07:00
Ivan De Marino c466d8aeef WebServer Headers for Request are treated case-insensitive
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.
2013-06-21 23:51:05 +01:00
Ariya Hidayat b4c4429e86 Unit tests: reduce the flakiness of loading progress tests.
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
2013-06-08 02:18:31 -07:00
Ariya Hidayat 01587211cb Unit test: secure connection check becomes async.
Issue #10882: https://github.com/ariya/phantomjs/issues/10882
2013-06-08 02:05:07 -07:00
Ariya Hidayat 44c3d6080d Unit tests: robustify the tests of PDF, GIF, PNG, JPEG rendering.
Issue #10973 https://github.com/ariya/phantomjs/issues/10973
2013-06-08 02:04:59 -07:00
Ariya Hidayat 9f1f56bc3b Unit tests: terminate any web servers after finishing the tests.
Issue #11163: https://github.com/ariya/phantomjs/issues/11163
Issue #11243: https://github.com/ariya/phantomjs/issues/11243
2013-06-08 02:04:48 -07:00
Ariya Hidayat f57fa468ab Unit test: tweak secure connection check.
The main wikipedia page can be slow to load and thus triggers the timeout.
Let's use the fast Google site so that we don't get flaky outcome.

Issue #10882: https://github.com/ariya/phantomjs/issues/10882
2013-06-08 02:04:39 -07:00
Vitaliy Slobodin 5528d75c9d Network request header manipulation
Issue: https://github.com/ariya/phantomjs/issues/11299 (#11299)

User should be able  to manipulate HTTP headers per each network request, not only using global setting page.customHeaders.
2013-05-13 22:48:58 -07:00
Andrew Galloni 3ae632e704 ChangeUrl to accept an encoded string
Issue #11243: https://github.com/ariya/phantomjs/issues/11243.
2013-04-29 07:07:53 -07:00
execjosh b159144a48 Teach `File` how to change its encoding
If a `File` is in "text" mode, then it has an encoding.  This
encoding defaults to UTF-8; however, it can be set only at time of
construction (by using `fs.open`).

This modification allows the user to change the encoding on-the-fly
for "text" mode `File` instances.

See #11234 https://github.com/ariya/phantomjs/pull/11234
Spin off from #11168 https://github.com/ariya/phantomjs/pull/11168
2013-04-29 07:00:19 -07:00
execjosh d925a510d9 Improve WebPage CJK support tests.
This is for issue #10249: https://github.com/ariya/phantomjs/issues/10249.
2013-04-22 22:35:08 -07:00
Ariya Hidayat 0bc2eb418e Temporarily call this branch as version 1.10.
Issue #10448 https://github.com/ariya/phantomjs/issues/10448#issuecomment-15689386
2013-03-31 03:06:50 -07:00
Pavel fcdd274f2e Show postData in onResourceRequested callback.
Issue #10158 https://github.com/ariya/phantomjs/issues/10158
2013-03-31 02:54:37 -07:00
Vitaliy Slobodin 47dc82681d Fire `onResourceReceived` callback when the resource error occured.
Issue #11163: https://github.com/ariya/phantomjs/issues/11163
2013-03-31 02:39:53 -07:00
Vitaliy Slobodin 9ca45ed62e Fix loading modules from an absolute path on Windows.
Don't check the module path using Linux-style path checking.

Issue #11165: https://github.com/ariya/phantomjs/issues/11165
2013-03-25 19:01:32 -07:00
Jonathan Wilkins 9f9053ec44 Add support for specifying non-default CA certificate bundles.
This is done via SSL_CERT_DIR and --ssl-certstore.

Fixes issue #10916.

https://github.com/ariya/phantomjs/issues/10916
2013-03-20 08:27:54 -07: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 0147fcbc07 Support for specifying request body encoding for WebPage::openUrl
Added a simple test in test/webpage-spec.js

Test data from http://code.google.com/p/phantomjs/issues/detail?id=1043
2013-03-18 21:43:22 -07:00
Ivan De Marino 005db037cf Tests for the new "page.loading" property.
This commit provides the unit tests for the new property, as asked by
Ariya in #11091.
2013-03-18 09:19:41 +00:00
Vitaliy Slobodin 212e4b7cd9 Reworked api for canceling network requests. Added experimental API for changing the url of the network request.
Issue:
http://code.google.com/p/phantomjs/issues/detail?id=539

Stub
2013-02-24 09:00:07 -08:00
Juliusz Gonera 2d42b52c67 Make require.stub() optionally accept a factory function
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
2013-02-05 00:04:17 -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 7e7325c0f5 Fixing up indentation for our Jasmine test specs.
Just getting rid of an itch of mine.
2013-01-17 23:52:47 +00:00
Ivan De Marino 12bb24f418 FIX: 'resource request errors' close the server.
The test "should handle resource request errors"
was not closing the server at the end of the test,
interfering with the successive tests.
2013-01-17 23:47:41 +00: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
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
Ariya Hidayat 2a2b6e455c Mac OS X: Add a manual test for the crash with TrueType fonts.
http://code.google.com/p/phantomjs/issues/detail?id=690
2012-12-30 21:17:39 -08:00
execjosh 836719f72e Implement CommonJS IO/A read([n Number])
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_Methods

http://code.google.com/p/phantomjs/issues/detail?id=938
2012-12-25 20:46:14 -08:00
execjosh f6c87221a7 Implement system.std{in,out,err}
See [issue 333][1] and pull request #192.

**Caveat**

`File::read` currently takes no parameters and is equivalent to a
"`readAll`".  This will be changed later to match [IO/A Spec's
`Stream#read`][2]; but, should still be noted.

[1]: http://code.google.com/p/phantomjs/issues/detail?id=333
[2]: http://wiki.commonjs.org/wiki/IO/A#Instance_Methods
2012-12-25 03:41:34 -08:00
Ariya Hidayat fac15407e8 Call the development branch as version 1.9. 2012-12-23 08:57:37 -08:00
execjosh 3458d4d507 Use fs.join(...) instead of fs.separator
http://code.google.com/p/phantomjs/issues/detail?id=361
2012-12-22 23:06:20 -08:00
execjosh 03500e6b55 Implement fs.{split(path),join(...),{to,from}NativeSeparators}
For fs.{split,join} specs, see: http://wiki.commonjs.org/wiki/Filesystem/A#Paths_as_Text

http://code.google.com/p/phantomjs/issues/detail?id=361
2012-12-22 23:05:46 -08:00
Sebastian Krzyszkowiak f70a6ab4ee Add test case for WebServerResponse::setEncoding
http://code.google.com/p/phantomjs/issues/detail?id=505
2012-12-17 19:27:19 -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
James M. Greene 31dd714a22 Added getters for the WebPage#onError and phantom.onError properties
Fixes http://code.google.com/p/phantomjs/issues/detail?id=910
2012-12-11 21:57:25 -08: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
James M. Greene 4c285c419d Removed an invalid spec file and an invalid spec include.
Fixes http://code.google.com/p/phantomjs/issues/detail?id=906
2012-12-06 08:27:55 -08:00
James M. Greene c9f9b5a14b Added getters for all of the WebPage signal//callback handlers.
Fixes http://code.google.com/p/phantomjs/issues/detail?id=899
2012-12-05 23:43:50 -06:00
Vitaliy Slobodin 63dd36205f Don't perform on-demand loading of root certificates on Linux
Description:
Qt is performing loading on-demand of root certificates on Linux, which causing SSL errors.

Issue:
http://code.google.com/p/phantomjs/issues/detail?id=882
2012-11-24 16:41:03 +04:00
Vitaliy Slobodin 40a14b72b1 Restore dirty line logic in RenderInline::destroy.
WebKit upstream fix: http://trac.webkit.org/changeset/86060
WebKit upsteam bug: https://bugs.webkit.org/show_bug.cgi?id=60448

Related issues:
http://code.google.com/p/phantomjs/issues/detail?id=704
http://code.google.com/p/phantomjs/issues/detail?id=703
http://code.google.com/p/phantomjs/issues/detail?id=675
http://code.google.com/p/phantomjs/issues/detail?id=689
http://code.google.com/p/phantomjs/issues/detail?id=532
http://code.google.com/p/phantomjs/issues/detail?id=851
2012-11-14 11:28:58 -08:00
Ariya Hidayat 559afcd4e8 Bump the version.
http://code.google.com/p/phantomjs/issues/detail?id=863
2012-11-10 01:45:54 -08:00
Ariya Hidayat 7b84e43a10 Merge remote-tracking branch 'JamesMGreene/ExposeProcessId' 2012-11-08 06:24:32 -08:00
James M. Greene 280305797e Exposing the Process ID (PID) via the System module.
`require('system').pid` should return your PhantomJS instance's Process ID.

http://code.google.com/p/phantomjs/issues/detail?id=769
2012-11-06 11:49:55 -06: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
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
Jim Evans 380c56e672 Adding test for sendEvent with modifier key
http://code.google.com/p/phantomjs/issues/detail?id=835
2012-10-28 20:58:51 -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
Vitallium 35c1971595 Fix parsing dates in ISO8601 format.
Issues:
http://code.google.com/p/phantomjs/issues/detail?id=187
http://code.google.com/p/phantomjs/issues/detail?id=267
2012-10-24 00:00:58 -07:00
Ariya Hidayat cab2635e66 Make the key enums as part of WebPage instance.
This way, we don't add anything into phantom object.

http://code.google.com/p/phantomjs/issues/detail?id=492
2012-09-20 23:44:06 -07: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 733d21042b Adding property "page.ownsPages".
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)
2012-09-04 09:49:24 -07:00
Ivan De Marino 27dc699919 Added "page.close()" and "page.onClosing = function(page){}" callback.
* 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.
2012-09-04 09:49:24 -07:00
Ariya Hidayat 3b161b914a Add 'isSSLSupported' to the system module.
http://code.google.com/p/phantomjs/issues/detail?id=484
2012-09-03 06:50:34 -07:00
neraliu 4e1735c899 Implement in-memory cookies storage for CookieJar.
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
2012-09-03 04:30:49 -07:00
Ivan De Marino 8d2384fd29 Tests for the "new" Frame-Switching API
http://code.google.com/p/phantomjs/issues/detail?id=654
2012-07-13 23:35:10 -07:00
Milian Wolff 1b2a84df9c Make Qt::Key accessible via phantom.keys.
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
2012-07-13 10:32:03 -07:00
Milian Wolff bf6fd70c88 Properly handle strings, chars and umlauts in key[press,down,up] events.
http://code.google.com/p/phantomjs/issues/detail?id=492
2012-07-13 10:32:03 -07:00
Nicolas Perriault 11044a8fbd added tests for new keyboard events
http://code.google.com/p/phantomjs/issues/detail?id=492
2012-07-13 10:32:03 -07:00
Ivan De Marino ea83351da3 Tests for the new "window opening" API
http://code.google.com/p/phantomjs/issues/detail?id=151
2012-07-13 09:56:10 -07:00
Ivan De Marino 008019ae10 Fixed an annoying FileSytem test that was wrongly designed (by me).
http://code.google.com/p/phantomjs/issues/detail?id=611
2012-07-13 09:52:35 -07:00
Ariya Hidayat 6ce27bbefa Version bump needs a unit test adjustment. 2012-07-13 09:38:57 -07:00
Juliusz Gonera 5015dbec2a Remove old module tests
New module tests contain all the tests from the old ones.

http://code.google.com/p/phantomjs/issues/detail?id=47
2012-07-12 23:14:12 -07:00
Juliusz Gonera 893108ad11 Fix stack trace when module is not found
The stack trace was missing when an error was thrown because of a
missing module. This should not be the case anymore.

http://code.google.com/p/phantomjs/issues/detail?id=47
2012-07-12 23:14:12 -07:00
Juliusz Gonera b22e995337 Fix indentation to 4 spaces in new require() tests
http://code.google.com/p/phantomjs/issues/detail?id=47
2012-07-12 23:14:12 -07:00
Juliusz Gonera 70925a873b Add test for .stack in errors thrown in modules
We want to be sure that the stack contains module file path.

http://code.google.com/p/phantomjs/issues/detail?id=47
2012-07-12 23:14:12 -07:00