From 773ed6d91e11b1e9af6c4d6a5324e2472d5dc600 Mon Sep 17 00:00:00 2001 From: ronkorving Date: Sat, 8 Jun 2013 14:53:02 +0900 Subject: [PATCH 1/4] Added abort-after-timeout test. Fixed a typo in abort-after-receive. --- XMLHttpRequest/abort-after-receive.htm | 2 +- XMLHttpRequest/abort-after-timeout.htm | 43 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 XMLHttpRequest/abort-after-timeout.htm diff --git a/XMLHttpRequest/abort-after-receive.htm b/XMLHttpRequest/abort-after-receive.htm index 736d289c9b6db3..44a02ba66af9f6 100644 --- a/XMLHttpRequest/abort-after-receive.htm +++ b/XMLHttpRequest/abort-after-receive.htm @@ -29,7 +29,7 @@ client.onabort = test.step_func(function () { // this should not fire! - assert_unreached("abort should not cause the about event to fire"); + assert_unreached("abort() should not cause the abort event to fire"); }); client.open("GET", "resources/well-formed.xml", true); diff --git a/XMLHttpRequest/abort-after-timeout.htm b/XMLHttpRequest/abort-after-timeout.htm new file mode 100644 index 00000000000000..985c77270f3dbd --- /dev/null +++ b/XMLHttpRequest/abort-after-timeout.htm @@ -0,0 +1,43 @@ + + + + XMLHttpRequest: abort() after successful receive should not fire "abort" event + + + + + +
+ + + From c7c09f6594e1ef3896a1ca16d1bf9115333bd8ea Mon Sep 17 00:00:00 2001 From: ronkorving Date: Sat, 8 Jun 2013 14:55:49 +0900 Subject: [PATCH 2/4] Fixed title. --- XMLHttpRequest/abort-after-timeout.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XMLHttpRequest/abort-after-timeout.htm b/XMLHttpRequest/abort-after-timeout.htm index 985c77270f3dbd..e4a8e7dcfc9cf2 100644 --- a/XMLHttpRequest/abort-after-timeout.htm +++ b/XMLHttpRequest/abort-after-timeout.htm @@ -1,7 +1,7 @@ - XMLHttpRequest: abort() after successful receive should not fire "abort" event + XMLHttpRequest: abort() after a timeout should not fire "abort" event From 8b5cae96fbcbe6395eca880850ccd07a3da71e07 Mon Sep 17 00:00:00 2001 From: ronkorving Date: Sat, 8 Jun 2013 15:08:04 +0900 Subject: [PATCH 3/4] Added an assertion that timeout actually happens. --- XMLHttpRequest/abort-after-timeout.htm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/XMLHttpRequest/abort-after-timeout.htm b/XMLHttpRequest/abort-after-timeout.htm index e4a8e7dcfc9cf2..717457f339c408 100644 --- a/XMLHttpRequest/abort-after-timeout.htm +++ b/XMLHttpRequest/abort-after-timeout.htm @@ -16,6 +16,8 @@ // the download would otherwise take 500ms // we check after 300ms to make sure abort does not fire an "abort" event + var timeoutFired = false; + var client = new XMLHttpRequest(); client.timeout = 100; @@ -24,11 +26,16 @@ client.abort(); + assert_true(timeoutFired); assert_equals(client.readyState, 0); test.done(); }), 300); + client.ontimeout = function () { + timeoutFired = true; + }; + client.onabort = test.step_func(function () { // this should not fire! From 7c58d190b4dfbd85b3c6d93d89bf0b5020eee76e Mon Sep 17 00:00:00 2001 From: ronkorving Date: Sat, 8 Jun 2013 15:12:37 +0900 Subject: [PATCH 4/4] Added an assertion to see if timeout is a supported feature to begin with. --- XMLHttpRequest/abort-after-timeout.htm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/XMLHttpRequest/abort-after-timeout.htm b/XMLHttpRequest/abort-after-timeout.htm index 717457f339c408..74c6e85bd9176f 100644 --- a/XMLHttpRequest/abort-after-timeout.htm +++ b/XMLHttpRequest/abort-after-timeout.htm @@ -19,14 +19,18 @@ var timeoutFired = false; var client = new XMLHttpRequest(); + + assert_true('timeout' in client, 'xhr.timeout is not supported in this user agent'); + client.timeout = 100; setTimeout(test.step_func(function() { + assert_true(timeoutFired); + // abort should not cause the "abort" event to fire client.abort(); - assert_true(timeoutFired); assert_equals(client.readyState, 0); test.done();