Commit Graph

485 Commits (e2295f805c0deeabcec4e3b28ba555bc9f3d29fa)

Author SHA1 Message Date
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 d844d5404f Fix wrong viewport size due to commit 6e39625e.
http://code.google.com/p/phantomjs/issues/detail?id=217
2011-09-08 23:40:05 -07:00
Ariya Hidayat f7162f7302 Fix coding style (brace placement and indentation with spaces). 2011-09-08 22:35:07 -07:00
Ariya Hidayat e674283821 Fix the proxy option example (http is not needed).
This was mentioned in
http://code.google.com/p/phantomjs/issues/detail?id=19
2011-09-08 21:37:40 -07:00
Ariya Hidayat a62299214d Fix braces placement to follow the coding style. 2011-09-08 17:49:05 -07:00
Ariya Hidayat 4fb37aa0cc Create FileSystem instance only when needed. 2011-09-08 17:37:01 -07:00
Ariya Hidayat 2b83a52251 Implement require('webpage').
This is mostly based on Ivan's work, see
https://github.com/ariya/phantomjs/pull/153

window.WebPage still works, it is not recommended and will be
deprecated.

http://code.google.com/p/phantomjs/issues/detail?id=47
2011-09-08 17:32:31 -07:00
Ariya Hidayat b412aba06d bootstrap.js: Reindent properly. 2011-09-08 13:25:44 -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
Ariya Hidayat 080eb26a11 Add the proper *.js files to OTHER_FILES. 2011-09-08 07:15:13 -07:00
Ariya Hidayat d94b0c4fbb Fix missing rename from commit 059e7258. 2011-09-07 20:50:02 -07:00
Ariya Hidayat 059e72588c Rename option/config to localToRemoteUrlAccess(Enabled). 2011-09-07 09:27:20 -07:00
Ariya Hidayat d35f81bbda Decouple static helper methods from a class. 2011-09-06 17:00:59 -07:00
Ariya Hidayat bc348c5a35 Give function parameter a proper name. 2011-09-06 17:00:59 -07:00
Ariya Hidayat 962f99fa77 Fix typo in the method name. 2011-09-06 17:00:55 -07:00
Ariya Hidayat e14c07f288 Fix member variable initialization order. 2011-09-06 16:38:51 -07:00
Ariya Hidayat 07c6eb81f5 Sort include files alphabetically. 2011-09-06 16:37:54 -07:00
Ariya Hidayat 3dc9fe53a0 Disk cache object is private for network access. 2011-09-06 16:36:23 -07:00
Ariya Hidayat c0e179d59e Do not manage object lifetime, rely on Qt for that. 2011-09-06 16:35:19 -07:00
Ariya Hidayat cebe64ec31 Config to limit the disk cache size.
Based on the previous patch at https://github.com/ariya/phantomjs/pull/144.

http://code.google.com/p/phantomjs/issues/detail?id=220
2011-09-06 16:33:11 -07:00
Ariya Hidayat 7aa5ec5347 Do not use empty string literal for the default parameter. 2011-09-06 16:01:19 -07:00
Alex Whitman 774070809f Fixes a couple of compiler warnings
* Unused parameter in networkaccessmanager.cpp
* No newline at the end of networkreplyproxy.cpp
2011-09-05 15:23:52 +01:00
Ariya Hidayat 7cd76309e6 Merge pull request #151 from detro/dev-commonjs_fileio
Last API
2011-09-04 21:19:15 -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 8c15c80b14 Renamed "fs-shim.js" to "fileystem-shim.js" to ensure name consistency. 2011-09-04 21:26:11 +01:00
Ariya Hidayat 5889ef75e9 Merge pull request #149 from Roejames12/master
Tons of updates :)
2011-09-04 00:24:29 -07:00
IceArmy 5f69a34a4f Add execjosh to webpage-shim copyrights 2011-09-03 23:52:36 -07:00
Paul Dixon 461d533348 Removing unnecessary Terminal include 2011-09-02 17:47:33 +02:00
mintbridge af71868c23 add basic http auth support to networkaccessmanager, and add the ability to pass the auth credentials in from the command line 2011-09-02 16:35:58 +01:00
Ivan De Marino f83b9a5ba7 Added "touch(path)" to the FS API
* Implemented in the JS Shim
* Added test accordingly
2011-09-01 18:06:30 -07:00
Ivan De Marino 750e1e98c4 Added "fs.move(source, dest)" to the set of FS API.
* Added tests accordingly
* The implementation is a pure JS shim
2011-09-01 18:06:30 -07:00
Ivan De Marino 31c2decbd3 Added "copy(source, dest)" to the set of FS API.
* Also, added test case accordingly.
2011-09-01 18:06:30 -07:00
Ivan De Marino 12171fc9c6 Improving compliancy of "remove*" Filesystem API. 2011-09-01 18:06:30 -07:00
Ivan De Marino 715f1a7fc3 Refactored the JS Shims to be isolated in their own file.
Also, refactored some "too cautious" code to load the shim.

PS I don't grasp 100% the point of "Terminal". Wouldn't qDebug() be enough? What am I missing?
2011-09-01 18:06:30 -07: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 3401dd9f78 Refactored the JS Shims to be isolated in their own file.
Also, refactored some "too cautious" code to load the shim.

