Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/layout/generic/test/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 3 kB image not shown  

Quelle  test_bug1644511.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/layout/generic/test/test_bug1644511.html


<!DOCTYPE html>
<meta charset="utf-8">
<title>Test for Bug 1644511</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<style>
  [contenteditable] {
    padding: .5em 40%;
  }
</style>

<div id="host" contenteditable="" dir="rtl">مرحبا عالم!<br>Hello World</div>

<button onclick="subtestLTR()"></button>

<script>
const caretMovementStyleFlag = "bidi.edit.caret_movement_style";

/**
 * Can't use synthesizeKey("KEY_Arrow*") as it triggers
 * nsFrameSelection::PhysicalMove() instead of CharacterMove() and thus
 * suppresses the flag. See also Bug 1644489.
 */
function moveCaret(aRight, aSelect) {
  const select = aSelect ? "selectChar" : "char";
  const dir = aRight ? "Next" : "Previous";
  SpecialPowers.doCommand(window, `cmd_${select}${dir}`);
}

/**
 * Safer to directly select text node when the paragraph ends with LTR text as
 * the left edge is the end of the paragraph and then also the start of the LTR
 * text.
 */
function putCaretInLastLine(div) {
  const { lastChild } = div;
  getSelection().collapse(lastChild, 1); // Pass 1 because of bug 1645877
}

// LTR behavior should be always same regardless of the flag
function subtestLTR() {
  putCaretInLastLine(host);
  moveCaret(true, true);
  is(getSelection().anchorOffset, 1, "Shift+ArrowRight should select from left");
  is(getSelection().focusOffset, 2, "Shift+ArrowRight should select to right");
  moveCaret(true, false);
  is(getSelection().anchorOffset, 2, "Collapsing by ArrowRight should put the caret to the right side");

  putCaretInLastLine(host);
  moveCaret(true, true);
  moveCaret(false, false);
  is(getSelection().anchorOffset, 1, "Collapsing by ArrowLeft should put the caret to the left side");
}

async function testLogicalMovement() {
  await SpecialPowers.pushPrefEnv({
    set: [[caretMovementStyleFlag, 0]]
  });
  getSelection().collapse(host);
  moveCaret(true, true);
  is(getSelection().anchorOffset, 0, "Shift+ArrowRight should select from right");
  is(getSelection().focusOffset, 1, "Shift+ArrowRight should select to left");
  moveCaret(true, false);
  is(getSelection().anchorOffset, 1, "Collapsing by ArrowRight should put the caret to the left side");

  getSelection().collapse(host);
  moveCaret(true, true);
  moveCaret(false, false);
  is(getSelection().anchorOffset, 0, "Collapsing by ArrowLeft should put the caret to the right side");

  subtestLTR();
}

async function testVisualMovement() {
  await SpecialPowers.pushPrefEnv({
    set: [[caretMovementStyleFlag, 1]]
  });
  getSelection().collapse(host);
  moveCaret(false, true);
  is(getSelection().anchorOffset, 0, "Shift+ArrowLeft should select from right");
  is(getSelection().focusOffset, 1, "Shift+ArrowLeft should select to left");
  moveCaret(false, false);
  is(getSelection().anchorOffset, 1, "Collapsing by ArrowLeft should put the caret to the left side");

  getSelection().collapse(host);
  moveCaret(false, true);
  moveCaret(true, false);
  is(getSelection().anchorOffset, 0, "Collapsing by ArrowRight should put the caret to the right side");

  subtestLTR();
}

async function testHybridMovement() {
  await SpecialPowers.pushPrefEnv({
    set: [[caretMovementStyleFlag, 2]]
  });
  getSelection().collapse(host);
  moveCaret(true, true);
  is(getSelection().anchorOffset, 0, "Shift+ArrowRight should select from right");
  is(getSelection().focusOffset, 1, "Shift+ArrowRight should select to left");
  moveCaret(false, false);
  is(getSelection().anchorOffset, 1, "Collapsing by ArrowLeft should put the caret to the left side");

  getSelection().collapse(host);
  moveCaret(true, true);
  moveCaret(true, false);
  is(getSelection().anchorOffset, 0, "Collapsing by ArrowRight should put the caret to the right side");

  subtestLTR();
}

SimpleTest.waitForExplicitFinish();
SimpleTest.promiseFocus().then(async () => {
  await testLogicalMovement();
  await testVisualMovement();
  await testHybridMovement();
  SimpleTest.finish();
});
</script>

Messung V0.5
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.