Skip to content

Commit

Permalink
Merge pull request #4748 from w3c/chromium-export-try
Browse files Browse the repository at this point in the history
Update a few pointerevent test and the automations
  • Loading branch information
jeffcarp committed Feb 6, 2017
2 parents d60e6d7 + 75438e0 commit 4c44212
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
Expand Up @@ -39,15 +39,13 @@ <h4>
window.onload = function() {
on_event(captureButton, 'pointerdown', function(event) {
detected_pointertypes[event.pointerType] = true;
sPointerCapture(event);
target0.setPointerCapture(event.pointerId);
});

on_event(target0, 'gotpointercapture', function(e) {
log("gotpointercapture", target1);
setTimeout(function() {
isDisconnected = true;
target0.parentNode.removeChild(target0);
}, 250);
isDisconnected = true;
target0.parentNode.removeChild(target0);
});

on_event(target0, 'lostpointercapture', function(e) {
Expand All @@ -63,7 +61,6 @@ <h4>
test(function() {
// TA: 11.3
assert_true(isDisconnected, "lostpointercapture must be fired on the document");

}, "lostpointercapture is dispatched on the document");
test_lostpointercapture.done();
});
Expand Down
Expand Up @@ -11,20 +11,24 @@
<!-- Additional helper script for common checks across event types -->
<script type="text/javascript" src="pointerevent_support.js"></script>
<script type="text/javascript">
var test_pointerEvent;
var detected_pointertypes = {};
var test_pointerEvent = async_test("lostpointercapture: subsequent events to target."); // set up test harness
// showPointerTypes is defined in pointerevent_support.js
// Requirements: the callback function will reference the test_pointerEvent object and
// will fail unless the async_test is created with the var name "test_pointerEvent".
add_completion_callback(showPointerTypes);

var captured_event;
var captured_event = null;
var test_done = false;
var overEnterEventsFail = false;
var outLeaveEventsFail = false;
var f_gotPointerCapture = false;
var f_lostPointerCapture = false;

function resetTestState() {
captured_event = null;
test_done = false;
overEnterEventsFail = false;
outLeaveEventsFail = false;
f_gotPointerCapture = false;
f_lostPointerCapture = false;
}

function listenerEventHandler(event) {
if (test_done)
return;
Expand All @@ -39,18 +43,18 @@
check_PointerEvent(event);
}
else if(event.type == "pointerover" || event.type == "pointerenter") {
if(!overEnterEventsFail) {
if(captured_event && !overEnterEventsFail) {
test(function() {
assert_true(f_gotPointerCapture, "pointerover/enter should not be received when the target doesn't have capture and pointer is not over it.");
}, "pointerover/enter should not be received when the target doesn't have capture and pointer is not over it.");
assert_false(f_gotPointerCapture, "pointerover/enter should be received before the target receives gotpointercapture even when the pointer is not over it.");
}, expectedPointerType + " pointerover/enter should be received before the target receives gotpointercapture even when the pointer is not over it.");
overEnterEventsFail = true;
}
}
else if(event.type == "pointerout" || event.type == "pointerleave") {
if(!outLeaveEventsFail) {
test(function() {
assert_true(f_lostPointerCapture, "pointerout/leave should not be received unless the target just lost the capture.");
}, "pointerout/leave should not be received unless the target just lost the capture.");
}, expectedPointerType + " pointerout/leave should not be received unless the target just lost the capture.");
outLeaveEventsFail = true;
}
}
Expand All @@ -63,7 +67,7 @@
// if any other events are received after releaseCapture, then the test fails
test(function () {
assert_unreached(event.target.id + "-" + event.type + " should be handled by target element handler");
}, "No other events should be recieved by capturing node after release");
}, expectedPointerType + " No other events should be recieved by capturing node after release");
}
}
}
Expand All @@ -75,7 +79,7 @@
if(event.type != "pointerout" && event.type != "pointerleave") {
test(function () {
assert_unreached("The Target element should not have received any events while capture is active. Event recieved:" + event.type + ". ");
}, "The target element should not receive any events while capture is active");
}, expectedPointerType + " The target element should not receive any events while capture is active");
}
}

Expand All @@ -90,13 +94,14 @@
assert_equals(event.pointerId, captured_event.pointerId, "pointerID is same for event captured and after release");
});
if (event.type == "pointerup") {
test_pointerEvent.done(); // complete test
test_done = true;
test_pointerEvent.done(); // complete test
}
}
}

function run() {
test_pointerEvent = setup_pointerevent_test("got/lost pointercapture: subsequent events to target", ALL_POINTERS); // set up test harness
var listener = document.getElementById("listener");
var target0 = document.getElementById("target0");
target0.style["touchAction"] = "none";
Expand All @@ -110,6 +115,7 @@
</script>
</head>
<body onload="run()">
<h2 id="pointerTypeDescription"></h2>
<div id="listener"></div>
<h1>Pointer Event: releasePointerCapture() - subsequent events follow normal hitting testing mechanisms</h1>
<h4>
Expand Down

0 comments on commit 4c44212

Please sign in to comment.