Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js

Issue 60203010: XHR.abort(): no event dispatching in completed/non-started states. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js
diff --git a/LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js b/LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js
index 6051b0d51588eba5daad76a2857d2a7d70c4320c..6ee6173b529402a2a76a123e61699cb3f81fbd42 100644
--- a/LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js
+++ b/LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout.js
@@ -193,16 +193,21 @@ AbortedRequest.prototype = {
req.ontimeout = handleEvent;
req.timeout = TIME_REGULAR_TIMEOUT;
- var _this = this;
function abortReq() {
- req.abort();
+ if (me.request.readyState == XMLHttpRequest.DONE || me.request.readyState > XMLHttpRequest.OPENED) {
tyoshino (SeeGerritForStatus) 2013/11/07 13:38:05 maybe this should be me.request.readyState < XMLHt
sof 2013/11/07 14:34:14 Much better, that was the intent & close enough (i
+ if (me.abortDelay > TIME_REGULAR_TIMEOUT)
+ me.timeoutEventFired()
+ else
+ me.noEventsFired();
+ } else
+ req.abort();
}
if (!this.shouldAbort) {
self.setTimeout(function() {
try {
- _this.noEventsFired();
+ me.noEventsFired();
}
catch (e) {
ok(false, "Unexpected error: " + e);
@@ -232,6 +237,14 @@ AbortedRequest.prototype = {
},
/**
+ * Ensure that an event fired, our timeout event.
+ */
+ timeoutEventFired: function() {
+ ok(this.hasFired && this.eventFired == "timeout", "A timeout event should have fired");
+ TestCounter.testComplete();
+ },
+
+ /**
* Get a message describing this test.
*
* @returns {String} The test description.
@@ -243,20 +256,17 @@ AbortedRequest.prototype = {
/**
* Check the event received, and if it's the right (and only) one we get.
*
- * WebKit fires abort events even for DONE and UNSENT states, which is
- * discussed in http://webkit.org/b/98404
- * That's why we chose to accept secondary "abort" events in this test.
- *
* @param {DOMProgressEvent} evt An event of type "load" or "timeout".
*/
handleEvent: function(evt) {
- if (this.hasFired && evt.type != "abort") {
- ok(false, "Only abort event should fire: " + this.getMessage());
+ if (this.hasFired) {
+ ok(false, "Only one event should fire: " + this.getMessage());
return;
}
- var expectedEvent = (this.abortDelay >= TIME_REGULAR_TIMEOUT && !this.hasFired) ? "timeout" : "abort";
+ var expectedEvent = (this.abortDelay >= TIME_REGULAR_TIMEOUT) ? "timeout" : "abort";
this.hasFired = true;
+ this.eventFired = evt.type;
is(evt.type, expectedEvent, this.getMessage());
TestCounter.testComplete();
}

Powered by Google App Engine
This is Rietveld 408576698