Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  test_copyimage.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/C/Firefox/dom/serializers/tests/mochitest/test_copyimage.html


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

<head>
  <title>Test for copy image</title>
  <script src="/tests/SimpleTest/SimpleTest.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=518249">Mozilla Bug 518249</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=952456">Mozilla Bug 952456</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

function testCopyImage () {
  var Ci = SpecialPowers.Ci;
  var Cc = SpecialPowers.Cc;
  var clipboard = SpecialPowers.Services.clipboard;

  function getClipboardData(mime) {
    var transferable = Cc['@mozilla.org/widget/transferable;1']
                       .createInstance(Ci.nsITransferable);
    var loadingContext = SpecialPowers.wrap(window).docShell
                                      .QueryInterface(Ci.nsILoadContext);
    transferable.init(loadingContext);
    transferable.addDataFlavor(mime);
    clipboard.getData(transferable, 1, SpecialPowers.wrap(window).browsingContext.currentWindowContext);
    var data = SpecialPowers.createBlankObject();
    transferable.getTransferData(mime, data);
    return data;
  }

  function testClipboardValue(mime, expected) {
    var data = SpecialPowers.wrap(getClipboardData(mime));
    var str = data.value == null ? data.value :
              data.value.QueryInterface(Ci.nsISupportsString).data;
    is(str, expected, "clipboard has correct [" + mime + "] content")
  }

  //--------- Prepare data and copy it.

  // Select the node.
  var node = document.getElementById('image');

  // Set node and copy image.
  var docShell = SpecialPowers.wrap(window).docShell;
  var documentViewer = docShell.docViewer
                               .QueryInterface(Ci.nsIDocumentViewerEdit);
  documentViewer.setCommandNode(node);
  documentViewer.copyImage(documentViewer.COPY_IMAGE_ALL);

  //--------- Let's check the content of the clipboard now.

  // Does the clipboard contain text/plain data ?
  ok(clipboard.hasDataMatchingFlavors(["text/plain"], clipboard.kGlobalClipboard), "clipboard contains unicode text");
  // Does the clipboard contain text/html data ?
  ok(clipboard.hasDataMatchingFlavors(["text/html"], clipboard.kGlobalClipboard), "clipboard contains html text");
  // Does the clipboard contain image data ?
  ok(clipboard.hasDataMatchingFlavors(["image/png"], clipboard.kGlobalClipboard), "clipboard contains image");

  const imgUrl = new URL('image.png', document.baseURI).href;

  // Is the text/plain data correct ?
  testClipboardValue('text/plain', imgUrl);
  // Is the text/html data correct ?
  var expected = `<img id="image" src="${imgUrl}">`;
  if (navigator.platform.includes("Win")) {
    expected = kTextHtmlPrefixClipboardDataWindows + expected + kTextHtmlSuffixClipboardDataWindows;
  }
  testClipboardValue('text/html', expected);

  SimpleTest.finish();
}

SimpleTest.waitForExplicitFinish();
addLoadEvent(testCopyImage);
</script>
</pre>
<div>
  <img id="image" src="image.png">
</div>
</body>
</html>

Messung V0.5 in Prozent
C=95 H=95 G=94

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002