Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/dom/base/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_bug498433.html   Sprache: HTML

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


<!DOCTYPE HTML>
<html>
<!--
-->

<head>
  <title>Test for HTML serializer</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=498433">Mozilla Bug </a>
<p id="display"></p>
<div id="content" style="display: none">
  <iframe id="testframe" src="file_htmlserializer_ipv6.html">
  </iframe>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">


function loadFileContent(aFile, aCharset) {
    if (aCharset == undefined)
        aCharset = 'UTF-8';

    var baseUri = SpecialPowers.Cc['@mozilla.org/network/standard-url-mutator;1']
                                  .createInstance(SpecialPowers.Ci.nsIURIMutator)
                                  .setSpec(window.location.href)
                                  .finalize();

    var ios = SpecialPowers.Cc['@mozilla.org/network/io-service;1']
            .getService(SpecialPowers.Ci.nsIIOService);
    var chann = ios.newChannel(aFile,
                               aCharset,
                               baseUri,
                               null,      // aLoadingNode
                               SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal(),
                               null,      // aTriggeringPrincipal
                               SpecialPowers.Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
                               SpecialPowers.Ci.nsIContentPolicy.TYPE_OTHER);

    var cis = SpecialPowers.Ci.nsIConverterInputStream;

    var inputStream = SpecialPowers.Cc["@mozilla.org/intl/converter-input-stream;1"]
                       .createInstance(cis);
    inputStream.init(chann.open(), aCharset, 1024, cis.DEFAULT_REPLACEMENT_CHARACTER);
    var str = {}, content = '';
    while (inputStream.readString(4096, str) != 0) {
        content += str.value;
    }
    return content;
}

function isRoughly(actual, expected, message) {
  return is(actual.replace(", "), 
            expected, 
            message);
}

function testHtmlSerializer_1 () {
  const de = SpecialPowers.Ci.nsIDocumentEncoder;
  var encoder = SpecialPowers.Cu.createDocumentEncoder("text/html");

  var doc = $("testframe").contentDocument;
  var out, expected;

  // in the following tests, we must use the OutputLFLineBreak flag, to avoid
  // to have the default line break of the platform in the result, so the test
  // can pass on all platform

  //------------ no flags
  encoder.init(doc, "text/html", de.OutputLFLineBreak);
  encoder.setCharset("UTF-8");
  out = encoder.encodeToString();
  expected = loadFileContent("file_htmlserializer_ipv6_out.html");
  isRoughly(out, expected, "test no flags");
  //------------ OutputAbsoluteLinks
  encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
  encoder.setCharset("UTF-8");
  out = encoder.encodeToString();
  expected = loadFileContent("file_htmlserializer_ipv6_out.html");
  isRoughly(out, expected, "test OutputAbsoluteLinks");
  //------------ serializing a selection
  encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
  encoder.setNode(doc.links[0]);
  out = encoder.encodeToString();
  expected = "http://[2001:4860:a003::68]/\">Test";
  isRoughly(out, expected, "test selection");


  SimpleTest.finish();
}


SimpleTest.waitForExplicitFinish();

addLoadEvent(testHtmlSerializer_1);

</script>
</pre>

</body>
</html>



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

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© 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.