Commit 9b7bafff authored by Ella Ge's avatar Ella Ge Committed by Commit Bot

Re-write test pointerevent_pointermove_in_pointerlock.html

The test was failing in wpt because it passing non-integer value to
test driver. This CL changes it to use "origin" instead.
This CL rewrites the test to makes it cleaner, instead of adding event
listener inside event listener.
This CL also changes the test to send the "move" events after receiving
pointerlockchange.

Bug: 986277
Change-Id: I0f51523c3c90791339877b2e51afa8e9a4cc9d4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717195Reviewed-by: default avatarLan Wei <lanwei@chromium.org>
Commit-Queue: Ella Ge <eirage@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680563}
parent 8d2e8733
......@@ -34,54 +34,58 @@
var target1 = innerframe.contentDocument.getElementById('target1');
innerframe.contentWindow.name = "innerframe";
on_event(document, "pointerlockchange", function(event) {
if (document.pointerLockElement == target0) {
on_event(target0, "pointermove", function (event) {
test_pointermove.step(function() {
assert_equals(event.view.name, "outerframe", "View attribute of pointermove should be the target frame.");
}, "View attribute of pointermove should be the target frame.");
document.exitPointerLock();
on_event(target0, "click", function(event) {
target0.requestPointerLock();
});
on_event(target1, "click", function(event) {
target1.requestPointerLock();
});
on_event(target1, "click", function(event) {
target1.requestPointerLock();
});
on_event(innerframe.contentDocument, "pointerlockchange", function(event) {
if (innerframe.contentDocument.pointerLockElement == target1) {
on_event(target1, "pointermove", function (event) {
innerframe_pointermoveReceived = true;
test_pointermove.step(function() {
assert_equals(event.view.name, "innerframe", "View attribute of pointermove should be the target frame.");
}, "View attribute of pointermove should be the target frame.");
innerframe.contentDocument.exitPointerLock();
test_pointermove.done();
});
}
});
});
on_event(target0, "pointermove", function (event) {
if (document.pointerLockElement == target0) {
test_pointermove.step(function() {
assert_equals(event.view.name, "outerframe", "View attribute of pointermove should be the target frame.");
}, "View attribute of pointermove should be the target frame.");
document.exitPointerLock();
// Click the inner frame target to lock.
clickInTarget("mouse", target1);
}
});
on_event(target0, "click", function(event) {
target0.requestPointerLock();
on_event(target1, "pointermove", function (event) {
if (innerframe.contentDocument.pointerLockElement == target1) {
test_pointermove.step(function() {
assert_equals(event.view.name, "innerframe", "View attribute of pointermove should be the target frame.");
}, "View attribute of pointermove should be the target frame.");
innerframe.contentDocument.exitPointerLock();
test_pointermove.done();
}
});
var x = innerframe.getBoundingClientRect().x + target1.getBoundingClientRect().x;
var y = innerframe.getBoundingClientRect().y + target1.getBoundingClientRect().y;
// Inject mouse input
new test_driver.Actions()
.pointerMove(5, 5, {origin: target0})
.pointerDown()
.pointerUp()
.pointerMove(100, 300, {origin: target0})
.pointerMove(x+10, y+10)
.pointerDown()
.pointerUp()
.pointerMove(5, 5, {origin: target0})
.send();
on_event(document, "pointerlockchange", function(event) {
if (document.pointerLockElement == target0) {
// Send moves in main frame target
new test_driver.Actions()
.pointerMove(10, 30, {origin: target0})
.pointerMove(20, 10, {origin: target0})
.send();
}
});
}
on_event(innerframe.contentDocument, "pointerlockchange", function(event) {
if (innerframe.contentDocument.pointerLockElement == target1) {
// Send moves in inner frame target
new test_driver.Actions()
.pointerMove(10, 30, {origin: target1})
.pointerMove(20, 10, {origin: target1})
.send();
}
});
// Click the outer frame target to lock.
clickInTarget("mouse", target0);
}
</script>
<div id="complete-notice">
</div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment