The goog.net.MockIFrameIo Class

goog.net.MockIFrameIo
> goog.events.EventTarget
> goog.Disposable

goog.net.MockIFrameIo(testQueue)

Mock implenetation of goog.net.IframeIo. This doesn't provide a mock implementation for all cases, but it's not too hard to add them as needed.

testQueue {goog.testing.TestQueue}
Test queue for inserting test events.

.abort(opt_failureCode)

Simulates aborting the current Iframe request.

opt_failureCode {goog.net.ErrorCode=}
Optional error code to use - defaults to ABORT.

.addEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched. Supported for legacy but use goog.events.listen(src, type, handler) instead.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.dispatchEvent(e)

Inherited from goog.events.EventTarget .

Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object. If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.

e {string|Object|goog.events.Event}
Event object.
returns {boolean}
If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.

.dispose()

Inherited from goog.Disposable .

Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.

returns {void}
Nothing.

.getErrorChecker()

Gets the callback function used to check if a loaded IFrame is in an error state.

returns {Function}
A callback that expects a document object as it's single argument.

.getLastCustomError()

Gets the last custom error.

returns {Object}
Last custom error.

.getLastError()

Gets the last error message.

returns {string}
Last error message.

.getLastErrorCode()

Gets the last error code.

returns {goog.net.ErrorCode}
Last error code.

.getLastUri()

Get the uri of the last request.

returns {goog.Uri}
Uri of last request.

.getParentEventTarget()

Inherited from goog.events.EventTarget .

Returns the parent of this event target to use for bubbling.

returns {goog.events.EventTarget}
The parent EventTarget or null if there is no parent.

.getResponseJson()

Parses the content as JSON. This is a safe parse and may throw an error if the response is malformed.

returns {Object}
The parsed content.

.getResponseText()

Returns the last response text (i.e. the text content of the iframe). Assumes plain text!

returns {string}
Result from the server.

.getTimeoutInterval()

Returns the number of milliseconds after which an incomplete request will be aborted, or 0 if no timeout is set.

returns {number}
Timeout interval in milliseconds.

.isActive()

returns {boolean}
True if a transfer is in progress.

.isComplete()

returns {boolean}
True if transfer is complete.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.isSuccess()

returns {boolean}
True if transfer was successful.

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.removeEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.send(uri, opt_method, opt_noCache, opt_data)

Simulates the iframe send.

uri {goog.Uri|string}
Uri of the request.
opt_method {string=}
Default is GET, POST uses a form to submit the request.
opt_noCache {boolean=}
Append a timestamp to the request to avoid caching.
opt_data {Object|goog.structs.Map=}
Map of key-value pairs.

.sendFromForm(form, opt_uri, opt_noCache)

Simulates the iframe send from a form.

form {Element}
Form element used to send the request to the server.
opt_uri {string=}
Uri to set for the destination of the request, by default the uri will come from the form.
opt_noCache {boolean=}
Append a timestamp to the request to avoid caching.

.setErrorChecker(fn)

Sets the callback function used to check if a loaded IFrame is in an error state.

fn {Function}
Callback that expects a document object as it's single argument.

.setParentEventTarget(parent)

Inherited from goog.events.EventTarget .

Sets the parent of this event target to use for bubbling.

parent {goog.events.EventTarget?}
Parent EventTarget (null if none).

.setTimeoutInterval(ms)

Sets the number of milliseconds after which an incomplete request will be aborted and a {@link goog.net.EventType.TIMEOUT} event raised; 0 means no timeout is set.

ms {number}
Timeout interval in milliseconds; 0 means none.

.simulateDone(errorCode)

Simulates the iframe is done.

errorCode {goog.net.ErrorCode}
The error code for any error that should be simulated.

.simulateIncrementalData(data)

Simulates receive of incremental data.

data {Object}
Data.

.simulateReady()

Simulates the IFrame is ready for the next request.