* 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_.
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. :)
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.
* "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
* 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?)
* 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
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.
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.
* 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.
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");
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).
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(.....);
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.
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
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
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.
* "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"
* 'phantom.simulateMouseClick' accepts a 'selector' and clicks on every element that matches the selector
* Added a couple of 'qDebug()' to help debugging PhantomJS
* 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")
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.
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');
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.
If the javascript calls phantom.exit(), and afterwards
phantom.open(), if may happen that the open() triggers a
loadFinished() signal happens after Phantom was destroyed.
Result: Crash in Phantom::finish().
Workaround: Disconnect from loadFinished() when exit() is
called.
Was caught in exec(). Apparently, on Windows an exit()
cannot be scheduled before exec was called. Since
a timer based exit was already implemented, use that.