Commit Graph

225 Commits (master)

Author SHA1 Message Date
Juliusz Gonera 2cfffa029a Merge phantomjs-nodify's require() and fix tests
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
2012-07-12 23:14:12 -07:00
Juliusz Gonera 945a4c0f8c Add require() tests and comment buggy test in fs-spec-03.js
http://code.google.com/p/phantomjs/issues/detail?id=47
2012-07-12 23:14:12 -07:00
Ivan De Marino b443b7add8 Changing the "working directory" to "/test" before running tests.
This fixes some issues with our tests, where we were erroneously failing.
2012-06-17 19:37:24 -07:00
Ariya Hidayat ead8066c57 Merge remote-tracking branch 'neraliu/cookiesapi'
Conflicts:
	src/modules/webpage.js
	src/webpage.h
2012-06-17 07:56:25 -07:00
Jon Leighton c9cf14f221 Don't pass an error object to the onError callback.
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
2012-06-16 14:24:37 -07:00
Jon Leighton d2290a60a9 Localize variables.
This is to avoid adding a onError handler to the page that exists in the
outer scope.

https://code.google.com/p/phantomjs/issues/detail?id=166
2012-06-16 14:24:37 -07:00
Nera Liu 94a1fbecdb Fix an indentation problem in the file test/webpage-spec.js. 2012-06-16 08:13:05 -07:00
Nera Liu 77052e60a8 Simplify the cookies api as property setter and getter for issue 354.
Update the test case for the cookies api.

http://code.google.com/p/phantomjs/issues/detail?id=354
2012-06-16 07:58:11 -07:00
Ivan De Marino f40b7ab730 Adding property "os" to the "system" module.
Contains the properties:
- name
- architecture
- version

http://code.google.com/p/phantomjs/issues/detail?id=585
2012-06-15 00:12:08 -07:00
Ivan De Marino f386f7d484 Adding the ability to switch between frames.
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
2012-06-15 00:07:53 -07:00
Ivan De Marino caf13651b7 Adding "window.phantomCallback()" within the page context.
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).
2012-06-14 23:29:13 -07:00
Nera Liu 7919387c71 Add WebPage.setCookies and WebPage.cookies apis for the issue 354.
Add sanity check for the cookies api in test/webpage-spec.js.

http://code.google.com/p/phantomjs/issues/detail?id=354
2012-06-14 00:43:20 -07:00
Ariya Hidayat cec3fdd8a0 Merge pull request #264 from jonleighton/multi_file_input
Handle multiple file inputs.
2012-06-12 08:42:23 -07:00
Jon Leighton bbbd6a22d7 Handle multiple file inputs.
https://code.google.com/p/phantomjs/issues/detail?id=256
2012-06-10 23:24:45 +01:00
Jon Leighton f7ecf6ccb9 Error.stack returns a string to match V8/Node.js
https://code.google.com/p/phantomjs/issues/detail?id=166
2012-06-10 21:28:46 +01:00
Milian Wolff 5c2e330a15 Make QWebPage::zoomFactor accessible to PhantomJS scripts.
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)
2012-06-08 11:05:54 +02:00
Ariya Hidayat 1989184fa1 Merge pull request #248 from neraliu/localstorage
Add --local-storage-quota and --local-storage-path options for issue 300...
2012-06-01 21:31:19 -07:00
Jon Leighton ad91d651a8 Pass an actual exception object to the error handler.
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
2012-05-30 20:20:30 +01:00
Nera Liu c85a26a229 Add --local-storage-quota and --local-storage-path options for issue 300.
Add sanity check for the configuration of --local-storage-quota and --local-storage-path.

