mirror of
https://github.com/gchq/CyberChef
synced 2025-01-14 21:43:54 +00:00
Abort the previous bake when attempting the next autobake
This commit is contained in:
parent
33a473c09b
commit
a81b2064d4
3 changed files with 54 additions and 1 deletions
|
@ -160,7 +160,12 @@ class App {
|
|||
// has completed.
|
||||
if (this.autoBakePause) return false;
|
||||
|
||||
if (this.autoBake_ && !this.baking) {
|
||||
if (this.baking) {
|
||||
this.manager.worker.cancelBakeForAutoBake();
|
||||
this.baking = false;
|
||||
}
|
||||
|
||||
if (this.autoBake_) {
|
||||
log.debug("Auto-baking");
|
||||
this.manager.worker.bakeInputs({
|
||||
nums: [this.manager.tabs.getActiveTab("input")],
|
||||
|
|
|
@ -322,6 +322,28 @@ class WorkerWaiter {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the current bake making it possible to autobake again
|
||||
*/
|
||||
cancelBakeForAutoBake() {
|
||||
if (this.totalOutputs > 1) {
|
||||
this.cancelBake();
|
||||
} else {
|
||||
// In this case the UI changes can be skipped
|
||||
|
||||
for (let i = this.chefWorkers.length - 1; i >= 0; i--) {
|
||||
if (this.chefWorkers[i].active) {
|
||||
this.removeChefWorker(this.chefWorkers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.inputs = [];
|
||||
this.inputNums = [];
|
||||
this.totalOutputs = 0;
|
||||
this.loadingOutputs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the current bake by terminating and removing all ChefWorkers
|
||||
*
|
||||
|
|
|
@ -167,6 +167,32 @@ module.exports = {
|
|||
browser.expect.element("#output-text .cm-status-bar .eol-value").text.to.equal("LF");
|
||||
},
|
||||
|
||||
"Autobaking the latest input": browser => {
|
||||
// Use the sleep recipe to simulate a long running task
|
||||
utils.loadRecipe(browser, "Sleep", "input", [2000]);
|
||||
|
||||
browser.waitForElementVisible("#stale-indicator");
|
||||
|
||||
// Enable previously disabled autobake
|
||||
browser.click("#auto-bake-label");
|
||||
|
||||
browser
|
||||
.sendKeys("#input-text .cm-content", "1");
|
||||
|
||||
browser.pause(500);
|
||||
|
||||
// Make another change while the previous input is being baked
|
||||
browser
|
||||
.sendKeys("#input-text .cm-content", "2");
|
||||
|
||||
browser
|
||||
.waitForElementNotVisible("#stale-indicator")
|
||||
.waitForElementNotVisible("#output-loader");
|
||||
|
||||
// Ensure we got the latest input baked
|
||||
utils.expectOutput(browser, "input12");
|
||||
},
|
||||
|
||||
"Special content": browser => {
|
||||
/* Special characters are rendered correctly */
|
||||
utils.setInput(browser, SPECIAL_CHARS, false);
|
||||
|
|
Loading…
Reference in a new issue