Commit 449985ba authored by Son Nguyen's avatar Son Nguyen
Browse files

Fix the bug in the behat step "I wait until the page is ready"

Bug 1422498

Change-Id: I3eec78722856eaac9d492cf93eaff7f39520ce94
parent 6b30d1de
......@@ -152,6 +152,12 @@ function displayMessage(message, type, hideprevmsg) {
}
}
/**
* This variable determines the completeness of a json request
* = true if the request is still in progress
*/
var isRequestStillProcessing = false;
/* Display a nice little loading notification */
function processingStart(msg) {
if (!msg) {
......@@ -163,11 +169,15 @@ function processingStart(msg) {
DIV(msg)
);
showElement('loading-box');
isRequestStillProcessing = true;
}
/* Hide the loading notification */
function processingStop() {
hideElement('loading-box');
isRequestStillProcessing = false;
}
// End message related functions
......
......@@ -139,8 +139,6 @@ PieformManager = new PieformManager();
*/
function Pieform(data) {//{{{
var self = this;
this.SUBMITTING = 0;
this.COMPLETE = 1;
this.init = function() {//{{{
if (self.data.checkDirtyChange) {
......@@ -152,7 +150,6 @@ function Pieform(data) {//{{{
}//}}}
this.processForm = function(e) {//{{{
self.updateStatus(self.SUBMITTING);
PieformManager.signal('onsubmit', self.data.name);
// Call the presubmit callback, if there is one
......@@ -184,7 +181,6 @@ function Pieform(data) {//{{{
// If canceling the form, redirect away
if (data.returnCode == -2) {
window.location = data.location;
self.updateStatus(self.COMPLETE);
return;
}
......@@ -262,8 +258,6 @@ function Pieform(data) {//{{{
&& self.data.postSubmitCallback != '') {
window[self.data.postSubmitCallback]($(self.data.name), self.clickedButton, e);
}
self.updateStatus(self.COMPLETE);
}
}//}}}
......@@ -299,30 +293,6 @@ function Pieform(data) {//{{{
});
}//}}}
/**
* Update the status of processing pieform.
*
* @return Boolean - True if succeeded
*/
this.updateStatus = function(status) {
if (self.data.name !== false) {
switch (status) {
case self.SUBMITTING:
SubmittingPieforms.push(self.data.name);
return true;
break;
case self.COMPLETE:
var index = SubmittingPieforms.indexOf(self.data.name);
if (index >= 0) {
SubmittingPieforms.splice(index, 1);
return true;
}
break;
}
}
return false;
};
// A reference to the iframe that submissions are made through
this.iframe = null;
......@@ -335,9 +305,3 @@ function Pieform(data) {//{{{
addLoadEvent(self.init);
}//}}}
/**
* @var SubmittingPieforms - The keys are the list of all submitting pieforms.
* @type Object
*/
SubmittingPieforms = [];
......@@ -53,7 +53,7 @@ class BehatBase extends Behat\MinkExtension\Context\RawMinkContext {
/**
* The JS code to check that the page is ready.
*/
const PAGE_READY_JS = '(SubmittingPieforms && SubmittingPieforms.length === 0) && (document.readyState === "complete")';
const PAGE_READY_JS = '(isRequestStillProcessing === false) && (document.readyState === "complete")';
/**
* @var Escaper
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment