Skip to content

Commit

Permalink
fix #1317 page engine disposal of PageConfigHelper
Browse files Browse the repository at this point in the history
PageConfigHelper was instantiated but not disposed in the destructor.
the resolve() method of aria.utils.Path class had an inconsistency in description (doc) and implementation ("If not specified, window is used")
close #1317
  • Loading branch information
lsimone committed Oct 20, 2014
1 parent b7e3c1b commit cb36e4f
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/aria/pageEngine/PageEngine.js
Expand Up @@ -217,22 +217,30 @@ module.exports = Aria.classDefinition({
this._secondDiv.parentNode.removeChild(this._secondDiv);
this._secondDiv = null;
}
var siteConfigHelper = this._siteConfigHelper, cssLoader = ariaUtilsCSSLoader;
var siteConfigHelper = this._siteConfigHelper,
pageConfigHelper = this._pageConfigHelper,
cssLoader = ariaUtilsCSSLoader;
if (siteConfigHelper) {
cssLoader.remove(siteConfigHelper.getSiteCss());
siteConfigHelper.$dispose();

}
if (pageConfigHelper) {
pageConfigHelper.$dispose();
pageConfigHelper = null;
}
cssLoader.remove(this._previousPageCSS);
cssLoader.remove(this._currentPageCSS);
this._modulesInPage = null;
if (this._rootModule) {
this._rootModule.$dispose();
this._rootModule = null;
}
this._pageProvider.$removeListeners({
"pageDefinitionChange" : this._onPageDefinitionChangeListener
});
if (this._pageProvider) {
this._pageProvider.$removeListeners({
"pageDefinitionChange" : this._onPageDefinitionChangeListener
});
}
this._onPageDefinitionChangeListener = null;

},
Expand Down Expand Up @@ -485,6 +493,10 @@ module.exports = Aria.classDefinition({
* @protected
*/
_loadPageDependencies : function (args) {
if (!this._pageConfigHelper) {
this.$callback(args.cb);
return;
}
var dependencies = this._pageConfigHelper.getPageDependencies(args.lazy);
var pageCommonModules = this._siteConfigHelper.getCommonModulesDescription({
priority : 2,
Expand Down Expand Up @@ -552,6 +564,10 @@ module.exports = Aria.classDefinition({
* @protected
*/
_displayPage : function (args) {
if (!this._pageConfigHelper) {
this.$callback(args.cb);
return;
}
var pageConfig = args.pageConfig, cfg = pageConfig.pageComposition, pageId = pageConfig.pageId;
this.$raiseEvent({
name : "beforePageTransition",
Expand Down Expand Up @@ -696,6 +712,9 @@ module.exports = Aria.classDefinition({
* @protected
*/
_afterLazyDependenciesLoad : function () {
if (!this._pageConfigHelper) {
return;
}
var lazyPlaceholders = this._pageConfigHelper.getLazyPlaceholdersIds();
this._lazyContent = false;
this.$raiseEvent({
Expand Down
Expand Up @@ -35,5 +35,6 @@ Aria.classDefinition({
this.addTests("test.aria.pageEngine.pageEngine.issue770.GetContentTest");
this.addTests("test.aria.pageEngine.pageEngine.customRootModule.CustomRootModuleTestSuite");
this.addTests("test.aria.pageEngine.pageEngine.externalHashNavigation.ExternalHashNavigationTest");
this.addTests("test.aria.pageEngine.pageEngine.pageEngineDisposal.DisposalTest");
}
});
50 changes: 50 additions & 0 deletions test/aria/pageEngine/pageEngine/pageEngineDisposal/DisposalTest.js
@@ -0,0 +1,50 @@
/*
* Copyright 2014 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

Aria.classDefinition({
$classpath : "test.aria.pageEngine.pageEngine.pageEngineDisposal.DisposalTest",
$dependencies : ["aria.pageEngine.PageEngine", "test.aria.pageEngine.pageEngine.pageEngineDisposal.PageProvider"],
$extends : "aria.jsunit.TestCase",
$prototype : {

/**
* this test just checks if all the object instantiated by pageEngine and pageProvider are correctly disposed
*/
testAsyncDisposePageEngine : function () {
var document = Aria.$window.document;
var div = document.createElement("div");
div.id = "testId";
document.body.appendChild(div);

this.pageEngine = new aria.pageEngine.PageEngine();
this.pageProvider = new test.aria.pageEngine.pageEngine.pageEngineDisposal.PageProvider();

var startConfig = {
pageProvider : this.pageProvider,
oncomplete : {
fn : function () {
this.pageEngine.$dispose();
this.pageProvider.$dispose();
this.notifyTestEnd('testAsyncDisposePageEngine');
},
scope : this
}
};

this.pageEngine.start(startConfig);

}
}
});
26 changes: 26 additions & 0 deletions test/aria/pageEngine/pageEngine/pageEngineDisposal/MainLayout.tpl
@@ -0,0 +1,26 @@
/*
* Copyright 2014 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


{Template {
$classpath : "test.aria.pageEngine.pageEngine.pageEngineDisposal.MainLayout"
}}

{macro main ()}
DISPOSAL TEST
{/macro}


{/Template}
51 changes: 51 additions & 0 deletions test/aria/pageEngine/pageEngine/pageEngineDisposal/PageProvider.js
@@ -0,0 +1,51 @@
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Fake page processor
*/
Aria.classDefinition({
$classpath : "test.aria.pageEngine.pageEngine.pageEngineDisposal.PageProvider",
$implements : ["aria.pageEngine.pageProviders.PageProviderInterface"],
$prototype : {

/**
* @param {aria.pageEngine.CfgBeans.ExtendedCallback} callback
*/
loadSiteConfig : function (callback) {
this.$callback(callback.onsuccess, {
containerId : "testId"
});
},

/**
* @param {String} pageId Id of the page
* @param {aria.pageEngine.CfgBeans.ExtendedCallback} callback
*/
loadPageDefinition : function (pageId, callback) {
this.$callback(callback.onsuccess, {
pageId : "aaa",
pageComposition : {
template : "test.aria.pageEngine.pageEngine.pageEngineDisposal.MainLayout",
placeholders : {
"newsInfo" : {
"contentId" : "pgen_news_and_info"
}
}
}
});
}
}
});

0 comments on commit cb36e4f

Please sign in to comment.