Commit Graph

166 Commits (49d82a25b00d942b453f9cb44095fe8a3d9530ed)

Author SHA1 Message Date
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
Ivan De Marino ee1c5afc32 Merge branch 'master' of https://github.com/detro/phantomjs 2011-03-01 12:09:12 +00:00
Ivan De Marino 8951859a53 Added "phantom.simulateMouseClick" and other minors for debugging.
* 'phantom.simulateMouseClick' accepts a 'selector' and clicks on every element that matches the selector
* Added a couple of 'qDebug()' to help debugging PhantomJS
2011-03-01 12:09:03 +00:00
Ivan De Marino 9c74adeeca Enhanced the "usage" message and fixed misdocumented behaviour of "--load-plugins"
* Now the "usage" shows all the options that are currently supported by phantomjs from the command line
* The default behaviour for the option "--load-plugins" is now fixed (to "no")
2011-02-28 23:17:59 +00:00
Ariya Hidayat 378406b89d Support for rasterizing as GIF image. 2011-02-19 22:47:15 -08:00
Ariya Hidayat 84a594112e Allow plugins loading (by default, plugins are not loaded).
This is issue #14:
http://code.google.com/p/phantomjs/issues/detail?id=14
2011-02-13 22:44:43 -08:00
Ariya Hidayat f827d88818 Allow disabling the loading of images.
This is issue #35:
http://code.google.com/p/phantomjs/issues/detail?id=35
2011-02-13 21:29:58 -08:00
Ariya Hidayat 799fa0b210 Hide command-line options from the script.
For example, the argument to allow file upload now is part of
phantomjs invocation:

    phantomjs --upload-file tag=/path/to/file script.js A B C

which means script.js only "sees" A, B, C in phantom.args array.
2011-02-13 20:59:37 -08:00
Ariya Hidayat bc6792769b Coding style fixes. 2011-02-13 12:01:12 -08:00
Matthias 5a7f742c11 File Uploads
pass --upload-file fileTag=/path/to/file as an argument and set the file of <input type="file" id="foo"/> by calling phantom.setFormInputFile(document.getElementById('foo'), 'fileTag');
2011-02-06 19:55:04 +01:00
Matthias e4a374185b Comment out shebang 2011-02-06 13:53:30 +01:00
Ariya Hidayat 9eb2dfb505 Really make it compile with Qt 4.6. 2011-01-29 19:17:10 -08:00
Ariya Hidayat 4baf0269ba Make it compile with Qt 4.6. 2011-01-29 19:13:19 -08:00
Ariya Hidayat 6e4aeb1077 Bump version. 2011-01-29 19:07:35 -08:00
mattn ee54806abc load script as utf-8 encoding. 2011-01-28 20:04:00 +09:00
mattn c0398f3fd7 use setUseSystemConfiguration(true). 2011-01-28 20:02:54 +09:00
Ariya Hidayat 0faca2649e Fix coding style. 2011-01-27 16:51:43 -08:00
jdalton 6bb2f1b4a1 phantomjs: Allow PhantomJS to build with Qt 4.5 which is available for Cygwin. [jddalton] 2011-01-27 18:57:35 -05:00
Alessandro Portale d14be77e56 Issue 20: JPG transparent colour is black.
Filling QImage with transparent white instead of transparent
black. For an artifact free rendering of a transparent web
page into PNG, Format_ARGB32 is needed instead of
Format_ARGB32_Premultiplied.
2011-01-27 16:54:58 +01:00
Ariya Hidayat 7f9e03ffad Change phantom.arguments to phantom.args.
This is explained in
http://code.google.com/p/phantomjs/issues/detail?id=16:

'arguments' is reserved word.

Reported by: Nicolas Ferrero.
2011-01-14 22:24:47 -08:00