org.jboss.arquillian.graphene.request.RequestGuard Maven / Gradle / Ivy
/**
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.arquillian.graphene.request;
import org.jboss.arquillian.graphene.Graphene;
import org.jboss.arquillian.graphene.javascript.JavaScript;
/**
* Allows to manually retrieve information from Request Guard on a page.
*
* This method is used internally by:
*
*
* - {@link Graphene#guardHttp(Object)}
* - {@link Graphene#guardAjax(Object)}
* - {@link Graphene#guardNoRequest(Object)}
* - {@link Graphene#waitForHttp(Object)}
*
*
* @author Lukas Fryc
*/
@JavaScript(implementation = "org.jboss.arquillian.graphene.guard.RequestGuardImpl")
public interface RequestGuard {
/**
* @return the last request type
*/
RequestType getRequestType();
/**
* @return the state of last request
*/
RequestState getRequestState();
/**
* Clears the request type cache and returns the last request type
*
* @return the last request type
*/
RequestType clearRequestDone();
/**
*
* Specifies JavaScript implementation of filter, which declares what requests will be guarded.
*
*
*
* If the provided expression evaluates to false, a request won't be guarded.
*
*
*
* In a 'eval' expression, you can use following contextual information:
*
*
*
* - this.url - an URL
* - this.method - GET/POST
* - this.async - boolean expression determines whether a request is async
* - this.body - a content of a request
*
*
*
* Note that some values might need processing, for example body might be escaped:
*
*
*
* E.g.: unescape(this.body).indexOf('javax.faces.source=f:poll') > 0
*
*
*
* The expression above will detect, whether a request body contains some string.
*
*/
void filter(String eval);
/**
* Clear all filters defined by {@link #filter(String)}.
*/
void clearFilters();
/**
*
* Specifies maximum timeout (in miliseconds) for asynchronous scheduled callbacks which will be guarded (default: 50 ms).
*
*
*
* Asynchronous scheduled callbacks are callbacks which are scheduled in XMLHttpRequests's
* onreadystatechange callback.
*
*
*
* Usually are those callbacks scheduled for timeouts <= 50 just to postpone updates of user interface out of XHR
* processing.
*
*
*
*
* Be aware that sometimes it is inappropriate to guard asynchronous scheduled callbacks - in this case you can set this
* value to -1 in order to guarding of scheduled callbacks at all.
*
*/
void setMaximumCallbackTimeout(int miliseconds);
}