Commit edfade4b edfade4bc285a13c47f2f389001fb231db6e2e9b by Nicolas Perriault

better form submission in fill() by using events

1 parent 1cd41d0d
...@@ -740,6 +740,12 @@ Casper.prototype.fill = function fill(selector, vals, submit) { ...@@ -740,6 +740,12 @@ Casper.prototype.fill = function fill(selector, vals, submit) {
740 var method = (form.getAttribute('method') || "GET").toUpperCase(); 740 var method = (form.getAttribute('method') || "GET").toUpperCase();
741 var action = form.getAttribute('action') || "unknown"; 741 var action = form.getAttribute('action') || "unknown";
742 __utils__.log('submitting form to ' + action + ', HTTP ' + method, 'info'); 742 __utils__.log('submitting form to ' + action + ', HTTP ' + method, 'info');
743 var event = document.createEvent('Event');
744 event.initEvent('submit', true, true);
745 if (!form.dispatchEvent(event)) {
746 __utils__.log('unable to submit form', 'warning');
747 return;
748 }
743 if (typeof form.submit === "function") { 749 if (typeof form.submit === "function") {
744 form.submit(); 750 form.submit();
745 } else { 751 } else {
......