<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../utils.js"></script>
<script>

'use strict';

target_test((target, test) => {
    target.style.touchAction = "none";
    const eventTracker = new EventTracker(target, ["pointerover", "pointerenter", "pointerdown", "pointermove", "pointerup", "pointerout", "pointerleave"]);

    const one = ui.finger();
    const two = ui.finger();
    const three = ui.finger();
    ui.sequence([
        one.begin({ x: 10, y: 10 }),
        two.begin({ x: 50, y: 50 }),
        two.move({ x: 70, y: 70 }),
        one.move({ x: 30, y: 30 }),
        one.end(),
        two.move({ x: 50, y: 50 }),
        two.end(),
        three.begin({ x: 10, y: 10 }),
        three.end(),
    ]).then(() => {
        eventTracker.assertMatchesEvents([
            // Yielded by one.begin({ x: 10, y: 10 }).
            { id: 1, type: "pointerover", x: 10, y: 10, isPrimary: true },
            { id: 1, type: "pointerenter", x: 10, y: 10, isPrimary: true },
            { id: 1, type: "pointerdown", x: 10, y: 10, isPrimary: true },
            // Yielded by two.begin({ x: 50, y: 50 }).
            { id: 2, type: "pointerover", x: 50, y: 50, isPrimary: false },
            { id: 2, type: "pointerenter", x: 50, y: 50, isPrimary: false },
            { id: 2, type: "pointerdown", x: 50, y: 50, isPrimary: false },
            // Yielded by two.move({ x: 70, y: 70 }).
            { id: 2, type: "pointermove", x: 70, y: 70, isPrimary: false },
            // Yielded by one.move({ x: 30, y: 30 }).
            { id: 1, type: "pointermove", x: 30, y: 30, isPrimary: true },
            // Yielded by one.end().
            { id: 1, type: "pointerup", x: 30, y: 30, isPrimary: true },
            { id: 1, type: "pointerout", x: 30, y: 30, isPrimary: true },
            { id: 1, type: "pointerleave", x: 30, y: 30, isPrimary: true },
            // Yielded by two.move({ x: 50, y: 50 }).
            { id: 2, type: "pointermove", x: 50, y: 50, isPrimary: false },
            // Yielded by two.end().
            { id: 2, type: "pointerup", x: 50, y: 50, isPrimary: false },
            { id: 2, type: "pointerout", x: 50, y: 50, isPrimary: false },
            { id: 2, type: "pointerleave", x: 50, y: 50, isPrimary: false },
            // Yielded by three.begin({ x: 10, y: 10 }).
            { id: 3, type: "pointerover", x: 10, y: 10, isPrimary: true },
            { id: 3, type: "pointerenter", x: 10, y: 10, isPrimary: true },
            { id: 3, type: "pointerdown", x: 10, y: 10, isPrimary: true },
            // Yielded by three.end().
            { id: 3, type: "pointerup", x: 10, y: 10, isPrimary: true },
            { id: 3, type: "pointerout", x: 10, y: 10, isPrimary: true },
            { id: 3, type: "pointerleave", x: 10, y: 10, isPrimary: true },
        ]);
        test.done();
    });
}, "The first touch of a touch sequence has isPrimary = true.");

</script>
</body>
</html>