<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<span inert id="not-editable" contenteditable>I'm not editable.</span>
<span id="editable" contenteditable>I'm editable.</span>
<script>
function clickOn(element)
{
return new Promise(function(resolve, reject) {
if (!window.eventSender)
reject();
var absoluteTop = 0;
var absoluteLeft = 0;
for (var parentNode = element; parentNode; parentNode = parentNode.offsetParent) {
absoluteLeft += parentNode.offsetLeft;
absoluteTop += parentNode.offsetTop;
}
var x = absoluteLeft + element.offsetWidth / 2;
var y = absoluteTop + element.offsetHeight / 2;
var pointerActions = [{
source: "mouse",
actions: [
{ name: "pointerMove", x: x, y: y },
{ name: "pointerDown", x: x, y: x },
{ name: "pointerUp" },
{ name: "pointerMove", x: 0, y: 0}
]
}];
chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve);
});
}
var notEditable = document.querySelector('#not-editable');
var editable = document.querySelector('#editable');
promise_test(async () => {
await clickOn(notEditable);
var oldValue = notEditable.textContent;
assert_equals(oldValue, "I'm not editable.");
eventSender.keyDown('a');
assert_equals(notEditable.textContent, oldValue);
}, "Can't edit inert contenteditable");
promise_test(async () => {
await clickOn(editable);
var oldValue = editable.textContent;
assert_equals(oldValue, "I'm editable.");
eventSender.keyDown('a');
assert_not_equals(editable.textContent, oldValue);
}, "Can edit non-inert contenteditable");
</script>
</body>
</html>