Let abort always exist, but we can't guarantee it will do anything.

This commit is contained in:
ccd0 2019-03-24 03:41:01 -07:00
parent 8cfd16f0a4
commit 695e995dce
2 changed files with 7 additions and 4 deletions

View File

@ -204,8 +204,7 @@ ThreadWatcher =
abort: ->
for req in ThreadWatcher.requests when !req.finished
req.finished = true
try
req.abort?()
req.abort()
ThreadWatcher.clearRequests()
initLastModified: ->

View File

@ -82,6 +82,7 @@ CrossOrigin =
val = header[i+1..].trim()
@responseHeaders[key] = val
(@responseHeaders or {})[headerName.toLowerCase()] ? null
abort: ->
# Attempts to fetch `url` in JSON format using cross-origin privileges, if available.
# Interface is a subset of that of $.ajax.
@ -93,7 +94,7 @@ CrossOrigin =
# `status` - HTTP status (0 if connection not successful)
# `statusText` - HTTP status text
# `response` - decoded response body
# `abort` - if present, can be called to abort the request
# `abort` - function for aborting the request (silently fails on some platforms)
# `getResponseHeader` - function for reading response headers
ajax: (url, options={}, extra={}) ->
{onloadend, timeout} = options
@ -127,7 +128,10 @@ CrossOrigin =
onabort: -> req.onloadend()
ontimeout: -> req.onloadend()
}
req.abort = gmReq.abort
if typeof gmReq.abort is 'function'
req.abort = ->
try
gmReq.abort()
<% } %>
<% if (type === 'crx') { %>