e);

    triggerMQLEvent(mql);
    await waitForChangesReported();
    assert_equals(calls, 2, "triggerMQLEvent");

    mql.dispatchEvent(new Event("change"));
    assert_equals(calls, 4, "dispatchEvent");
}, "listener added with addListener and addEventListener (capture) is called twice");

promise_test(async t => {
    const mql = await createMQL(t);

    let calls = 0;
    const listener = {
        handleEvent() {
            calls++;
        },
    };

    mql.addListener(listener);
    mql.removeEvent