function loadScriptsPromise(scriptNames, base)
{
    /** @type {!Array.<!Promise.<string>>} */
    var promises = [];
    /** @type {!Array.<string>} */
    var urls = [];
    var sources = new Array(scriptNames.length);
    var scriptToEval = 0;
    for (var i = 0; i < scriptNames.length; ++i) {
        var scriptName = scriptNames[i];
        var sourceURL = (base || self._importScriptPathPrefix) + scriptName;
        var schemaIndex = sourceURL.indexOf("://") + 3;
        sourceURL = sourceURL.substring(0, schemaIndex) + normalizePath(sourceURL.substring(schemaIndex));
        if (_loadedScripts[sourceURL])
            continue;
        urls.push(sourceURL);
        promises.push(loadResourcePromise(sourceURL).then(scriptSourceLoaded.bind(null, i), scriptSourceLoaded.bind(null, i, undefined)));
    }
    return Promise.all(promises).then(undefined);

    /**
     * @param {number} scriptNumber
     * @param {string=} scriptSource
     */
    function scriptSourceLoaded(scriptNumber, scriptSource)
    {
        sources[scriptNumber] = scriptSource || "";
        // Eval scripts as fast as possible.
        while (typeof sources[scriptToEval] !== "undefined") {
            evaluateScript(urls[scriptToEval], sources[scriptToEval]);
            ++scriptToEval;
        }
    }

    /**
     * @param {string} sourceURL
     * @param {string=} scriptSource
     */
    function evaluateScript(sourceURL, scriptSource)
    {
        _loadedScripts[sourceURL] = true;
        if (!scriptSource) {
            // Do not reject, as this is normal in the hosted mode.
            console.error("Empty response arrived for script '" + sourceURL + "'");
            return;
        }
        self.eval(scriptSource + "\n//# sourceURL=" + sourceURL);
    }
}
@param {!Array.<string>} scriptNames
@param {string=} base
@return {!Promise.<undefined>}