function fillLogin(request) {
        var result = {
            filledFields: [],
            foreignFill: undefined,
        };

        // get the login form
        let loginForm = undefined;
        if (request.fields.includes("openid")) {
            // this is an attempt to fill a form containing only openid field
            loginForm = form(OPENID_FIELDS);
        } else {
            // this is an attempt to fill a regular login form
            loginForm = form(INPUT_FIELDS);
        }

        // don't attempt to fill non-secret forms unless non-secret filling is allowed
        if (!request.allowNoSecret && !find(PASSWORD_FIELDS, loginForm)) {
            return result;
        }

        // ensure the origin is the same, or ask the user for permissions to continue
        if (window.location.origin !== request.origin) {
            if (!request.allowForeign || request.foreignFills[window.location.origin] === false) {
                return result;
            }
            var message =
                "You have requested to fill login credentials into an embedded document from a " +
                "different origin than the main document in this tab. Do you wish to proceed?\n\n" +
                `Tab origin: ${request.origin}\n` +
                `Embedded origin: ${window.location.origin}`;
            if (request.foreignFills[window.location.origin] !== true) {
                result.foreignOrigin = window.location.origin;
                result.foreignFill = confirm(message);
                if (!result.foreignFill) {
                    return result;
                }
            }
        }

        // fill login field
        if (
            request.fields.includes("login") &&
            update(USERNAME_FIELDS, request.login.fields.login, loginForm)
        ) {
            result.filledFields.push("login");
        }

        // fill secret field
        if (
            request.fields.includes("secret") &&
            update(PASSWORD_FIELDS, request.login.fields.secret, loginForm)
        ) {
            result.filledFields.push("secret");
        }

        // fill openid field
        if (
            request.fields.includes("openid") &&
            update(OPENID_FIELDS, request.login.fields.openid, loginForm)
        ) {
            result.filledFields.push("openid");
        }

        // finished filling things successfully
        return result;
    }
Fill password

@since 3.0.0

@param object request Form fill request
@return object result of filling a form