diff --git a/bundles/org.eclipse.orion.client.core/web/orion/operationsClient.js b/bundles/org.eclipse.orion.client.core/web/orion/operationsClient.js index 4cc1df0e54..6f7fbbb771 100644 --- a/bundles/org.eclipse.orion.client.core/web/orion/operationsClient.js +++ b/bundles/org.eclipse.orion.client.core/web/orion/operationsClient.js @@ -1,6 +1,6 @@ /******************************************************************************* * @license - * Copyright (c) 2011, 2014 IBM Corporation and others. + * Copyright (c) 2011, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution @@ -120,7 +120,9 @@ define(['i18n!orion/operations/nls/messages', "orion/Deferred"], function(messag } } } - that._preferenceService.put(NAMESPACE, globalOperations).then(def.resolve, def.reject); + // overriding the preference key's value completely so set it to clear + var options = { clear: true }; + that._preferenceService.put(NAMESPACE, globalOperations, options).then(def.resolve, def.reject); }); }; }(def), function(def) { diff --git a/bundles/org.eclipse.orion.client.ui/web/js-tests/ui/operations/operationsClientTests.js b/bundles/org.eclipse.orion.client.ui/web/js-tests/ui/operations/operationsClientTests.js new file mode 100644 index 0000000000..972e97854e --- /dev/null +++ b/bundles/org.eclipse.orion.client.ui/web/js-tests/ui/operations/operationsClientTests.js @@ -0,0 +1,47 @@ +/******************************************************************************* + * @license + * Copyright (c) 2017 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License v1.0 + * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution + * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). + * + * Contributors: IBM Corporation - initial API and implementation + * Google Inc. - Casey Flynn (caseyflynn@google.com) + ******************************************************************************/ +/*eslint-env browser, amd, mocha*/ +define([ + "chai/chai", + "orion/bootstrap", + 'orion/serviceregistry', + "orion/operationsClient", + "orion/progress", + "mocha/mocha" +], function(chai, mBootstrap, mServiceRegistry, mOperationsClient, mProgress) { + var assert = chai.assert; + + describe("Operations Client", function() { + it("Bug 510646", function(finished) { + mBootstrap.startup().then(function(core) { + var serviceRegistry = core.serviceRegistry; + var operationsClient = new mOperationsClient.OperationsClient(serviceRegistry); + var progressService = new mProgress.ProgressService(serviceRegistry, operationsClient); + var operation = {}; + operation.Location = "/task/temp/bug510646"; + operation.expires = 0; + operation.Name = "test"; + operation.progressMonitor = {}; + operation.progressMonitor.progress = function() {}; + progressService.writeOperation(0, operation); + return operationsClient.removeCompletedOperations() + .then(function() { + return operationsClient.getOperations(); + }) + .then(function(operations) { + assert.equal(Object.keys(operations).length, 0); + finished(); + }); + }) + }); + }); +}); diff --git a/bundles/org.eclipse.orion.client.ui/web/js-tests/ui/uiTests.html b/bundles/org.eclipse.orion.client.ui/web/js-tests/ui/uiTests.html index 471016fe53..10d3d02e2b 100644 --- a/bundles/org.eclipse.orion.client.ui/web/js-tests/ui/uiTests.html +++ b/bundles/org.eclipse.orion.client.ui/web/js-tests/ui/uiTests.html @@ -32,6 +32,7 @@ "js-tests/ui/globalSearch/globalSearchTests", "js-tests/ui/HTMLTemplates/HTMLTemplateTests", "js-tests/ui/objects/objectsTests", + "js-tests/ui/operations/operationsClientTests", "js-tests/ui/pageUtil/pageUtilTests", "js-tests/ui/searchCrawler/searchCrawlerTests", "js-tests/ui/settings/settingsTests",