blob: 09811f90ed8bd57b205383de612d314afa848f9c [file] [edit]
<!DOCTYPE html>
<html>
<head>
<style>
p {
font-size: 20px;
width: 100px;
text-align: center;
display: inline-block;
}
</style>
</head>
<body>
<p>foobar</p>
<div>Has "Translate" item? <span id="has-translate"></span></div>
<div>Has "Look Up" item? <span id="has-look-up"></span></div>
<div>Has "Search the Web" item? <span id="has-search"></span></div>
<script>
function hasMenuItemContainingTitle(items, titleToQuery)
{
for (let item of items) {
let title = item.title || item;
if (title.includes?.(titleToQuery))
return true;
}
return false;
}
onload = async () => {
if (!window.testRunner)
return;
testRunner.waitUntilDone();
let paragraph = document.querySelector("p");
let boundingRect = paragraph.getBoundingClientRect();
await eventSender.asyncMouseMoveTo(boundingRect.left + boundingRect.width / 2, boundingRect.top + boundingRect.height / 2);
items = eventSender.contextClick();
document.getElementById("has-look-up").textContent = hasMenuItemContainingTitle(items, "Look Up");
document.getElementById("has-translate").textContent = hasMenuItemContainingTitle(items, "Translate");
document.getElementById("has-search").textContent = hasMenuItemContainingTitle(items, "Search the Web");
paragraph.remove();
testRunner.notifyDone();
}
</script>
</body>
</html>