Skip to content

Commit

Permalink
codenvy-1871: avoid iframe script execution on source changes
Browse files Browse the repository at this point in the history
Signed-off-by: Ann Shumilova <[email protected]>
  • Loading branch information
ashumilova committed Mar 24, 2017
1 parent bbd0c1a commit 1daefae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dashboard/src/app/ide/ide-iframe/ide-iframe.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div flex class="animate-show">
<div flex class="animate-show" id="ide-application-frame">
<ide-iframe-button-link></ide-iframe-button-link>
<iframe class="ide-page-frame" ng-src="{{ideIframeLink}}"></iframe>
<iframe class="ide-page-frame" ng-src="{{ideIframeLink}}" ></iframe>
</div>
13 changes: 12 additions & 1 deletion dashboard/src/app/ide/ide.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import {CheAPI} from '../../components/api/che-api.factory';
import {CheWorkspace} from '../../components/api/che-workspace.factory';
import {RouteHistory} from '../../components/routing/route-history.service';
import {CheUIElementsInjectorService} from '../../components/injector/che-ui-elements-injector.service';

/**
* This class is handling the service for viewing the IDE
Expand All @@ -32,6 +33,7 @@ class IdeSvc {
proxySettings: any;
routeHistory: RouteHistory;
userDashboardConfig: any;
cheUIElementsInjectorService: CheUIElementsInjectorService;

ideParams: Map<string, string>;
lastWorkspace: any;
Expand All @@ -48,7 +50,7 @@ class IdeSvc {
constructor($location: ng.ILocationService, $log: ng.ILogService, $mdDialog: ng.material.IDialogService,
$q: ng.IQService, $rootScope: ng.IRootScopeService, $sce: ng.ISCEService, $timeout: ng.ITimeoutService,
$websocket: ng.websocket.IWebSocketProvider, cheAPI: CheAPI, cheWorkspace: CheWorkspace, lodash: any,
proxySettings: any, routeHistory: RouteHistory, userDashboardConfig: any) {
proxySettings: any, routeHistory: RouteHistory, userDashboardConfig: any, cheUIElementsInjectorService: CheUIElementsInjectorService) {
this.$location = $location;
this.$log = $log;
this.$mdDialog = $mdDialog;
Expand All @@ -63,6 +65,7 @@ class IdeSvc {
this.proxySettings = proxySettings;
this.routeHistory = routeHistory;
this.userDashboardConfig = userDashboardConfig;
this.cheUIElementsInjectorService = cheUIElementsInjectorService;

this.ideParams = new Map();

Expand Down Expand Up @@ -266,12 +269,20 @@ class IdeSvc {
this.ideParams.clear();
}

// perform remove of iframes in parent node. It's needed to avoid any script execution (canceled requests) on iframe source changes.
let iframeParent = angular.element('#ide-application-frame');
iframeParent.find('iframe').remove();

if (inDevMode) {
(this.$rootScope as any).ideIframeLink = this.$sce.trustAsResourceUrl(ideUrlLink + appendUrl);
} else {
(this.$rootScope as any).ideIframeLink = ideUrlLink + appendUrl;
}

// iframe element for IDE application:
let iframeElement = '<iframe class=\"ide-page-frame\" id=\"ide-application-iframe\" ng-src=\"{{ideIframeLink}}\" ></iframe>';
this.cheUIElementsInjectorService.injectAdditionalElement(iframeParent, iframeElement);

let defer = this.$q.defer();
if (workspace.status === 'RUNNING') {
defer.resolve();
Expand Down

0 comments on commit 1daefae

Please sign in to comment.