Closed Bug 757888 Opened 12 years ago Closed 7 years ago

ENH: Expose 'abort' into XHR and Request modules

Categories

(Add-on SDK Graveyard :: General, enhancement, P2)

enhancement

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: glind, Unassigned)

References

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")}
  });
Whiteboard: [good first bug]
Because of the difficulty finding mentors and the expected life span of the SDK, we are removing [good first bug] from remaining SDK bugs.
Whiteboard: [good first bug]
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.