async function dispatchFill(settings, request, allFrames, allowForeign, allowNoSecret) {
    request = Object.assign(helpers.deepCopy(request), {
        allowForeign: allowForeign,
        allowNoSecret: allowNoSecret,
        foreignFills: settings.foreignFills[settings.origin] || {},
    });

    let perFrameResults = await chrome.scripting.executeScript({
        target: { tabId: settings.tab.id, allFrames: allFrames },
        func: function (request) {
            return window.browserpass.fillLogin(request);
        },
        args: [request],
    });

    // merge filled fields into a single array
    let filledFields = perFrameResults
        .reduce((merged, frameResult) => merged.concat(frameResult.result.filledFields), [])
        .filter((val, i, merged) => val && merged.indexOf(val) === i);

    // if user answered a foreign-origin confirmation,
    // store the answers in the settings
    let foreignFillsChanged = false;
    for (let frame of perFrameResults) {
        if (typeof frame.foreignFill !== "undefined") {
            if (typeof settings.foreignFills[settings.origin] === "undefined") {
                settings.foreignFills[settings.origin] = {};
            }
            settings.foreignFills[settings.origin][frame.foreignOrigin] = frame.foreignFill;
            foreignFillsChanged = true;
        }
    }
    if (foreignFillsChanged) {
        await saveSettings(settings);
    }

    return filledFields;
}
Call injected code to fill the form

@param object  settings      Settings object
@param object  request       Request details
@param boolean allFrames     Dispatch to all frames
@param boolean allowForeign  Allow foreign-origin iframes
@param boolean allowNoSecret Allow forms that don't contain a password field
@return array list of filled fields