compareSnapshots_(normalButtonCanvas, pressedFocusedButtonCanvas, false, "Pressed focused buttons should look different from normal buttons.");
// Release.
sendMouseEvent("mouseup", button);
yield;
// make sure the button is focused as this doesn't happen on click on Mac
button.focus();
takeSnapshot(normalFocusedButtonCanvas);
compareSnapshots_(normalFocusedButtonCanvas, pressedFocusedButtonCanvas, false, "Pressed focused buttons should look different from normal focused buttons.");
// Unfocus the button.
sendMouseEvent("mousedown", outside);
sendMouseEvent("mouseup", outside);
yield;
// Press the label.
sendMouseEvent("mousemove", label);
sendMouseEvent("mousedown", label);
yield;
compareSnapshots_(normalButtonCanvas, currentSnapshot, false, "Pressing the label should have pressed the button.");
takeSnapshot(pressedButtonCanvas);
// Move the mouse down from the label.
sendMouseEvent("mousemove", outside);
yield;
compareSnapshots_(normalButtonCanvas, currentSnapshot, true, "Moving the mouse down from the label should have unpressed the button.");
// ... and up again.
sendMouseEvent("mousemove", label);
yield;
compareSnapshots_(pressedButtonCanvas, currentSnapshot, true, "Moving the mouse back on top of the label should have pressed the button.");
// Release.
sendMouseEvent("mouseup", label);
yield;
compareSnapshots_(normalFocusedButtonCanvas, currentSnapshot, true, "Releasing the mouse over the label should have unpressed (and focused) the button.");
// Press the label and remove it.
sendMouseEvent("mousemove", label);
sendMouseEvent("mousedown", label);
yield;
label.parentNode.removeChild(label);
yield;
compareSnapshots_(normalButtonCanvas, currentSnapshot, true, "Removing the label should have unpressed the button.");