Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  test_find_bug1601118.html   Sprache: HTML

 
 products/sources/formale Sprachen/C/Firefox/dom/base/test/test_find_bug1601118.html


<!doctype html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="container">
  Fission <br/>
  Some text <br/>
  Some more text Fission or Fission or even <span>Fi</span>ssion<br/>
  Fission <br/>
  more text<br/>
  <div>
    in a nested block Fission stuff
  </div>
</div>
<script>
const kContainer = document.getElementById("container");
const kExpectedCount = 6;

// We expect surroundContents() to throw in the <span>Fi</span>ssion case.
const kExpectedThrewCount = 1;

// Keep a hang of the original DOM so as to test forwards and backwards navigation.
const kContainerClone = kContainer.cloneNode(true);

function advance(backwards) {
  if (!window.find("Fiss", /* caseSensitive = */ true, backwards))
    return { success: false };

  let threw = false;
  try {
    window.getSelection().getRangeAt(0).surroundContents(document.createElement("mark"));
  } catch (ex) {
    threw = true;
  }

  // Sanity-check
  assert_equals(window.getSelection().toString(), "Fiss");
  return { success: true, threw };
}

function runTestForDirection(backwards) {
  let threwCount = 0;
  for (let i = 0; i < kExpectedCount; ++i) {
    let result = advance(backwards);
    assert_true(result.success, `Should've successfully advanced (${i} / ${kExpectedCount}, backwards: ${backwards})`);
    if (result.threw)
      threwCount++;
  }
  assert_false(advance(backwards).success, `Should've had exactly ${kExpectedCount} matches`);
  assert_equals(threwCount, kExpectedThrewCount, "Should've thrown the expected number of times");
  assert_equals(kContainer.querySelectorAll("mark").length, kExpectedCount - threwCount, "Should've created the expected number of marks");
  assert_false(!!kContainer.querySelector("mark mark"), "Shouldn't have created nested marks");
}

test(function() {
  runTestForDirection(false);
  window.getSelection().removeAllRanges();
  kContainer.innerHTML = kContainerClone.innerHTML;
  runTestForDirection(true);
}, "window.find() while marking with surroundContents");
</script>

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

¤ Dauer der Verarbeitung: 0.1 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge