Commit 2fb88bb8 authored by Liviu Tinta's avatar Liviu Tinta Committed by Commit Bot

Use integer coordinates for Actions.pointerMove.

The 2 tests were failing on wpt.fyi because the coordinates passed to Actions.pointerMove were not integers (like on local run). Since Actions.pointerMove expects integer coordinates, the tests were failing with an exception.
Use Math.ceil on coordinates passed to Actions.pointerMove. Apply memory leak fix.

Bug: 810882
Change-Id: I399f763fa03ebd98167fd060ad1769e8dd7f9d30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132950
Commit-Queue: Liviu Tinta <liviutinta@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755524}
parent b77ab3ce
...@@ -48,59 +48,58 @@ ...@@ -48,59 +48,58 @@
<wc-wc id="wc-wc"></wc-wc> <wc-wc id="wc-wc"></wc-wc>
<div id="log"></div> <div id="log"></div>
<script> <script>
var logDiv = document.getElementById("log"); function onLoad(){
function logMessage(message){ var logDiv = document.getElementById("log");
var log = document.createElement("div"); function logMessage(message){
var messageNode = document.createTextNode(message); var log = document.createElement("div");
log.appendChild(messageNode); var messageNode = document.createTextNode(message);
logDiv.appendChild(log); log.appendChild(messageNode);
} logDiv.appendChild(log);
var events = [];
var content = document.getElementById("wc-wc")
.shadowRoot.getElementById("content");
content.addEventListener("pointerdown", function(e){
content.setPointerCapture(e.pointerId);
events.push("pointerdown@content");
});
content.addEventListener("gotpointercapture", function(e){
logMessage("Pointer was captured by custom element's Shadow DOM!");
events.push("gotpointercapture@content");
});
content.addEventListener("pointerup", function(e){
content.releasePointerCapture(e.pointerId);
events.push("pointerup@content");
});
content.addEventListener("lostpointercapture", function(e){
logMessage("Pointer was released by custom element's Shadow DOM!");
events.push("lostpointercapture@content");
if(window.promise_test && wc_shadow_dom_test){
wc_shadow_dom_test.step(function(){
assert_array_equals(events, ["pointerdown@content",
"gotpointercapture@content", "pointerup@content",
"lostpointercapture@content"]);
resolve_test();
wc_shadow_dom_test.done();
});
} }
}); var events = [];
var wc_shadow_dom_test = null; var content = document.getElementById("wc-wc")
var resolve_test = null; .shadowRoot.getElementById("content");
var reject_test = null;
function cleanup(){ content.addEventListener("pointerdown", function(e){
events = []; content.setPointerCapture(e.pointerId);
shadow_dom_test = null; events.push("pointerdown@content");
resolve_test = null; });
reject_test = null; content.addEventListener("gotpointercapture", function(e){
} logMessage("Pointer was captured by custom element's Shadow DOM!");
events.push("gotpointercapture@content");
});
content.addEventListener("pointerup", function(e){
content.releasePointerCapture(e.pointerId);
events.push("pointerup@content");
});
content.addEventListener("lostpointercapture", function(e){
logMessage("Pointer was released by custom element's Shadow DOM!");
events.push("lostpointercapture@content");
if(window.promise_test && wc_shadow_dom_test){
wc_shadow_dom_test.step(function(){
assert_array_equals(events, ["pointerdown@content",
"gotpointercapture@content", "pointerup@content",
"lostpointercapture@content"]);
resolve_test();
});
}
});
function onLoad(){ var wc_shadow_dom_test = null;
var resolve_test = null;
var reject_test = null;
function cleanup(){
events = [];
shadow_dom_test = null;
resolve_test = null;
reject_test = null;
}
if(window.promise_test){ if(window.promise_test){
promise_test(function(t){ promise_test(async function(t){
return new Promise(function(resolve, reject){ var actions_promise;
return new Promise(async function(resolve, reject){
wc_shadow_dom_test = t; wc_shadow_dom_test = t;
resolve_test = resolve; resolve_test = resolve;
reject_test = reject; reject_test = reject;
...@@ -109,11 +108,14 @@ ...@@ -109,11 +108,14 @@
}); });
var contentRect = content.getBoundingClientRect(); var contentRect = content.getBoundingClientRect();
var actions = new test_driver.Actions(); var actions = new test_driver.Actions();
var actions_promise = actions actions_promise = actions
.pointerMove(contentRect.x, contentRect.y) .pointerMove(Math.ceil(contentRect.x), Math.ceil(contentRect.y))
.pointerDown({button: actions.ButtonType.LEFT}) .pointerDown({button: actions.ButtonType.LEFT})
.pointerUp({button: actions.ButtonType.LEFT}) .pointerUp({button: actions.ButtonType.LEFT})
.send(); .send();
}).then(async()=>{
await actions_promise;
t.done();
}); });
}, "PointerCapture works for custom element Shadow DOM."); }, "PointerCapture works for custom element Shadow DOM.");
} }
......
...@@ -34,64 +34,64 @@ ...@@ -34,64 +34,64 @@
<div id="shadowhost"></div> <div id="shadowhost"></div>
<div id="log"></div> <div id="log"></div>
<script> <script>
var logDiv = document.getElementById("log"); function onLoad(){
function logMessage(message){ var logDiv = document.getElementById("log");
var log = document.createElement("div"); function logMessage(message){
var messageNode = document.createTextNode(message); var log = document.createElement("div");
log.appendChild(messageNode); var messageNode = document.createTextNode(message);
logDiv.appendChild(log); log.appendChild(messageNode);
} logDiv.appendChild(log);
var events = []; }
var events = [];
var host = document.getElementById("shadowhost"); var host = document.getElementById("shadowhost");
var shadowRoot = host.attachShadow({mode: "open"}); var shadowRoot = host.attachShadow({mode: "open"});
var template = document.getElementById("template"); var template = document.getElementById("template");
var node = template.content.cloneNode(true); var node = template.content.cloneNode(true);
shadowRoot.appendChild(node); shadowRoot.appendChild(node);
var content = host.shadowRoot.getElementById("content"); var content = host.shadowRoot.getElementById("content");
content.addEventListener("pointerdown", function(e){ content.addEventListener("pointerdown", function(e){
content.setPointerCapture(e.pointerId); content.setPointerCapture(e.pointerId);
events.push("pointerdown@content"); events.push("pointerdown@content");
}); });
content.addEventListener("gotpointercapture", function(e){ content.addEventListener("gotpointercapture", function(e){
logMessage("Pointer was captured by Shadow DOM!"); logMessage("Pointer was captured by Shadow DOM!");
events.push("gotpointercapture@content"); events.push("gotpointercapture@content");
}); });
content.addEventListener("pointerup", function(e){ content.addEventListener("pointerup", function(e){
content.releasePointerCapture(e.pointerId); content.releasePointerCapture(e.pointerId);
events.push("pointerup@content"); events.push("pointerup@content");
}); });
content.addEventListener("lostpointercapture", function(e){ content.addEventListener("lostpointercapture", function(e){
logMessage("Pointer was released by Shadow DOM!"); logMessage("Pointer was released by Shadow DOM!");
events.push("lostpointercapture@content"); events.push("lostpointercapture@content");
if(window.promise_test && shadow_dom_test){ if(window.promise_test && shadow_dom_test){
shadow_dom_test.step(function(){ shadow_dom_test.step(function(){
assert_array_equals(events, ["pointerdown@content", assert_array_equals(events, ["pointerdown@content",
"gotpointercapture@content", "pointerup@content", "gotpointercapture@content", "pointerup@content",
"lostpointercapture@content"]); "lostpointercapture@content"]);
resolve_test(); resolve_test();
shadow_dom_test.done(); });
}); }
} });
});
var shadow_dom_test = null; var shadow_dom_test = null;
var resolve_test = null; var resolve_test = null;
var reject_test = null; var reject_test = null;
function cleanup(){ function cleanup(){
events = []; events = [];
shadow_dom_test = null; shadow_dom_test = null;
resolve_test = null; resolve_test = null;
reject_test = null; reject_test = null;
} }
function onLoad(){
if(window.promise_test){ if(window.promise_test){
promise_test(function(t){ promise_test(async function(t){
return new Promise(function(resolve, reject){ var actions_promise;
return new Promise(async function(resolve, reject){
shadow_dom_test = t; shadow_dom_test = t;
resolve_test = resolve; resolve_test = resolve;
reject_test = reject; reject_test = reject;
...@@ -100,11 +100,14 @@ ...@@ -100,11 +100,14 @@
}); });
var contentRect = content.getBoundingClientRect(); var contentRect = content.getBoundingClientRect();
var actions = new test_driver.Actions(); var actions = new test_driver.Actions();
var actions_promise = actions actions_promise = actions
.pointerMove(contentRect.x, contentRect.y) .pointerMove(Math.ceil(contentRect.x), Math.ceil(contentRect.y))
.pointerDown({button: actions.ButtonType.LEFT}) .pointerDown({button: actions.ButtonType.LEFT})
.pointerUp({button: actions.ButtonType.LEFT}) .pointerUp({button: actions.ButtonType.LEFT})
.send(); .send();
}).then(async ()=>{
await actions_promise;
t.done();
}); });
}, "PointerCapture works for Shadow DOM element."); }, "PointerCapture works for Shadow DOM element.");
} }
......
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