<!doctype html>
<style>
body {margin: 0; width: 280px;}
a {font-size: 30px; font-family: Ahem;}
a:focus {outline: 5px solid orange;}
</style>
<a dir="rtl" id="a" href="#">عربية and עברית</a><a href="#" id="b" style="color: pink">bb</a><br>
<a href="#" id="c" style="color: lightgreen;">cc</a>
<div id="spacer" tabindex="0" style="margin-bottom: 120vh">
For rtl-text, when going downwards and the first fragment is hidden, the first *visible* fragment becomes origin, not the first fragment.
</div>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
a.focus();
window.scroll(0, 45);
// Now only #a's second fragment is visible.
var resultMap = [
["Down", "c"], // #c is closest to the visible fragment.
["Up", "a"], // Focus and scroll all of #a into view.
["Down", "b"], // Now that all of #a is visible, we search from the first fragment.
];
document.getElementById("a").focus();
snav.assertFocusMoves(resultMap);
</script>