issue 300 - http://code.google.com/p/phantomjs/issues/detail?id=300
2012-05-19 21:04:01 +08:00
Jon Leighton 54c41ae77a Support retrieving the stack of an error
https://code.google.com/p/phantomjs/issues/detail?id=166
2012-05-07 23:29:36 +01:00
Jon Leighton 479b827b66 Enable rich source info for errors.
https://code.google.com/p/phantomjs/issues/detail?id=510
2012-05-07 17:34:07 +01:00
Ariya Hidayat 81794f9096 Squashed commit of the following:
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
2012-04-10 23:52:56 -07:00
david 8c645ecd79 Added tests for customHeaders.
http://code.google.com/p/phantomjs/issues/detail?id=77.
2012-03-27 22:23:46 -07:00
Ivan De Marino ac771a22b9 Option to pass "headers" when using "open()" on "webpage" module.
Solves [Issue 452](http://code.google.com/p/phantomjs/issues/detail?id=452)
2012-03-23 11:48:16 +00:00
Ivan De Marino 03e47a1712 Fixing defect in the "Filesystem Spec 03".
Too strong assumption regarding the Current Working Directory.
2012-03-23 11:45:13 +00:00
Ivan De Marino 59c4e32c60 Updating "webserver" test spec.
I also made a minor fix in the logic of "system" test spec:
too strong assumption on the CurrentWorkingDirectory
when launching the test.
2012-03-23 10:56:51 +00:00
Ariya Hidayat fcc0ff7bae Open master branch for 1.6 development. 2012-03-22 21:24:27 -07:00
Jon Leighton adcb14dd0e Basic tests for the onError handler
http://code.google.com/p/phantomjs/issues/detail?id=166
2012-03-18 21:44:31 -07:00
Ariya Hidayat c6091b48c1 Implement fs.readLink to read symlink target.
http://code.google.com/p/phantomjs/issues/detail?id=329
2012-03-16 20:44:56 -07:00
Ariya Hidayat 59a777e348 Add a simple check to ensure that there is no loaded plugin.
http://code.google.com/p/phantomjs/issues/detail?id=418
2012-03-15 21:47:01 -07:00
Ariya Hidayat 756d0d3166 Implement system.env to get system environment variables.
Based on the initial work from execjosh:
https://github.com/ariya/phantomjs/pull/192

See also http://wiki.commonjs.org/wiki/System#System_Interface.

http://code.google.com/p/phantomjs/issues/detail?id=271
2012-03-15 01:22:17 -07:00
Ariya Hidayat 545a3f76b4 Implement system.args to get command-line arguments.
This also means that phantom.args is deprecated.

Based on the initial work from execjosh:
https://github.com/ariya/phantomjs/pull/192

See also http://wiki.commonjs.org/wiki/System#System_Interface.

http://code.google.com/p/phantomjs/issues/detail?id=270
http://code.google.com/p/phantomjs/issues/detail?id=276
2012-03-15 01:11:26 -07:00
Ariya Hidayat 119e1ba516 Implement the plumbing for CommonJS System module support.
See http://wiki.commonjs.org/wiki/System.

Based on the initial work from execjosh:
https://github.com/ariya/phantomjs/pull/192

http://code.google.com/p/phantomjs/issues/detail?id=270
2012-03-14 23:23:43 -07:00
Ariya Hidayat ac699a4d90 WebKit: Support multiple console.log arguments.
http://code.google.com/p/phantomjs/issues/detail?id=36
2012-03-08 22:10:42 -08:00
Milian Wolff 61eb86782b Filesystem module should allow reading and writing binary files.
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.
2012-02-29 07:55:00 -08:00
Baffo32 9d1c2e90ac Update phantom spec version test 2012-02-15 18:47:56 -08:00
Milian Wolff 1411ebdff6 make POST/PUT data accessible from phantomjs server scripts
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)
2012-02-15 18:41:51 -08:00
execjosh c22dfdc576 Implement charset param for fs.{open,read,write}
http://code.google.com/p/phantomjs/issues/detail?id=367
2012-02-03 00:44:14 +09:00
Jon Leighton e6b6f2ec2e Add a test for file upload support 2011-12-30 11:58:23 +00:00
Ariya Hidayat b465acf5d3 Don't create window.WebServer.
It was done for WebPage for backward compatibility and it would be
removed in the future, so don't do it for WebServer.

http://code.google.com/p/phantomjs/issues/detail?id=115
2011-12-22 21:55:00 -08:00
Ariya Hidayat 5528c046db Some API changes in the WebServer module.
Trying to match http://nodejs.org/docs/latest/api/http.html.

For the server response:

  * Change writeBody to write
  * Change writeHeaders to writeHead

For the request object, 'headers' is now an object containing all
key-value pairs of the actual HTTP headers.

'queryString' is folded into 'url' key.

Non-standard keys in the request: isSSL, remotePort, remoteIP,
remoteUser, are disabled in the mean-time (will be revisited after 1.4
release).

Implementation-wise, the request object is now a simple key-value pair
using QVariant, as opposed to the heavy QObject instance.

http://code.google.com/p/phantomjs/issues/detail?id=115
2011-12-19 18:38:21 -08:00
Viorel Dram 2ffcd1375f Passed test results failed count as exit code 2011-11-29 11:39:09 +02:00
Milian Wolff 46a5ccf1e5 extend webserver test 2011-11-15 13:45:17 +01:00
Milian Wolff bd2052631f basic unit testing for WebServer.listen 2011-11-15 13:45:11 +01:00
Milian Wolff 5eaf705955 basic unit test for webserver 2011-11-15 13:45:11 +01:00
Ariya Hidayat f1b03e84d9 Bump the unstable version to 1.4. 2011-10-29 11:18:50 -05:00
Ariya Hidayat fe20c0987d Avoid deleting a QWebPage inside its own signal emission.
If Phantom.exit() is called inside the handler for loadFinished(), we
end up in a situation that QWebPage is deleting itself during a signal
emission. This used to be OK in QtWebKit 2.0 (Qt 4.7) but is not OK for
QtWebKit 2.2 (upcoming Qt 4.8).

http://code.google.com/p/phantomjs/issues/detail?id=251

Patch by Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>.
2011-10-05 17:26:46 -07:00
Alessandro Portale bf9a68ed43 Autotest for Issue 249 (text codec support in static builds)
Tests Japanese (Shift_JIS, EUC-JP, ISO-2022-JP) and Chinese
(Big5, GBK). Easy to extend with more data.

