blob: e6c17149a4813f8e2e981494e88391d0ddabd119 [file] [log] [blame]
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="resources/model-utils.js"></script>
<style>
model {
position: absolute;
top: 0;
left: 0;
width: 400px;
height: 400px;
}
</style>
<script>
const dragModel = async (model) => {
const bounds = model.getBoundingClientRect();
const startPoint = new DOMPoint(
bounds.x + bounds.width / 2,
bounds.y + bounds.height / 2
);
const endPoint = new DOMPoint(
startPoint.x + bounds.width / 4,
startPoint.y + bounds.height / 4
);
return new Promise((resolve, reject) => {
if (!("eventSender" in window)) {
reject();
return;
}
eventSender.mouseMoveTo(startPoint.x, startPoint.y);
eventSender.mouseDown();
eventSender.mouseMoveTo(endPoint.x, endPoint.y);
eventSender.mouseUp();
resolve();
});
};
promise_test(async test => {
const model = await readyModel(test);
model.interactive = false;
const cameraBeforeDrag = await model.getCamera();
await dragModel(model);
const cameraAfterDrag = await model.getCamera();
assert_cameras_are_equal(cameraAfterDrag, cameraBeforeDrag, "cameras before and after drag match");
}, "Dragging over a <model> has no effect on the camera when interactive is false");
promise_test(async test => {
const model = await readyModel(test);
model.interactive = true;
const cameraBeforeDrag = await model.getCamera();
await dragModel(model);
const cameraAfterDrag = await model.getCamera();
assert_cameras_are_not_equal(cameraAfterDrag, cameraBeforeDrag, "cameras before and after drag are different");
}, "Dragging over a <model> affects the camera when interactive is true");
promise_test(async test => {
const model = await readyModel(test, { interactive: true });
const cameraBeforeDrag = await model.getCamera();
await dragModel(model);
const cameraAfterDrag = await model.getCamera();
assert_cameras_are_not_equal(cameraAfterDrag, cameraBeforeDrag, "cameras before and after drag are different");
}, "Dragging over a <model> affects the camera when interactive is set to true using the HTML attribute as the element is created");
</script>
</body>
</html>