ENH: Expose 'abort' into XHR and Request modules

RESOLVED INCOMPLETE

Status

P2
enhancement
RESOLVED INCOMPLETE
6 years ago
11 months ago

People

(Reporter: glind, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

See:  http://pastebin.mozilla.org/1648603 for possible implementation.


Use case: aborting requests.  onComplete is too late.
So with that pastebin Gregg linked to applied to my SDK, my simple addon ( http://pastebin.mozilla.org/1648605 ) fires the onComplete function on line 4, logs the response.status as "0", then throws an error about response.json being undefined. 
I'm not really sure if that's what's supposed to happen when you abort() a request ( http://www.w3.org/TR/XMLHttpRequest/#the-abort-method ), but the request clearly doesn't complete. :)
Severity: normal → enhancement
OS: Mac OS X → All
Hardware: x86 → All
I certainly wouldn't complain if all the "endings" (ERROR, ABORT, CANCEL) were listenable :)  It seems like the module as written goes to a lot of trouble to hide the xhr request from introspection (during runRequest), which makes Request harder to subclass.  

It would be nice if it was as easy as this:

  var AbortableRequest = Class({
    extends: Request,
    abort:  function(){console.log("aborting"); this.xhr.abort();     this.emit("abort")}
  });

Updated

6 years ago
Priority: -- → P2
Whiteboard: [good first bug]

Comment 3

2 years ago
Because of the difficulty finding mentors and the expected life span of the SDK, we are removing [good first bug] from remaining SDK bugs.

Updated

2 years ago
Whiteboard: [good first bug]
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: NEW → RESOLVED
Last Resolved: 11 months ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.