Return dummy response to user scripts after all request listeners run.
Move readyState to HEADERS_RECEIVED. This is only effective for xhr response.
Move readyState to LOADING. This is only effective for xhr response.
When called in xspy's response listener, return modified response to user script. This callback is useful for asynchronous operation.
Listen XHR/fetch request to be dispatched from user script and modify/view request as you like. This listener behaves differently when defined as 1 parameter function or 2 parameters function.
When second parameter sendResponse
is specified as a function argument,
original request stops until sendResponse
is called in listener function.
Listen on XHR/fetch response returned from a server to modify/view response as you like. This listener behaves differently when defined as 2 parameter function or 3 parameters function.
When third parameter next
is specified as a function argument,
user scripts will not receive response until next
is called in listener function.
Generated using TypeDoc
When called in xspy's request listener, immediately return fake response without dispatching request to external network after all listeners run.
You can move readyState one by one by calling
callback.moveToHeaderReceived
and/orcallback.moveToLoading
.Return fake response step by step with simulating loading.
xspy.onRequest(function listenerForRequest(request, sendResponse){ if(request.ajaxType === "xhr"){ sendResponse.moveToHeaderReceived({ headers: {"content-type": "application/json"}, status: 200, statusText: "OK", }); sendResponse.moveToLoading({ headers: {"content-type": "application/json"}, status: 200, statusText: "OK", responseText: "{'result':" }); sendResponse({ ajaxType: "xhr", status: 200, statusText: "OK", headers: {"content-type": "application/json"}, response: {result: 3}, responseType: "json", responseText: "{'result':3}", }); } });