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


Quelle  test_clipboard_nbsp.html   Sprache: HTML

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


<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=359303
-->

<head>
  <meta charset="utf-8" />
  <title>Test for copying non-breaking spaces to the clipboard</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=359303">Mozilla Bug 359303</a>

<p id="display"></p>

<div id="content">
<!-- In a plain-text editable control (such as a textarea or textinput), copying to clipboard should
preserve non-breaking spaces. -->

<input
  id="input-with-non-breaking-spaces"
  value="Input content: This town is 100 km away / « Est-ce Paris ? » / Consecutive non-breaking spaces: '  '">
<textarea id="textarea-with-non-breaking-spaces">
Textarea content:
- This town is 100 km away.
- « Est-ce Paris ? »
- Consecutive non-breaking spaces: "  "
</textarea>

<!-- In a content-editable div, copying to clipboard should preserve non-breaking spaces.
However, for compatibility with what other browsers currently do, the behavior of replacing non-breaking spaces by spaces is preserved for now.
See https://bugzilla.mozilla.org/show_bug.cgi?id=359303#c145
-->

<div contenteditable="true" id="content-editable-with-non-breaking-spaces">
Content-editable content:
- This town is 100 km away.
- « Est-ce Paris ? »
- Consecutive non-breaking spaces: "  "
</div>

<!-- In non-editable HTML nodes, like this paragraph, copying to clipboard should preserve non-breaking
spaces.
However, for compatibility with what other browsers currently do, the behavior of replacing non-breaking spaces by spaces is preserved for now.
See https://bugzilla.mozilla.org/show_bug.cgi?id=359303#c145
-->

<p id="paragraph-with-non-breaking-spaces">
Paragraph content:
- This town is 100 km away.
- « Est-ce Paris ? »
- Consecutive non-breaking spaces: "  "
</p>
</div>

<pre id="test">
<script class="testbody" type="application/javascript">

// Helper: for the given element, select all its content, execute a "Copy" command,
// and return the text put into the clipboard.
async function clipboardTextForElementId(aDomId, aExpectedString) {
  let textContainer = document.getElementById(aDomId);
  let sel = window.getSelection();
  sel.removeAllRanges();

  if (textContainer.select) {
    // Select the entire text in the input or textarea
    textContainer.select();
  } else {
    // Select text node in element.
    let r = document.createRange();
    r.setStart(textContainer, 0);
    r.setEnd(textContainer, 1);
    sel.addRange(r);
  }

  let copiedText = await SimpleTest.promiseClipboardChange(
    function compare(aValue) {
      return aValue.includes(aExpectedString);
    },
    function setup() {
      synthesizeKey("C", {accelKey: true});
    },
    "text/plain");
  return copiedText;
}

/** Test for Bug 359303 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async function() {
  let iValue = await clipboardTextForElementId("input-with-non-breaking-spaces""Input");
  ok(iValue.includes("100 km"), "NBSP between two characters should be preserved");
  ok(iValue.includes("« "),  "A single NBSP near a punctuation mark should be preserved");
  ok(iValue.includes(" »"),  "A single NBSP near a punctuation mark should be preserved");
  ok(iValue.includes(" ? "), "NBSPs before *and* after a character should be preserved");
  ok(iValue.includes("  "), "Consecutive NBSPs should be preserved");

  let tValue = await clipboardTextForElementId("textarea-with-non-breaking-spaces""Textarea");
  ok(tValue.includes("100 km"), "NBSP between two characters should be preserved");
  ok(tValue.includes("« "),  "A single NBSP near a punctuation mark should be preserved");
  ok(tValue.includes(" »"),  "A single NBSP near a punctuation mark should be preserved");
  ok(tValue.includes(" ? "), "NBSPs before *and* after a character should be preserved");
  ok(tValue.includes("  "), "Consecutive NBSPs should be preserved");

  let cValue = await clipboardTextForElementId("content-editable-with-non-breaking-spaces""Content-editable");
  ok(cValue.includes("100 km"), "NBSP should be replaced by spaces, until brower compatibility issues are sorted out");

  let pValue = await clipboardTextForElementId("paragraph-with-non-breaking-spaces""Paragraph");
  ok(pValue.includes("100 km"), "NBSP should be replaced by spaces, until brower compatibility issues are sorted out");

  SimpleTest.finish();
});

</script>
</pre>
</body>
</html>

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

¤ 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