Commit Graph

233 Commits (master)

Author SHA1 Message Date
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 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 da629874d3 examples/feature.js: Show supported/unsupported features.
Feature detection is done via Modernizr.
2011-06-26 14:05:48 -07:00
Dunk Fordyce 42472aa92f fix page/phantom variable wrongness 2011-06-21 14:34:41 +01:00
Ariya Hidayat 9931279ccc Remove unnecessary console redirection. 2011-06-19 15:28:58 -07:00
rgieseke e09da4e1d8 netsniff.coffee: Remove dot in prototype check. 2011-06-17 09:05:19 +02:00
rgieseke 7e4a5fd33e injectme.coffee: Add CoffeeScript version. 2011-06-17 09:04:08 +02:00
rgieseke 913b214d91 useragent.coffe: Change useragent as in js version. 2011-06-17 08:45:41 +02:00
rgieseke e5064db060 pizza.coffee: Add missing onConsoleMessage. 2011-06-17 08:25:35 +02:00
rgieseke 2c8e9bd5b4 Examples: new coffeescript versions. 2011-06-16 22:56:06 +02:00
Ivan De Marino e2ee86e0ac Minor cleanup on 'sleepsort.js' 2011-06-16 14:48:41 +01:00
Ivan De Marino d00ed3f2fc sleepsort.js - This must go in for 1.2 :P
* It's so silly, it has to.
* Also, it shows how "powerful" the function scoping is
2011-06-16 11:46:10 +01:00
Ariya Hidayat 6b28a956ac Refer to function argument 'startTime', not from page. 2011-06-13 08:11:40 -07: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 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 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
IceArmy 0bfd28e67d example/netsniff.coffee: Format the output to HAR 1.2 specification. 2011-06-09 00:58:03 -07:00
Ariya Hidayat c2c6cbc287 example/netsniff.js: Format the output to HAR 1.2 specification. 2011-06-08 23:47:14 -07: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 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
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
IceArmy 805c824ff3 Convert netsniff.js to CoffeeScript 2011-06-07 02:52: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 cf8a890f8b loadspeed.js: Fixed missing semicolons. 2011-06-06 23:52:39 -07:00
IceArmy 88f9434a0c Convert run-jasmine.js to CoffeeScript 2011-06-06 19:01:45 -07:00
IceArmy 331be469bc Convert run-qunit.js to CoffeeScript 2011-06-06 18:57:46 -07:00
IceArmy 6390f92550 Convert imagebin.js to CoffeeScript 2011-06-06 18:52:33 -07:00
Ariya Hidayat 3170b2b4b6 imagebin.js: Example of file upload inside form.
Warning: this script has zero error checking.
2011-06-05 01:11:59 -07:00
IceArmy 253469b03e Improve waitfor.coffee readability 2011-06-02 17:18:25 -07:00
IceArmy 5e876a6517 Improve weather.coffee a little 2011-06-02 17:18:11 -07:00
IceArmy ac354d7804 Convert render_multi_url.js to CoffeeScript 2011-06-02 00:46:50 -07:00
IceArmy bdf4fb4571 Convert post.js to CoffeeScript 2011-06-02 00:46:50 -07:00
IceArmy 6b2c492796 Port tweets.coffee to PhantomJS 1.2 2011-06-02 00:46:50 -07:00
IceArmy 39d8522c3a Port weather.coffee to PhantomJS 1.2 2011-06-02 00:46:50 -07:00
IceArmy dd0d437b89 Port countdown.coffee to PhantomJS 1.2 2011-06-01 23:20:47 -07:00
IceArmy 80131a2353 Port waitfor.coffee to PhantomJS 1.2 2011-06-01 19:51:17 -07:00
Ivan De Marino e59054247c Converted 'cycle_multiple_urls.js' to PhantomJS 1.2 (and renamed to 'render_multi_url.js').
Given that I practically rewrote it, I took the liberty to rename it based on my personal taste ;)
2011-06-01 18:37:57 +01:00
Ivan De Marino 93d2c30248 Converted 'run-jasmine.js' to PhantomJS 1.2 2011-06-01 17:30:27 +01:00
Ivan De Marino afce9b83b0 Converted 'run-qunit.js' to PhantomJS 1.2 AND fixed a stupid mistake in 'waitFor' 2011-06-01 17:24:32 +01:00
Ivan De Marino f8e59f92f8 Ported 'waitfor.js' to Phantom 1.2.
* There is a problem though: the script causes a "segfault" on phantom.exit() - I didn't investigated why yet
2011-06-01 16:29:44 +01:00
Ivan De Marino 78cab6b4b1 Converted "weather.js" for PhantomJS 1.2 2011-06-01 14:55:35 +01:00
Ivan De Marino 811c56b6f3 Ported 'countdown.js' to PhantomJS 1.2 2011-06-01 14:25:22 +01:00
Ivan De Marino b91f5b9632 Converted "tweets.js" to PhantomJS 1.2.
First impression: PhantomJS 1.2 makes a lot of sense.
But there are issues if we try to pass a DOM node as a return value for calls to "evaluate"
2011-06-01 14:18:08 +01:00
Ariya Hidayat a7a8a6749a Merge pull request #49 from rgieseke/cs-examples
Port CoffeeScript examples to use WebPage object.
2011-05-29 12:33:03 -07:00
rgieseke 2a8fac45b4 Indent with 2 spaces. 2011-05-29 14:21:25 +02:00
rgieseke 5b8a40e763 Remove unused variable. 2011-05-29 14:01:55 +02: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 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
rgieseke 08c6faff71 More CoffeeScript examples using WebPage. 2011-05-27 12:09:15 +02:00
rgieseke 4f68bf7067 Use WebPage in useragent.coffee example. 2011-05-26 11:08:33 +02:00
rgieseke dcd91d73d1 Use WebPage in pizza.coffee example. 2011-05-26 11:07:37 +02:00
rgieseke fc5b799db0 Use WebPage in direction.coffee example. 2011-05-26 11:06:41 +02:00
rgieseke 95c13d46fd Use WebPage in loadspeed.coffee. 2011-05-26 11:05:03 +02:00
rgieseke 71c61a8f7f Fix error message. 2011-05-26 11:04:00 +02:00
Ariya Hidayat 414a46e921 technews.js: Port to use WebPage object. 2011-05-25 23:37:56 -07:00
Ariya Hidayat 55bb382a1b follow.js: Port to use WebPage object. 2011-05-25 23:28:41 -07:00
Ariya Hidayat f84bef4b38 rasterize.js: Port to WebPage object. 2011-05-25 14:37:58 -07:00
Ariya Hidayat 5da05055cc pizza.js: Port to use WebPage object. 2011-05-25 14:37:25 -07:00
Ariya Hidayat 5f018b32b2 useragent.js: Port to WebPage object. 2011-05-25 14:37:25 -07:00
Ariya Hidayat 838b110e9e direction.js: Port to use WebPage object. 2011-05-25 14:10:35 -07:00
Ariya Hidayat a1f0691311 loadspeed.js: Port to use WebPage object. 2011-05-25 14:04:30 -07:00
Ariya Hidayat a4b540ef9e Merge branch 'master' of github.com:ariya/phantomjs 2011-05-25 10:58:26 -07:00
Ariya Hidayat 041e827447 Port color wheel example to use WebPage object. 2011-05-25 10:55:25 -07:00
Ismael Celis f204a3386e Example: Array.prototype.forEachWebPage() for easy loading and processing of multiple URLs in Phantom.js 2011-05-19 16:25:26 +01:00
Roejames12 2345087b21 Fixed issue 106 2011-05-16 23:25:47 -07:00
rgieseke 09519dab6c Use sencha account in follow example. 2011-05-11 16:57:52 +02:00
rgieseke c585107e38 Display tweet index in CoffeeScript example. 2011-05-11 16:52:57 +02:00
rgieseke cd9e3d9647 Use sencha twitter account. 2011-05-11 16:47:55 +02:00
rgieseke 4e0126a803 Use window as recommended in CoffeeScript docs. 2011-05-11 11:42:18 +02:00
rgieseke d3845e94ab Use YAML-Style array creation in follow.coffee. 2011-04-25 18:28:26 +02:00
rgieseke 38a6638d2c Fix weather.coffee. Implicit parentheses are until end of line. 2011-04-25 18:26:44 +02:00
rgieseke dfd4c06586 Remove unnecessary semicolons in coffeescript examples. 2011-04-23 19:43:18 +02:00
rgieseke 0a91497075 Loop only through divs, not length and item. 2011-04-23 14:41:19 +02:00
rgieseke 0acb9195b0 Add Coffeescript version of waitfor.js. 2011-04-23 14:38:51 +02:00
rgieseke e32b6ba529 Change meaning of message parameter to show what has happenend. 2011-04-23 13:13:38 +02:00
rgieseke c8043520ee Don't throw error on timeout, use phantom.exit instead. 2011-04-23 13:09:42 +02:00
rgieseke a7713e31da Use shorter default timeout. 2011-04-23 13:05:43 +02:00
rgieseke d4df69b175 Use an existing Twitter account and update name changes in new Twitter. 2011-04-23 13:04:48 +02:00
rgieseke ef899fee17 Use spaces throughout. 2011-04-23 13:00:00 +02:00
rgieseke 239ace5357 Add Coffeescript version of extract.js 2011-04-22 18:07:18 +02:00
rgieseke 34081845a4 Add Coffeescript version of weather.js. 2011-04-22 17:39:53 +02:00
rgieseke 71ef739988 Add Coffeescript version of version.js. 2011-04-22 17:39:52 +02:00
rgieseke 0475c72cea Add Coffeescript version of useragent.js. 2011-04-22 17:39:52 +02:00
rgieseke b2e50a26ce Add Coffeescript version of technews.js. 2011-04-22 17:39:52 +02:00
rgieseke 5d8e00c695 Add Coffeescript version of seasonfood.js. 2011-04-22 17:39:52 +02:00
rgieseke a486b7efa0 Add Coffeescript version of rasterize.js. 2011-04-22 17:39:51 +02:00
rgieseke a7c8008498 Add Coffeescript version of pizza.js. 2011-04-22 17:39:51 +02:00
rgieseke 20f278257e Add Coffeescript version of movies.js. 2011-04-22 17:39:51 +02:00
rgieseke 13a6be70b3 Add Coffeescript version of loadspeed.js. 2011-04-22 17:39:51 +02:00
rgieseke 99658b7f77 Add Coffeescript version of ipgeocode.js. 2011-04-22 17:39:51 +02:00
rgieseke c5101aa3a2 Add Coffeescript version of fibo.js. 2011-04-22 17:39:51 +02:00
rgieseke 94069c43ea Add Coffeescript version of direction.js. 2011-04-22 17:39:51 +02:00
rgieseke fdd1eebe0a Add Coffeescript version of countdown.js. 2011-04-22 17:39:51 +02:00
rgieseke e1317fffbb Add Coffeescript version of colorwheel.js. 2011-04-22 17:39:51 +02:00
rgieseke 3717373bc4 Add Coffeescript version of arguments.js. 2011-04-22 17:39:51 +02:00
Weston Ruter ffd38ad225 Adding extract-text.js example 2011-04-12 22:58:26 -07:00
Ariya Hidayat c1781944c7 Remove unfinished browsermode example. 2011-04-09 23:36:28 -07: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
Gabor Torok 6e485df72a added example for waitFor function 2011-04-04 21:14:02 -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
Ariya Hidayat 28929a3069 follow.coffee: CoffeeScript version of follow.js. 2011-03-12 10:45:56 -08:00
Ariya Hidayat f32c232cb0 follow.js: Adding lojjic. 2011-03-12 10:20:04 -08:00
Ariya Hidayat 1df1bc9590 follow.js: Find the number of twitter following and followers. 2011-03-10 21:43:37 -08:00
Ariya Hidayat 158362ed16 Start to implement support for CoffeeScript. 2011-03-02 00:59:07 -08:00
Ariya Hidayat 3e60ae6b9b Show tweets from SenchaInc instead. 2011-03-02 00:59:07 -08:00
Ariya Hidayat e15834522d colorwheel.js: Example on using Canvas to produce the color wheel. 2011-02-17 00:38:44 -08:00
Ariya Hidayat 32c5f02f2b QUnit driver should not print the status multiple times.
If the test suite reloads the page over and over again, only one
final message should be displayed. Detect this by adding one more
state to the logic.
2011-01-28 08:43:18 -08:00
Ariya Hidayat 4de99130c5 Add driver for running QUnit test suite.
Courtesy of Łukasz Korecki (https://gist.github.com/796548).
2011-01-27 22:38:58 -08: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
Ariya Hidayat 4113063283 direction.js: Fix the logic and simplify the extraction. 2011-01-02 10:39:50 -08:00
Ariya Hidayat 3a0d0886b6 Provide an API to get PhantomJS version. 2011-01-01 08:29:03 -08:00
Ariya Hidayat 0110913c1f Fix the logic structure in the weather example. 2010-12-31 22:17:51 -08:00
Ariya Hidayat 04cc4193ca Change phantom.storage to phantom.state. 2010-12-31 22:09:02 -08:00
Ariya Hidayat 24d433ea13 Remove phantom.log, just use the de-facto console.log for logging. 2010-12-31 20:10:34 -08:00
Ariya Hidayat a2bec750cd technews.js: Snap Google News Sci/Tech as image. 2010-12-31 19:35:38 -08:00
Ariya Hidayat c5de293368 rasterize.js: Rasterize HTML/XML/SVG document to an image. 2010-12-31 18:27:15 -08:00
Ariya Hidayat a75e67a041 run-jasmine.js: Drive Jasmine-based tests. 2010-12-31 17:05:36 -08:00
Ariya Hidayat b2d8eca8c4 direction.js: Get driving direction using Google Maps Directions API. 2010-12-30 00:12:25 -08:00
Ariya Hidayat 4df6976427 movies.js: List movies from kids-in-mind.com. 2010-12-28 21:15:36 -08:00
Ariya Hidayat d528b30ae6 seasonfood.js: List seasonal food from BBC GoodFood. 2010-12-28 20:26:39 -08:00
Ariya Hidayat d5b905a8ee ipgeocode.js: JSONP example with IP geocoding. 2010-12-28 00:10:12 -08:00
Ariya Hidayat bcfcdea810 weather.js: Weather forecast from Google. 2010-12-27 22:40:26 -08:00
Ariya Hidayat 2153e5ebea fibo.js: Fibonacci sequence 2010-12-27 22:04:04 -08:00
Ariya Hidayat d8a5c2b7d0 tweets.js: Inevitable example of showing twitter status. 2010-12-26 23:46:50 -08:00
Ariya Hidayat 9d7e4b4156 pizza.js: Fantastico! 2010-12-26 23:32:51 -08:00
Ariya Hidayat 5346072a90 useragent.js: Custom user agent example. 2010-12-26 23:12:31 -08:00
Ariya Hidayat 064ffa84f2 loadspeed.js: Measure page loading time. 2010-12-26 22:48:10 -08:00
Ariya Hidayat 160c4128d8 arguments.js: Dump all arguments passed to the script. 2010-12-26 22:40:07 -08:00
Ariya Hidayat 5c05acd986 countdown.js: Playing the launch center... 2010-12-26 22:23:17 -08:00
Ariya Hidayat 8e74533ec0 hello.js: the simplest PhantomJS example. 2010-12-26 22:15:02 -08:00