addons/web/static/tests/helpers/test_utils_mock.js
/**
 * intercepts an event bubbling up the widget hierarchy. The event intercepted
 * must be a "custom event", i.e. an event generated by the method 'trigger_up'.
 *
 * Note that this method really intercepts the event if @propagate is not set.
 * It will not be propagated further, and even the handlers on the target will
 * not fire.
 *
 * @param {Widget} widget the target widget (any Odoo widget)
 * @param {string} eventName description of the event
 * @param {function} fn callback executed when the even is intercepted
 * @param {boolean} [propagate=false]
 */
intercepts an event bubbling up the widget hierarchy. The event intercepted
must be a "custom event", i.e. an event generated by the method 'trigger_up'.

Note that this method really intercepts the event if @propagate is not set.
It will not be propagated further, and even the handlers on the target will
not fire.

@param {Widget} widget the target widget (any Odoo widget)
@param {string} eventName description of the event
@param {function} fn callback executed when the even is intercepted
@param {boolean} [propagate=false]
intercepts an event bubbling up the widget hierarchy . The event intercepted must be a " custom event " i . e . an event generated by the method ' trigger_up ' . Note that this method really intercepts the event if @propagate is not set . It will not be propagated further and even the handlers on the target will not fire . @param { Widget } widget the target widget ( any Odoo widget ) @param { string } eventName description of the event @param { function } fn callback executed when the even is intercepted @param { boolean } [ propagate = false ]
function intercept(widget, eventName, fn, propagate) {
    var _trigger_up = widget._trigger_up.bind(widget);
    widget._trigger_up = function (event) {
        if (event.name === eventName) {
            fn(event);
            if (!propagate) { return; }
        }
        _trigger_up(event);
    };
}
function intercept ( widget , eventName , fn , propagate ) { var _trigger_up = widget . _trigger_up . bind ( widget ) ; widget . _trigger_up = function ( event ) { if ( event . name === eventName ) { fn ( event ) ; if ( ! propagate ) { return ; } } _trigger_up ( event ) ; } ; }
intercepts an event bubbling up the widget hierarchy.
intercepts an event bubbling up the widget hierarchy .