From 695e995dcead4d792d048f34e99e5544f6a9cb50 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 24 Mar 2019 03:41:01 -0700 Subject: [PATCH] Let abort always exist, but we can't guarantee it will do anything. --- src/Monitoring/ThreadWatcher.coffee | 3 +-- src/platform/CrossOrigin.coffee | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee index 32cc80b47..10f075fe4 100644 --- a/src/Monitoring/ThreadWatcher.coffee +++ b/src/Monitoring/ThreadWatcher.coffee @@ -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: -> diff --git a/src/platform/CrossOrigin.coffee b/src/platform/CrossOrigin.coffee index 9748df096..c8140348f 100644 --- a/src/platform/CrossOrigin.coffee +++ b/src/platform/CrossOrigin.coffee @@ -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') { %>