It will currently fail with static builds of PhantomJS, but
pass with dynamic ones.
2011-10-05 04:34:35 +02:00
execjosh caab0951bf Add unit tests for initializing WebPage via constructor 2011-09-18 22:49:58 +09:00
execjosh 2b5f24c482 Make webpage unit tests more readable 2011-09-18 20:48:55 +09:00
Ariya Hidayat 4544b129c9 Improve the API for mouse events.
It now looks like in this example:

  page.sendEvent('mousedown', 42, 217);

Other available events are 'mouseup', 'mousemove', and 'click'. They modelled
after the DOM events.

Unit tests are included.

http://code.google.com/p/phantomjs/issues/detail?id=234
2011-09-16 07:15:21 -07:00
Ariya Hidayat b6102d7f6e Refactoring on the module implementation.
This is mostly based on Ivan's work, see
https://github.com/ariya/phantomjs/pull/153

http://code.google.com/p/phantomjs/issues/detail?id=47
2011-09-11 01:04:53 -07:00
Ariya Hidayat 64bc80d080 Add simple tests for require().
http://code.google.com/p/phantomjs/issues/detail?id=47
2011-09-08 17:55:31 -07:00
Ariya Hidayat 6a79ea7e6d Implement require('fs').
This is mostly based on Ivan's work, see
https://github.com/ariya/phantomjs/pull/153

http://code.google.com/p/phantomjs/issues/detail?id=47
2011-09-08 10:00:07 -07:00
Ivan De Marino 88991207c2 Added "copyTree(source, destination)" to the set of File API.
* This is the last API
* I added tests accordingly
* Test could be improved with a proper recursive comparison
* Or, if we introduce "phantom.exec", we could just run a "diff -rq" :)
2011-09-04 23:42:54 +01:00
Ivan De Marino 96641ea8a1 Added "touch(path)" to the FS API
* Implemented in the JS Shim
* Added test accordingly
2011-09-01 00:34:55 +01:00
Ivan De Marino 619d4b470f Added "fs.move(source, dest)" to the set of FS API.
* Added tests accordingly
* The implementation is a pure JS shim
2011-09-01 00:14:17 +01:00
Ivan De Marino f381f61c64 Added "copy(source, dest)" to the set of FS API.
* Also, added test case accordingly.
2011-09-01 00:01:40 +01:00
Ivan De Marino cffd688efd Improving compliancy of "remove*" Filesystem API. 2011-08-31 23:32:56 +01:00
Ivan De Marino d8d88a3894 Added "Copyright..." line to files on which I worked on.
I tried to also add/remove based on the git history.
2011-08-31 16:29:40 +01:00
Ariya Hidayat 783229214c Unit test: remove the test for non-public method. 2011-08-28 15:12:12 -07:00
execjosh cad33014b4 Alphabetize WebPage function tests 2011-08-28 20:24:46 +09:00
execjosh ec92ac735c Add basic tests for WebPage 2011-08-28 20:13:38 +09:00
IceArmy e4dfb406f0 Alter 'should have the default outputEncoding of UTF-8' test to compare against lowercase, for PyPhantomJS compatibility 2011-08-24 16:48:42 -07:00
execjosh 4272070d60 Update spec for outputEncoding (should equal "UTF-8") 2011-08-23 00:54:10 +09:00
Ariya Hidayat 3ec96ea6b0 Unit test: check for phantom's functions. 2011-08-20 23:47:39 -07:00
Ariya Hidayat ba41180fa1 Unit test: check for phantom.outputEncoding. 2011-08-20 22:58:11 -07:00
Ariya Hidayat 7a0bd2a569 Unit test: check for phantom.version. 2011-08-20 22:53:22 -07:00
Ivan De Marino 512de8c9b1 Fixed typo. 2011-08-08 23:46:56 +01:00
Ivan De Marino 2c4ac33942 Filesystem API: completed the "Tests" API group from CommonJS/Filesystem definition.
* Tests provided in "fs-spec-04.js"
* I also slightly enriched the "jasmine-console.js" reporter to get a bit more info
2011-08-08 23:42:11 +01:00
Ivan De Marino a47ee85d09 Filesystem API: completed the "Paths" API group from CommonJS/Filesystem definition.
* Tests provided in "fs-spec-03.js"
2011-08-02 00:47:43 +01:00
Ariya Hidayat 9469a0d343 Add unit tests for properties of phantom object. 2011-07-25 00:25:09 -07:00
Ivan De Marino 512ff9658e Filesystem API: added the "Attributes" API group from CommonJS/Filesystem definition
* Tests for this new API are also provided
* The 'fs.size()' method is implemented with a shim in 'bootstrap.js' to cover the exception throwing behaviour
2011-07-22 00:29:25 +01:00
Ivan De Marino 744663e9a1 Removing "jasmine.css" because we are not using the Jasmine HTML Trivial Reporter anyway. 2011-07-20 22:45:01 +01:00
Ivan De Marino e5c2240fcb Added Jasmine 1.1.0, a Console Reporter and the first Test Specs for the new Filesystem API. 2011-07-20 20:31:52 +01:00