guacamole-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmuehl...@apache.org
Subject [1/2] incubator-guacamole-client git commit: GUACAMOLE-105: Clean up download iframe only after download has truly completed. If completion cannot be determined, wait a reasonable amount of time before assuming completion.
Date Sat, 05 Nov 2016 05:31:24 GMT
Repository: incubator-guacamole-client
Updated Branches:
  refs/heads/master 2dd1b322c -> 3f43653a1


GUACAMOLE-105: Clean up download iframe only after download has truly completed. If completion
cannot be determined, wait a reasonable amount of time before assuming completion.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/92886e63
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/92886e63
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/92886e63

Branch: refs/heads/master
Commit: 92886e639d1aebdd3b3305e99d757ccf335281db
Parents: 2dd1b32
Author: Michael Jumper <mjumper@apache.org>
Authored: Fri Nov 4 20:50:37 2016 -0700
Committer: Michael Jumper <mjumper@apache.org>
Committed: Fri Nov 4 20:50:37 2016 -0700

----------------------------------------------------------------------
 .../webapp/app/rest/services/tunnelService.js   | 25 ++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/92886e63/guacamole/src/main/webapp/app/rest/services/tunnelService.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/rest/services/tunnelService.js b/guacamole/src/main/webapp/app/rest/services/tunnelService.js
index 0029650..e736f82 100644
--- a/guacamole/src/main/webapp/app/rest/services/tunnelService.js
+++ b/guacamole/src/main/webapp/app/rest/services/tunnelService.js
@@ -44,6 +44,17 @@ angular.module('rest').factory('tunnelService', ['$injector',
     var document = $window.document;
 
     /**
+     * The number of milliseconds to wait after a stream download has completed
+     * before cleaning up related DOM resources, if the browser does not
+     * otherwise notify us that cleanup is safe.
+     *
+     * @private
+     * @constant
+     * @type Number
+     */
+    var DOWNLOAD_CLEANUP_WAIT = 5000;
+
+    /**
      * Makes a request to the REST API to get the list of all tunnels
      * associated with in-progress connections, returning a promise that
      * provides an array of their UUIDs (strings) if successful.
@@ -189,6 +200,7 @@ angular.module('rest').factory('tunnelService', ['$injector',
         // Create temporary hidden iframe to facilitate download
         var iframe = document.createElement('iframe');
         iframe.style.position = 'fixed';
+        iframe.style.border = 'none';
         iframe.style.width = '1px';
         iframe.style.height = '1px';
         iframe.style.left = '-1px';
@@ -197,11 +209,20 @@ angular.module('rest').factory('tunnelService', ['$injector',
         // The iframe MUST be part of the DOM for the download to occur
         document.body.appendChild(iframe);
 
-        // Automatically remove iframe from DOM when download completes
-        stream.onend = function downloadComplete() {
+        // Automatically remove iframe from DOM when download completes, if
+        // browser supports tracking of iframe downloads via the "load" event
+        iframe.onload = function downloadComplete() {
             document.body.removeChild(iframe);
         };
 
+        // Automatically remove iframe from DOM a few seconds after the stream
+        // ends, in the browser does NOT fire the "load" event for downloads
+        stream.onend = function downloadComplete() {
+            $window.setTimeout(function cleanupIframe() {
+                document.body.removeChild(iframe);
+            }, DOWNLOAD_CLEANUP_WAIT);
+        };
+
         // Begin download
         iframe.src = url;
 


Mime
View raw message