Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/editor/libeditor/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 4 kB image not shown  

Quelle  test_resizers_appearance.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/editor/libeditor/tests/test_resizers_appearance.html


<!DOCTYPE html>
<html>
<head>
  <title>Test for resizers appearance</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>
<p id="display"></p>
<div id="content" style="display: none;">

</div>

<div id="editor" contenteditable></div><br>
<div id="clickaway" style="width: 30px; height: 30px; border: 3px solid red;"></div>
<img src="green.png"><!-- for ensuring to load the image at first test of <img> case -->
<pre id="test">

<script class="testbody" type="application/javascript">
"use strict";

function resizingActive(win = window) {
  let Ci = SpecialPowers.Ci;
  let editor = SpecialPowers.wrap(win).docShell.editor;
  return editor && editor.QueryInterface(Ci.nsIHTMLObjectResizer).isObjectResizingActive;
}

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async function() {
  async function waitForSelectionChange() {
    return new Promise(resolve => {
      document.addEventListener("selectionchange", () => {
        resolve();
      }, {once: true});
    });
  }

  let editor = document.getElementById("editor");
  let outOfEditor = document.getElementById("clickaway");

  const kTests = [
    { description: "",
      innerHTML: "target\" src=\"green.png\" width=\"100\" height=\"100\">",
      resizable: true,
    },
    { description: "",
      innerHTML: "
target\" border>
1-11-2
2-12-2
"
,
      resizable: true,
    },
    { description: "absolute positioned
",
      innerHTML: "
target\" style=\"position: absolute; top: 50px; left: 50px;\">positioned
"
,
      resizable() { return document.queryCommandState("enableAbsolutePositionEditing"); },
    },
    { description: "fixed positioned
",
      innerHTML: "
target\" style=\"position: fixed; top: 50px; left: 50px;\">positioned
"
,
      resizable: false,
    },
    { description: "relative positioned
",
      innerHTML: "
target\" style=\"position: relative; top: 50px; left: 50px;\">positioned
"
,
      resizable: false,
    },
  ];

  for (let kEnableAbsolutePositionEditor of [true, false]) {
    document.execCommand("enableAbsolutePositionEditing", false, kEnableAbsolutePositionEditor);
    for (const kTest of kTests) {
      const kDescription = kTest.description +
        (kEnableAbsolutePositionEditor ? " (enabled absolute position editor)" : "") + ": ";
      editor.innerHTML = kTest.innerHTML;
      let target = document.getElementById("target");

      document.execCommand("enableObjectResizing", false, false);
      ok(!document.queryCommandState("enableObjectResizing"),
         kDescription + "Object resizer should be disabled by the call of execCommand");

      synthesizeMouseAtCenter(outOfEditor, {});
      let promiseSelectionChangeEvent1 = waitForSelectionChange();
      synthesizeMouseAtCenter(target, {});
      await promiseSelectionChangeEvent1;
      ok(!resizingActive(),
       kDescription + ": While enableObjectResizing is disabled, resizers shouldn't appear");

      document.execCommand("enableObjectResizing", false, true);
      ok(document.queryCommandState("enableObjectResizing"),
         kDescription + "Object resizer should be enabled by the call of execCommand");

      synthesizeMouseAtCenter(outOfEditor, {});
      let promiseSelectionChangeEvent2 = waitForSelectionChange();
      synthesizeMouseAtCenter(target, {});
      await promiseSelectionChangeEvent2;

      const kResizable = typeof kTest.resizable === "function" ? kTest.resizable() : kTest.resizable;
      is(resizingActive(), kResizable,
         kDescription + (kResizable ? "While enableObjectResizing is enabled, resizers should appear" :
                                      "Even while enableObjectResizing is enabled, resizers shouldn't appear"));
      document.execCommand("enableObjectResizing", false, false);
      ok(!resizingActive(),
         kDescription + "enableObjectResizing is disabled even while resizers are visible, resizers should disappear");

      document.execCommand("enableObjectResizing", false, true);
      is(resizingActive(), kResizable,
         kDescription + (kResizable ? "enableObjectResizing is enabled when resizable object is selected, resizers should appear" :
                                      "Even if enableObjectResizing is enabled when non-resizable object is selected, resizers shouldn't appear"));
    }
  }

  SimpleTest.finish();
});
</script>
</pre>
</body>
</html>

99%


¤ Dauer der Verarbeitung: 0.4 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 ist noch experimentell.