Commit Graph

225 Commits (master)

Author SHA1 Message Date
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
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