[Pkg-javascript-commits] [dojo] 72/149: refs #16138, add error listener for request/script

David Prévot taffit at moszumanska.debian.org
Sat Feb 27 03:13:49 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository dojo.

commit 6fe6d9b7465c8cea7e69594816e2bf6d1aa94372
Author: Nick Nisi <nick at nisi.org>
Date:   Fri Sep 11 09:23:48 2015 -0700

    refs #16138, add error listener for request/script
---
 request/script.js            |  5 +++++
 tests/unit/request/script.js | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/request/script.js b/request/script.js
index e9882ed..749c783 100644
--- a/request/script.js
+++ b/request/script.js
@@ -162,6 +162,11 @@ define([
 			}
 		}
 
+		on.once(node, 'error', function (error) {
+			dfd.reject(error);
+			script._remove(dfd.id, options.frameDoc, true);
+		});
+
 		watch(dfd);
 
 		return returnDeferred ? dfd : dfd.promise;
diff --git a/tests/unit/request/script.js b/tests/unit/request/script.js
index 03e9369..8b3b8fe 100644
--- a/tests/unit/request/script.js
+++ b/tests/unit/request/script.js
@@ -46,6 +46,23 @@ define([
 			);
 		},
 
+		'script error event': function () {
+			var def = this.async();
+
+			script.get('/__services/non-existent-script', {
+				jsonp: 'callback',
+				timeout: 3000 // timeout for old IE
+			}).then(def.reject, def.callback(function (error) {
+				if (error.type) {
+					assert.strictEqual(error.type, 'error');
+				}
+				else {
+					// old IE doesn't emit an error event, timeout instead
+					assert.instanceOf(error, RequestTimeoutError);
+				}
+			}));
+		},
+
 		jsonp: function () {
 			var def = this.async();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list