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


Quelle  test_bug386782.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/docshell/test/navigation/test_bug386782.html


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

<head>
  <title>Test for Bug 386782</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" />

  <script>

    // This tests if we can load a document whose root is in designMode,
    // edit it, navigate to a new page, navigate back, still edit, and still
    // undo/redo. Note that this is different from the case where the
    // designMode document is in a frame inside the window, as this means
    // the editable region is not in the root docshell (a less complicated case).

    var gTests = [
      {
        // <html><body><p>designModeDocument</p></body></html>
        url: "file_bug386782_designmode.html",
        name: "designModeNavigate",
        onload(doc) { doc.designMode = "on"; },
        expectedBodyBeforeEdit: "

designModeDocument

"
,
        expectedBodyAfterEdit:  "

EDITED designModeDocument

"
,
        expectedBodyAfterSecondEdit: "

EDITED TWICE designModeDocument

"
,
      },
      {
        // <html><body contentEditable="true"><p>contentEditable</p></body></html>
        url: "file_bug386782_contenteditable.html",
        name: "contentEditableNavigate",
        expectedBodyBeforeEdit: "

contentEditable

"
,
        expectedBodyAfterEdit:  "EDITED

contentEditable

"
,
        expectedBodyAfterSecondEdit: "EDITED TWICE

contentEditable

"
,
      },
    ];

    var gTest = null;

    add_task(async () => {
      while (gTests.length) {
        gTest = gTests.shift();
        await runTest();
      }
    });

    async function runTest() {
      gTest.window = window.open(gTest.url, gTest.name, "width=500,height=500");
      let e = await new Promise(r => window.onmessage = r);
      is(e.data.persisted, false, "Initial load cannot be persisted");
      if ("onload" in gTest) {
        gTest.onload(gTest.window.document);
      }
      await SimpleTest.promiseFocus(gTest.window);

      gTest.window.document.body.focus();

      // WARNING: If the following test fails, give the setTimeout() in the onload()
      // a bit longer; the doc hasn't had enough time to setup its editor.
      is(gTest.window.document.body.innerHTML, gTest.expectedBodyBeforeEdit, "Is doc setup yet");
      sendString("EDITED ", gTest.window);
      is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Editing failed.");

      gTest.window.location = "about:blank";
      await new Promise(r => gTest.window.onpagehide = r);
      // The active document is updated synchronously after "pagehide" (and
      // its associated microtasks), so, after waiting for the next global
      // task, gTest.window will be proxying the realm associated with the
      // "about:blank" document.
      // https:// style='color:red'>html
.spec.whatwg.org/multipage/browsing-the-web.html#update-the-session-history-with-the-new-page
      await new Promise(r => setTimeout(r));
      is(gTest.window.location.href, "about:blank""location.href");
      await SimpleTest.promiseFocus(gTest.window, true);

      gTest.window.history.back();
      e = await new Promise(r => window.onmessage = r);
      // Skip the test if the page is not loaded from the bf-cache when going back.
      if (e.data.persisted) {
        checkStillEditable();
      }
      gTest.window.close();
    }

    function checkStillEditable() {
      // Check that the contents are correct.
      is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Edited contents still correct?");

      // Check that we can undo/redo and the contents are correct.
      gTest.window.document.execCommand("undo", false, null);
      is(gTest.window.document.body.innerHTML, gTest.expectedBodyBeforeEdit, "Can we undo?");

      gTest.window.document.execCommand("redo", false, null);
      is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Can we redo?");

      // Check that we can still edit the page.
      gTest.window.document.body.focus();
      sendString("TWICE ", gTest.window);
      is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterSecondEdit, "Can we still edit?");
    }

  </script>

</head>
<body>
<a target="_blank" href="
https://bugzilla.mozilla.org/show_bug.cgi?id=386782">Mozilla Bug 386782</a>
<p id="display"></p>
<div id="content" style="display: none">

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

/** Test for Bug 386782 */

SimpleTest.waitForExplicitFinish();

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

100%


¤ 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 ist 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