head.js (936B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * Creates a new Taskbar Tab within the registry, and asserts that it does not 9 * already exist. 10 * 11 * (This function is also in xpcshell/head.js.) 12 * 13 * @param {TaskbarTabsRegistry|TaskbarTabs} aRegistry 14 * The registry to create the taskbar tab in. 15 * @param {...*} args 16 * Arguments to findOrCreateTaskbarTab. 17 * @returns {TaskbarTab} 18 * The newly-created taskbar tab. 19 */ 20 function createTaskbarTab(aRegistry, ...args) { 21 let result = aRegistry.findOrCreateTaskbarTab(...args); 22 function check({ taskbarTab, created }) { 23 Assert.ok(created, "Created taskbar tab did not exist before"); 24 return taskbarTab; 25 } 26 27 if (result.then) { 28 return result.then(check); 29 } 30 31 return check(result); 32 }