Commit Graph

36 Commits (e8b565547441f050e39562006fdd9e091b14a76d)

Author SHA1 Message Date
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 b0a5b6dbad Every web page gets its own network access manager.
Network-related activites should not be shared between web page
instances. Otherwise, it is extremely confusing when there are two (or
more) web pages are active at the same time.

http://code.google.com/p/phantomjs/issues/detail?id=190
2011-09-14 23:46:01 -07:00
Ariya Hidayat ac9be2a0d4 Sort the include files alphabetically. 2011-09-14 21:47:36 -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
Ariya Hidayat 6fe972d0a8 Implement WebPage's release() function in pure C++. 2011-08-23 18:53:53 -07:00
Ariya Hidayat 52746493c4 Remove useless extra empty line. 2011-08-20 23:45:21 -07:00
Ariya Hidayat 699f4f76f2 Fix coding style (no tab, 4 spaces). 2011-08-20 22:34:11 -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
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
Kapil Reddy 6e39625ecf added scrollPosition support in c++ version 2011-07-22 13:41:30 +05:30
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 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
Ariya Hidayat 6e2b362850 Change scriptLookupDir to libraryPath. 2011-06-17 20:52:19 -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
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
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 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
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 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 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 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 a65ae9b1a8 Reenable custom network access manager. 2011-05-26 01:56:43 -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
Ivan De Marino 8ed9dc1c44 Adding forgotten Include Guards. 2011-04-09 19:49:22 +01:00
Ivan De Marino be72a29c9f Propagated License Headers. 2011-04-09 18:34:04 +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