Functions that will likely never be implemented
->post
I have no use for it
...
sub post {
####
my ($self, $url, %options) = @_;
#my $b = $self->tab->{linkedBrowser};
$self->clear_current_form;
#my $flags = 0;
#if ($options{no_cache}) {
# $flags = $self->repl->constant('nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE');
#};
# If we don't have data, encode the parameters:
if( !$options{ data }) {
my $req= HTTP::Request::Common::POST( $url, $options{params} );
#warn $req->content;
carp "Faking content from parameters is not yet supported.";
#$options{ data } = $req->content;
};
#$options{ charset } ||= 'utf-8';
#$options{ headers } ||= {};
#$options{ headers }->{"Content-Type"} ||= "application/x-www-form-urlencoded";
#if( $options{ charset }) {
# $options{ headers }->{"Content-Type"} .= "; charset=$options{ charset }";
#};
# Javascript POST implementation taken from
# http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit
$self->eval(<<'JS', $url, $options{ params }, 'POST');
function (path, params, method) {
method = method || "post"; // Set method to post by default if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}
JS
####
# Now, how to trick Selenium into fetching the response?
}
####
plan skip_all => "POST requests via Selenium/ghostdriver/PhantomJS are currently unsupported :-/";