ted();
        assert_equals(eventsCount, i);
    }
}, "listeners are called correct number of times");

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

    mql.addListener(() => {
        calls.push("1st");
    });
    mql.addListener(() => {
        calls.push("2nd");
    });

    triggerMQLEvent(mql);
    await waitForChangesReported();

    assert_array_equals(calls, ["1st", "2nd"]);
}, "listeners are called in order they were added");

promise_test(async t => {
    