PS I don't grasp 100% the point of "Terminal". Wouldn't qDebug() be enough? What am I missing?
2011-08-31 23:19:17 +01:00
Ariya Hidayat 4dca2b3d60 Fixed issue 212: build problem due to config.h.
Change <config.h> in the GIF code to "config.h" so that it is not
confused with PhantomJS' own config file.
2011-08-31 09:40:43 -07:00
Ariya Hidayat 868e751bea Merge pull request #143 from execjosh/issue-206-web-page-init
Allow for passing options to WebPage constructor
2011-08-31 09:28:58 -07:00
Ariya Hidayat 8ebd446e58 Merge pull request #145 from detro/master
Comments stuff
2011-08-31 09:27:52 -07: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
execjosh d792cd8d05 Remove ini file related stuff from Config 2011-08-30 00:50:59 +09:00
execjosh 3c4699b609 Add "--config" command-line option 2011-08-30 00:45:39 +09:00
execjosh 26f7185bf6 Implement JSON config loader 2011-08-30 00:43:41 +09:00
execjosh 94c5e270cf Remove superfluous inclusion of QApplication 2011-08-29 23:24:45 +09:00
execjosh 8f89ddc9a3 Make Config extend QObject 2011-08-29 23:23:01 +09:00
execjosh da97b9abbf Fixup copyInto function
* Drop any undefined values
* Copy non-objects, too
2011-08-28 23:12:52 +09:00
execjosh 74db4807d5 Actually add parameter to WebPage constructor 2011-08-28 22:29:31 +09:00
execjosh 3c790d80a8 Migrate command-line argument processing logic to Config 2011-08-28 22:13:57 +09:00
execjosh 9c94a8ef24 Rename ini file code to "Config::loadIniFile" 2011-08-28 21:12:40 +09:00
execjosh ad53b9bb3e Rename "PhantomConfig" to "Config" 2011-08-28 21:11:20 +09:00
execjosh 102b421617 Allow for passing options to WebPage constructor 2011-08-28 19:11:24 +09:00
execjosh 1461ac012d Implement config file (.phantomjsrc) 2011-08-27 03:03:06 +09:00
execjosh f5f436160c Migrate page settings to PhantomConfig 2011-08-27 03:02:59 +09:00
execjosh a445b2d7b9 Migrate network access manager settings to PhantomConfig 2011-08-27 03:02:51 +09:00
execjosh 5441f51607 Migrate proxy settings to PhantomConfig 2011-08-27 03:02:43 +09:00
execjosh a75f7c9dc3 Create PhantomConfig and migrate output and script encoding settings 2011-08-27 03:02:35 +09:00
Ariya Hidayat 66460a7793 Fix building with Qt 4.6. 2011-08-24 05:48:07 -07:00
Ariya Hidayat 6fe972d0a8 Implement WebPage's release() function in pure C++. 2011-08-23 18:53:53 -07:00
Ariya Hidayat 08e6c5b8cd Merge pull request #132 from execjosh/issue-194-default-encoding-utf8
[BUGFIX] issue 194: make default encoding UTF-8
2011-08-22 09:02:29 -07:00
Ariya Hidayat d3cb9fe750 Fix typo. 2011-08-21 22:07:33 -07:00
Ariya Hidayat c75e595ea4 Merge branch 'master' of github.com:ariya/phantomjs 2011-08-21 15:23:07 -07:00
IceArmy fb93d49a7f Rename page.destroy() to page.release() 2011-08-21 14:12:15 -07:00
IceArmy 3caac5a5a3 Rename "XSSAuditing" to "XSSAuditingEnabled" 2011-08-21 14:08:14 -07:00
execjosh d78b1e1f5e [BUGFIX] issue 194: make default encoding UTF-8 2011-08-21 19:48:02 +09:00
Ariya Hidayat f95a39230b Clean up WebPage#open, use named arguments. 2011-08-21 01:34:14 -07:00
Ariya Hidayat 6e4c1a40f2 Simplify WebPage#open, first argument is always url. 2011-08-21 01:25:43 -07:00
Ariya Hidayat 34a7389a2c Make Terminal class a real singleton. 2011-08-21 00:47:34 -07:00
Ariya Hidayat 83922ada2f Ensure consistent #ifdef guard. 2011-08-21 00:30:15 -07:00
Ariya Hidayat 4a96278d1b Include usage.txt in the project file. 2011-08-21 00:21:15 -07:00
Ariya Hidayat d3f10a8e18 Make CSConverter a real singleton. 2011-08-21 00:16:38 -07:00
Ariya Hidayat 944056ce4a Remove unused m_convert from Phantom class. 2011-08-20 23:52:23 -07:00
Ariya Hidayat 52746493c4 Remove useless extra empty line. 2011-08-20 23:45:21 -07:00
Ariya Hidayat 2dbdc36598 Reduce JSLint warnings on the bootstrap code. 2011-08-20 23:21:39 -07:00
Ariya Hidayat 776da4987f Add JSLint directives for the bootstrap code. 2011-08-20 23:11:14 -07:00
Ariya Hidayat 699f4f76f2 Fix coding style (no tab, 4 spaces). 2011-08-20 22:34:11 -07:00
Ariya Hidayat 9d19e02355 Remove stray character in the issue link. 2011-08-20 22:07:18 -07:00
Ariya Hidayat e679640700 Merge branch 'master' of github.com:ariya/phantomjs 2011-08-20 18:13:38 -07:00
Ariya Hidayat 319fd80ec3 Add callback for page initialization.
http://code.google.com/p/phantomjs/issues/detail?id=143
2011-08-20 17:57:01 -07:00
Ariya Hidayat e79a51bdd8 Merge pull request #129 from Roejames12/QWebSettings
New page settings
2011-08-20 17:17:36 -07:00
IceArmy 8880edcf78 Remove settings: jsOpenWindows, jsAccessClipboard, siteSpecificQuirksMode
Renamed jsEnabled to javascriptEnabled
2011-08-20 16:49:36 -07:00
Niek 8deac1b8c6 Fix issue 128 and issue 193 2011-08-20 10:24:56 +02:00
IceArmy 33005c3957 Add a few new QWebSettings for page settings.
Among the most useful, is the jsEnabled setting, which allows you to disable JavaScript.
2011-08-19 15:47:34 -07:00
Ariya Hidayat 545ce2a2b9 Merge pull request #126 from execjosh/issue186-script-and-terminal-encoding
Issue186 script and terminal encoding
2011-08-16 13:46:18 -07:00
Ariya Hidayat 155054e671 Merge pull request #124 from jgornick/reply-proxy-issue-158
Updated the network access manager to use a proxied reply so the response
2011-08-16 12:20:49 -07:00
execjosh 4e7d3f1c18 Change javascript property from "encoding" to "outputEncoding" 2011-08-17 04:17:42 +09:00
Ariya Hidayat 2867e06c53 Merge pull request #125 from robterrell/049e1f50bd54429ea2e43207ab01e10c8021988e
Added functions to WebPage class to simulate mouse move, mouse up, and mouse down using Qt.
2011-08-16 12:17:36 -07:00
execjosh 682b3532be Add command-line option to set encoding of starting script 2011-08-17 03:53:56 +09:00
execjosh 6254c84717 Add command-line option to set terminal output encoding 2011-08-17 03:49:12 +09:00
execjosh c3d7b2e918 Add static UTF-8 instance to encoding 2011-08-17 03:33:15 +09:00
execjosh ca92c9ff84 Allow startup script to set output encoding 2011-08-17 03:18:52 +09:00
execjosh dc72101c10 Replace direct usage of stdout and stderr with terminal 2011-08-17 03:15:02 +09:00
execjosh 714a849374 Create registry to hold globally-accessible instances 2011-08-17 02:52:23 +09:00
execjosh 40625b4c53 Wrap stdout and stderr to control display encoding 2011-08-17 02:49:48 +09:00
execjosh 1710409215 Wrap QTextCodec to control encoding/decoding 2011-08-17 02:47:28 +09:00
Joe Gornick 578aa6c236 Updated the network access manager to use a proxied reply so the response bodies can be captured. 2011-08-14 03:41:39 -05:00
Ivan De Marino 0842485f62 Merge remote-tracking branch 'upstream/master' into dev-commonjs_fileio 2011-08-08 23:42:36 +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
Ariya Hidayat f811e6ae1e Merge pull request #122 from Roejames12/master
Updates
2011-08-08 15:35:32 -07:00
IceArmy 862dc6e017 Update CoffeeScript to 1.1.2 2011-08-08 15:12:57 -07:00
Rob Terrell 049e1f50bd Added functions to WebPage class to simulate mouse move, mouse up, and mouse down. Also added click() convenience function, which combines a move, mousedown, and mouseup.
Added functions to simulate mouse move, mouse up, and mouse down events
in the Qt layer. For our uses, this was more reliable than creating
mouse events in javascript.
2011-08-07 09:29:50 -04:00
Ivan De Marino e71a992dbd Merge remote-tracking branch 'upstream/master' 2011-08-04 21:37:31 +01:00
Ariya Hidayat f280e51c2c Merge pull request #120 from detro/dev-commonjs_fileio
Filesystem API: completed the "Paths" API group from CommonJS/Filesystem
2011-08-01 22:43:44 -07:00
Bartosz Nitka bb2adcc986 Prevent javascript timeout
"The script on this page appears to have a problem. Do you want
to stop the script ?" dialog should no longer show
2011-08-01 17:31:13 -07: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
Ivan De Marino f3a11cd224 Given the progress made by Alessandro with [#140](http://code.google.com/p/phantomjs/issues/detail?id=140),
we should consider re-instating this .pro option for Mac.

Yes, it will still show the Icon in the Dock, but we gain the static executable.
2011-08-01 22:40:07 +01:00
Kapil Reddy 6e39625ecf added scrollPosition support in c++ version 2011-07-22 13:41:30 +05:30
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 49ee7b52fd A bit more code doc 2011-07-20 22:43:34 +01:00
Ivan De Marino 21d633b786 Implement "fs.read" and "fs.write" in the JavaScript shim.
* I'd have to do it for throwing an exception in case of error anyway
* Updated a bit the code doc
2011-07-20 22:43:00 +01:00
Ivan De Marino ad33cb5b0b Note in the code what method I'm going to add to the "fs" object (update). 2011-07-20 22:42:48 +01:00
Ivan De Marino 540c6a6672 Note in the code what method I'm going to add to the "fs" object. 2011-07-20 22:42:30 +01:00
Erik Dubbelboer b1d947dd51 added persistent cookie support 2011-07-19 19:32:42 +02:00
IceArmy d1c418ba07 Allow constructs such as: page.open(url, operation) 2011-07-04 11:06:34 -07:00
IceArmy 895923603f Fix memory issues by providing a way to truly delete WebPages. #154
Use page.destroy() to delete the page and regain the memory.
2011-07-02 17:08:06 -07:00
Alessandro Portale c86d104c83 Remove obsolete #include <gifwriter.h> 2011-06-30 05:15:43 +02:00
Alessandro Portale 3fd978d6bf List bootstrap.js in Qt Creator under "Other Files" 2011-06-30 05:13:52 +02:00
Ariya Hidayat da749624a3 Merge pull request #99 from aportale/Issue_148
Fix crash on exit (Issues #136, #148 and #149)
2011-06-28 18:05:40 -07:00
Alessandro Portale 5acaa6b42d Fix crash on exit (Issues #136, #148 and #149)
Workaround: Apparently, all QWebPages need to be deleted before
the QApplication gets destroyed.
2011-06-29 00:45:12 +02:00
Ivan De Marino 3807b9dc4d Now, if "fs.open" fails, it throws an exception.
* This is implemented with a javascript-shim
2011-06-28 21:35:27 +01:00
Ivan De Marino a0e1888c2c Moved the "fs" object to be in the global/window space: will not be attached to the "phantom" object anymore.
* Once (and if) we implement support for CommonJS Module Loading, a "require("fs")" will be required.
2011-06-28 21:02:48 +01:00
Ivan De Marino aad029e53f Sorting out some nitpicks. 2011-06-28 13:24:24 +01:00
Ariya Hidayat c5213b24b0 Revert "Mac OS X: No need to build as an application bundle."
This reverts commit c6db0354ea.
2011-06-27 19:54:39 -07:00
Ivan De Marino f4aa689ec7 A bit more compliancy with the CommonJS Filesystem/A draft specs.
* Renamed some methods to be more compliant with the specs
* Added some Directory/Tree specific ops
* Support for the open mode '+' (that is equivalent to 'a')
* See draft at: http://wiki.commonjs.org/wiki/Filesystem/A
2011-06-27 23:14:41 +01:00
Ivan De Marino 6b04ee23c1 Introducing File I/O API in PhantomJS.
* This is the  squash of 30 commits, so it's meaty
* Inspired by HammerJS (see https://github.com/senchalabs/hammerjs)
* Not yet 100% complete
* Final aim is to provide a CommonJS/Filesystem compliant API (see http://wiki.commonjs.org/wiki/Filesystem)
2011-06-27 23:14:05 +01:00
Ariya Hidayat f25a7a66e5 Bump the Qt requirement to version >= 4.6.
Also, remove code branch for Qt 4.5.
2011-06-26 21:51:30 -07:00
Ariya Hidayat c6db0354ea Mac OS X: No need to build as an application bundle.
http://code.google.com/p/phantomjs/issues/detail?id=139
2011-06-26 00:03:18 -07:00
Ariya Hidayat cf23a5c6e3 Bump unstable version. 2011-06-25 23:59:16 -07:00
M. Scott Ford 1b67c2b8c4 Fixed issue with the open method that was preventing the use of POST unless a onLoadFinished handler was also passed in. 2011-06-26 00:07:07 -04:00
Ivan De Marino 99310e2c47 Curing my _Commentitis_. 2011-06-25 00:16:57 +01:00
Ivan De Marino 2895d096ab Adding "--local-access-remote=[yes|no]".
* This will allow local content to access remote content, bypassing the same origin policy.
* It's controllable from the CLI and through the "page.settings" property
* This addresses Issue #28 but only partially: it's still not possible to make _remote content access other remote content on a different origin_.
2011-06-24 15:57:55 +01:00
Ivan De Marino 0a2ec5f09f Sorting out the Page Settings Names into a unique source of truth (i.e. consts.h) 2011-06-24 15:51:01 +01:00
Ivan De Marino 9fa0a2c7ce Enabled HTML5 Web App Cache. 2011-06-24 15:28:17 +01:00
Ivan De Marino 6a56c53fba Sorted out a bit the global "QWebSettins".
More stuff to come: I'm working on Issue #28.
2011-06-24 14:54:31 +01:00
Ivan De Marino 40817dd525 Added "--version" and updated text in the usage text. 2011-06-24 14:17:54 +01:00
Ariya Hidayat 753ef864b9 Merge pull request #84 from corgibytes/fix-disconnect-this
Correctly disconnected event handler.
2011-06-20 23:59:32 -07:00
Ariya Hidayat 8094cdb4e7 Make sure phantom.exit() really exits.
Patch by Alessandro Portale.
2011-06-20 23:24:51 -07:00
M. Scott Ford 95a7650be8 Correctly disconnected event handler. 2011-06-20 18:55:05 -04:00
Ariya Hidayat baa4382de9 Merge pull request #83 from Roejames12/69b06da1
Revert "Exit program properly when we call phantom.exit"
2011-06-20 10:33:32 -07:00
Ariya Hidayat 3abb03d638 Build fix for Qt 4.5. 2011-06-20 10:26:32 -07:00
IceArmy 69b06da140 Revert "Exit program properly when we call phantom.exit" 2011-06-20 10:14:08 -07:00
Ariya Hidayat 7ba0d6964e Merge pull request #82 from Roejames12/master
Exit program properly when we call phantom.exit
2011-06-19 23:19:44 -07:00
IceArmy 3d0c56af40 Fix the last problem with setTimeout and setInterval 2011-06-19 21:18:14 -07:00
Ariya Hidayat 00810e98b3 Pass source and lineNumber for console redirection.
onConsoleMessage callback can handle two (optional) arguments, e.g.

    page.onConsoleMessage = function (msg, lineNo, source) {
        ....
    };
2011-06-19 21:06:27 -07:00
IceArmy c44838227d Fix bug where phantom.exit wouldn't exit properly 2011-06-19 17:26:39 -07:00
IceArmy 54478a1154 Use qWarning only if script isn't starting script 2011-06-19 14:00:04 -07:00
IceArmy 7a9e0c8599 Exit on start script error 2011-06-19 13:37:03 -07:00
IceArmy 0e765f2a95 Exit program properly when we call phantom.exit
Previously, calling phantom.exit would set the exit code and finish running the
JavaScript until it was done, then exit the program with your code. Basically
it didn't actually exit the program. It caused many code fallthrough problems,
but is now fixed. :)
2011-06-19 01:20:45 -07:00
IceArmy ff3eb34fc1 Maintain consistency across error messages 2011-06-18 00:27:59 -07:00
Ariya Hidayat 6e2b362850 Change scriptLookupDir to libraryPath. 2011-06-17 20:52:19 -07:00
Ariya Hidayat 12c81516cc Never continue if terminated is flagged. 2011-06-17 20:52:13 -07:00
Ariya Hidayat 944afb314e Do not crash when the command line option is unknown.
http://code.google.com/p/phantomjs/issues/detail?id=124
2011-06-17 18:37:01 -07:00
Ariya Hidayat 75bbbebb89 Simplify the logic inside Phantom::execute().
We need to make sure we return quickly if terminated is set to false
(e.g. in the constructor, if something is wrong).
2011-06-17 18:04:20 -07:00
Ariya Hidayat 78856f8d51 Fix a regression where exit() function does not work.
http://code.google.com/p/phantomjs/issues/detail?id=119
2011-06-17 17:43:47 -07:00
IceArmy 520010fab8 Simplify bootstrap defineSetter code into function 2011-06-17 01:04:19 -07:00
IceArmy 9ed0c2951e On Coffee convert error, just warn and return nothing.
The reason for this is for consistencies sake. When we have a JavaScript
evaluation error, it shows the error, but doesn't exit the program.
Since we can inject CoffeeScripts as well as JS, it wouldn't be
consistent to exit the program. So we just warn instead.
2011-06-16 21:30:10 -07:00
IceArmy e52ed4a54a Report CoffeeScript compile errors 2011-06-16 17:28:36 -07:00
IceArmy 61459fab45 Use phantom.scriptName instead of phantom.args[0] 2011-06-15 14:30:31 -07:00
IceArmy c8c58f11c7 Pass script's filename as arg[0] 2011-06-15 02:57:14 -07:00
IceArmy 309d3b5aaa Allow scriptLookupDir to be set for phantom object 2011-06-12 14:38:34 -07:00
IceArmy 25ac6d35ca phantom.injectJs should use the starting scripts directory, not the app directory 2011-06-12 14:04:07 -07:00
IceArmy 99473110df Merge branch 'master' of https://github.com/ariya/phantomjs 2011-06-12 01:40:18 -07:00
IceArmy 985593221f Re-fix commit 3c665681 2011-06-12 01:38:30 -07:00
Ariya Hidayat 693d1c5f23 Handle 'onConsoleMessage' event just like the other events. 2011-06-11 17:16:49 -07:00
Ariya Hidayat d92723bd29 Handle onAlert event just like the other events. 2011-06-11 16:05:53 -07:00
Ariya Hidayat f6c55010b9 Use closure to make 'handlers' really private. 2011-06-11 03:51:08 -07:00
Ville Lautanala 0aae7361af Fix reference to handlers in onResourceReceived 2011-06-11 11:52:34 +03:00
Ivan De Marino 22ee075cc2 Removing "page.click()" for now.
There is need for a discussion to decide how to do this.
2011-06-10 17:08:46 +01:00
Ivan De Marino bd18d7c838 More work on "injectJs"
* "injectJs()" now supports ".coffee" input
* "injectJs()" is now available for the "phantom" object as well
* CSConverter is now a singleton embedded in the Utils static class
* The code used by "injectJs()" is now centralised in the Utils static class
2011-06-10 17:08:46 +01:00
Ivan De Marino cc45aa7f38 Normalie user-provided script path 2011-06-10 17:08:46 +01:00
Ivan De Marino 75403737c4 Added "includeJs()" to "page".
* It includes a script in the page
* It uses a callback to ensure any code dependent on the include runs afterwards
* It uses the signal "javaScriptAlertSent" to do the trick (is there another way to be notified of the "onLoad" event from outside the page context?)
* It uses a "private" slot "_appendScriptElement" to pass the script url in the page context (is there a better way?)
2011-06-10 17:08:46 +01:00
Ivan De Marino 11c8322718 Renaming "page.handlers" to "page._handlers": more common for "private" stuff. 2011-06-10 17:08:46 +01:00
Ivan De Marino a0f8f2491d "loadJsFile()" -> "injectJs"
* According to Issue #32 (http://code.google.com/p/phantomjs/issues/detail?id=32) I added a "lookup logic" that searchs for the file following those steps:
*# Search for file at given path (relative to PWD or absolute - no difference)
*# Is file there? Inject it
*# Is file not there? Try looking for it in "scriptLookupDir"
*# Is file there? Inject it
*# Is file not there? abort
* "scriptLookupDir" is an extra property for WebPage, that, as by it's name, defines a place where to look to script to inject
* Script can alter the scriptLookupDir, if they want
* Updated "injectme.js" accordingly
2011-06-10 17:08:45 +01:00
Ivan De Marino bb0b820f72 Merge remote-tracking branch 'upstream/master' into utilities 2011-06-09 11:50:54 +01:00
Ariya Hidayat 751e471068 Better timing for onResourceRequested and onResourceReceived.
We record the time right inside the network access manager. This gives
better accuracy than doing it from JavaScript side, no loss due to the
latency of signal slot connection.
2011-06-08 23:32:14 -07:00
Ariya Hidayat dd8344f041 Expose more properties for onResourceReceived event. 2011-06-08 23:28:54 -07:00
IceArmy 3c665681f4 Fix possible bug where if CoffeeScript starts with a shebang (hashbang) #!, then // gets put in front of it; but this is not a comment in CoffeeScript, so it causes a problem with the conversion. 2011-06-08 19:00:07 -07:00
Ariya Hidayat 555f80c899 onResourceReceived with stage=start should fire only once.
We detect if stage=start has been fired before. If yes, no need to
fire again, thus making the event is associated with the very
first byte received for the given resource.
2011-06-08 07:57:51 -07:00
Ariya Hidayat 5b2fdca640 Add a unique id to associate resource request and receive. 2011-06-08 07:54:28 -07:00
Ariya Hidayat 1cae77a3e0 Add 'onResourceReceived' event, fired when resource is being received.
This is now being used in the netsniff.js example.
2011-06-08 01:10:00 -07:00
Ariya Hidayat ea62c17b91 Fix typo, it's C5E and not CSE. 2011-06-07 11:27:10 -07:00
IceArmy 81627896c2 Support every possible PDF format 2011-06-07 10:57:08 -07:00
Ivan De Marino 5b6f2731c4 Added support for "page.click()" and "page.loadJsFile()".
* click() accepts a "querySelectorAll" input - can click on multiple things in one call
* loadJsFile() is synchronous at loading JS in the page
* added 2 examples in JavaScript to show how to use (and test) the new methods
* NOTE: someone will have to generate the .coffee version - I tried using "http://ricostacruz.com/js2coffee/" but it hangs and I'm not willing to learn why :P - I don't like Coffee Script.
2011-06-07 17:20:22 +01:00
Ariya Hidayat 4dfe70f620 Enumerate all headers in the HTTP request. 2011-06-07 00:19:12 -07:00
Ariya Hidayat a0ab4f798e Get away with manual qDebug() since we can use the API now. 2011-06-07 00:14:01 -07:00
Ariya Hidayat 8722399c0a Add "onResourceRequested" event, fired when request is started.
To see how this is being used, see the new examples/netsniff.js.

http://code.google.com/p/phantomjs/issues/detail?id=2
2011-06-07 00:06:08 -07:00
Ariya Hidayat c8504f6994 Introduce "onLoadFinished" event, fired when loading is completed.
It is now possible to specify only the URL in the open() function.
The loading callback can be set using onLoadFinished.

Example use:

    var page = new WebPage();
    page.onLoadFinished = function () {
        console.log("Done!");
        phantom.exit();
    };
    page.open("http://example.com");
2011-06-06 01:40:17 -07:00
Ariya Hidayat d9d9d5a8ac Introduce 'onLoadStarted' event which will fire upon page loads.
An example use:

      var page = new WebPage();
      page.onLoadStarted = function() {
          console.log('start loading...Please wait');
      };
      page.open("http://example.com", function (status) {
          console.log('Done ' + status);
          phantom.exit();
      });
2011-06-06 01:39:24 -07:00
Ariya Hidayat c68762dc9d Add --version command-line option. 2011-06-06 00:36:31 -07:00
Ariya Hidayat f4d40b82f1 No need for the command-line --upload-file. 2011-06-05 13:26:10 -07:00
Ariya Hidayat f8b9c322ea Bring back file upload support.
Instead of using command-line option, file can be uploaded using
WebPage.uploadFile function, e.g.:

  var page = new WebPage();
  page.open(....., function () {
      page.uploadFile('input#attachment', '/path/to/file');
  });

uploadFile() accepts selector name (first argument), this is used to identify
which input element will need the filename (second argument).
2011-06-05 00:34:27 -07:00
IceArmy 69ff230f3a Revert "Fix bug where WebPage.evaluate had a syntax error."
This reverts commit d2c520a777.
2011-06-01 12:14:20 -07:00
IceArmy d2c520a777 Fix bug where WebPage.evaluate had a syntax error.
It now creates a proper anonymous function (which passes this for global context)
2011-06-01 02:09:07 -07:00
Ariya Hidayat dfb19a4d8a WebPage callback for its JS alert.
This is similar to the way console message is handled (see commit
5be29972). WebPage callback for alert is called 'onAlert'.
2011-05-29 00:29:29 -07:00
Ariya Hidayat 1d9c349265 Make exit() synchronous.
We might still need to find a workaround if this crashes on Windows
(see commit bb355db6).
2011-05-29 00:20:56 -07:00
Ariya Hidayat 5be29972cf WebPage callback for its console message.
See http://code.google.com/p/phantomjs/issues/detail?id=12.

By default, WebPage is "silent" and does not report its console message.
This can be overridden easily, e.g:

  var page = new WebPage();
  page.onConsoleMessage = function (msg) {
    console.log(msg);
  };
  page.open(.....);
2011-05-28 21:16:18 -07:00
Ariya Hidayat e7ca6c0aaf Render the web page using tiling approach.
http://code.google.com/p/phantomjs/issues/detail?id=54

Because Qt software rasterizer has a bug in its fillRect() when
dealing with very big paint device, we split the painting into
smaller-size tiles.
2011-05-28 16:02:48 -07:00
Ariya Hidayat 7594a050e9 Refactor render(), split the buffer rendering to its own function.
This can be useful for issue #15.
2011-05-28 13:51:39 -07:00
Ariya Hidayat ff726de796 Simplify buffer handling in render(). 2011-05-28 13:45:23 -07:00
Ariya Hidayat b1af26ecc0 Support different HTTP operations for loading a page.
http://code.google.com/p/phantomjs/issues/detail?id=88
2011-05-28 02:06:20 -07:00
Ariya Hidayat 7e099abaf2 User-agent is part of WebPage settings, not WebPage object itself. 2011-05-27 22:50:33 -07:00
Ariya Hidayat 2a46ccde8b WebPage object can have settings. 2011-05-27 22:36:34 -07:00
Ariya Hidayat b8fc6558a2 Bring back load-images and load-plugins option. 2011-05-27 20:39:09 -07:00
Ariya Hidayat f5e070d444 Store bootstrap code in its own file. 2011-05-26 02:18:09 -07:00
Ariya Hidayat a65ae9b1a8 Reenable custom network access manager. 2011-05-26 01:56:43 -07:00
Ariya Hidayat 9a2fd4b361 Bring back some default web page settings. 2011-05-26 00:27:55 -07:00
Ariya Hidayat df64f60ec9 Use WebPage, not QWebPage, inside Phantom class. 2011-05-25 14:00:20 -07:00
Ariya Hidayat d15e097815 Refactor most of functionalities to WebPage object.
This breaks all examples (will be fixed slowly). Some features, e.g.
file upload, are also still regressed.
2011-05-25 10:49:35 -07:00
rgieseke 11cc69efa4 Update CoffeeScript to version 1.1.1. 2011-05-11 11:45:23 +02:00
Peter Jihoon Kim 57f525a78a added option: --ignore-ssl-errors=[yes|no] 2011-04-29 16:32:40 +08:00
Ariya Hidayat 710e947ac7 Fix issue 93: build with Qt 4.5.
Guard some Qt >= 4.6 features in version checks.
2011-04-18 22:50:27 -07:00
Ariya Hidayat a23a012ef9 Fix issue 93: build with Qt 4.6
Guard some new enums of QNetworkAccessManager in Qt version checks.
2011-04-18 22:47:29 -07:00
Ivan De Marino 4f1fbb3f81 Commented out flags for "phantomjs.pro" that can be useful to have at hand. 2011-04-19 01:04:15 +01:00
IceArmy 924eaa9cbd Only show status code if it exists 2011-04-13 07:45:54 -07:00
IceArmy acbc62a1a5 Added HTTP status code to debug messages in handleFinished() 2011-04-13 04:07:53 -07:00
IceArmy 6fdc9d11f5 Allow setting clipRect to height:0, width:0, which will 'reset' the clipRect 2011-04-13 02:08:33 -07:00
IceArmy 3ca9137219 Show response URL on NetworkAccessManager's Reponse (because you can't always know what request the response came from) 2011-04-12 18:53:23 -07:00
IceArmy 6f9f368cab Fixed issue 86 - req.url() in NetworkAccessManager createRequest() displays incorrectly 2011-04-12 18:37:29 -07:00
Jon Turner e82619df4d Removed old function declaration 2011-04-12 18:10:53 +01:00
Jon Turner 0e1e5071fb Added option for disk cache use 2011-04-12 15:21:09 +01:00
Ariya Hidayat e808690fd8 Default build should not litter the output with debug messages. 2011-04-09 23:04:01 -07:00
Ariya Hidayat 7280e6d5c6 For the moment, remove simulateMouseClick, includeJS, and loadJS.
See http://code.google.com/p/phantomjs/issues/detail?id=32 and
http://code.google.com/p/phantomjs/issues/detail?id=41.
2011-04-09 22:40:36 -07:00
Ariya Hidayat c0ea3d8732 Preserve last year copyright. 2011-04-09 22:37:06 -07:00
Ivan De Marino 8ed9dc1c44 Adding forgotten Include Guards. 2011-04-09 19:49:22 +01:00
Ivan De Marino 1f1e1d17e4 Amended a stupid mistake with Version String.
I always forget that the Pre-Compiler passes only once.
2011-04-09 19:48:58 +01:00
Ivan De Marino be72a29c9f Propagated License Headers. 2011-04-09 18:34:04 +01:00
Ivan De Marino 71e0612ccc Added analysis of the HTTP Reply in the NetworkAccessManager. 2011-04-09 18:26:04 +01:00
Ivan De Marino 6ec8b3b669 New "shim" Network Access Manager, new 'browsermode' example and more.
The new Network Access Manager currently is designed to do just logging:
- logs HTTP Method type
- logs HTTP Destination URL

The new 'browsermode':
It's in "/examples" and make PhantomJS do just a call to "open(url)".
It has a companion shell script to help with the task.

Also, improvement for Message Handler:
messages are now prefixed with ISO Datetime.
2011-04-09 18:22:52 +01:00
Ivan De Marino c616205620 Added a Qt Message Handler (finally). 2011-04-08 15:49:20 +01:00
Ivan De Marino a45b8e8401 Major refactoring of the CPP code into separate classes.
This doesn't add ANY new feature: it's aimed only at separating code into
more manageable pieces.

Maybe it's not perfect yet, but it's a start.
2011-04-08 14:30:50 +01:00
Ivan De Marino ce07e12c9e Merge remote branch 'upstream/master' 2011-04-07 10:19:12 +01:00
IceArmy 6888877aad In setClipRect, remove top and left positive only limits 2011-04-01 13:21:35 -07:00
Wouter de Bie 2a84536d95 Match coding style 2011-03-30 08:18:47 +02:00
Wouter de Bie affdd9b245 Don't copy buffers, but translate the QPainter instead when clipping 2011-03-29 21:01:40 +02:00
Wouter de Bie f96d113302 Renamed clipSize() to clipRect() 2011-03-29 20:09:45 +02:00
Wouter de Bie 7531b3311c Renamed renderSize() to clipSize() and fixed a bug 2011-03-29 20:06:12 +02:00
Wouter de Bie 2fe2e696ee Modified phantom.renderSize() to allow top and left parameters 2011-03-29 13:30:40 +02:00
Wouter de Bie 3e939febd4 Added phantom.renderSize() to be able to control the dimensions of the output 2011-03-29 08:39:58 +02:00
Ivan De Marino 8ac4a7962b Separated the "usage" instructions in a text file, embedded as "resource".
Also:
* I added a couple of "qFatal" where it makes sense.
* Usage now mentions the fact that the input files that finish by ".coffee" are also acceptable
2011-03-24 23:20:34 -07:00
Ivan De Marino f86bc38bc1 Separated the "usage" instructions in a text file, embedded as "resource".
Also:
* I added a couple of "qFatal" where it makes sense.
* Usage now mentions the fact that the input files that finish by ".coffee" are also acceptable
2011-03-24 22:43:49 +00:00
Ivan De Marino 23cfad71fa Merge remote-tracking branch 'upstream/master'
Conflicts:
	src/phantomjs.cpp
2011-03-24 22:00:53 +00:00
Ariya Hidayat 2182d8e54b Add icon files for Windows and OS/2.
Issue: http://code.google.com/p/phantomjs/issues/detail?id=60

This improvement is provided by Salvador Parra Camacho.
2011-03-18 23:43:45 -07:00
Alessandro Portale fbb524e629 Issue 17: Make paper size for the PDF export specifiable
http://code.google.com/p/phantomjs/issues/detail?id=17

Adding a new phantom property called "paperSize". It takes one of
the two possible dictionary variants:
   { width: '200px', height: '300px', border: '0px' }
   { format: 'A4', orientation: 'portrait', border: '1cm' }
- If no paperSize is defined, the size is defined by the web page
- supported dimension units are: mm, cm, in, px. No unit means px.
- border is optional and defaults to 0.
- supported formats are: A3, A4, A5, Legal, Letter, Tabloid
- orientation (portrait|landscape) is optional and defaults to portrait

I'm considering implementing a short form like:
  phantom.paperSize = 'A4';
...needs further investigation.
2011-03-18 10:26:45 +01:00
Ivan De Marino 3b4163521f Merge remote-tracking branch 'upstream/master' 2011-03-14 22:53:27 +00:00
Ariya Hidayat a7a1322ea1 Fixed issue #19: option for setting the proxy.
Based on the original patch by Clint Berry.
2011-03-13 21:35:49 -07:00
Ivan De Marino 6ad3352519 Minor tweaks for qDebug messages 2011-03-04 10:13:32 +00:00
Ariya Hidayat 158362ed16 Start to implement support for CoffeeScript. 2011-03-02 00:59:07 -08:00
Ivan De Marino 25cf54784f Added "phantom.loadJs" and "phantom.includeJs", plus more "qDebug" usage
* "phantom.loadJs()" loads a JS file and executes it's content within the current Document Context. It's synchronous.
* "phantom.includeJs()" adds a <script> tag include. It's asynchronous and accepts as second parameter a "callback", fired when the js file has been loaded.
* Some more qDebug() calls
* qDebug() output disabled by default in the .pro file

NOTE: I'm adding qDebug() calls to make development of phantomjs easier and "debuggable"
2011-03-01 18:16:44 +00:00