Bug 1772588 [wpt PR 34302] - [wpt] Add test for block-in-inline offsetParent., a...
[gecko.git] / editor / libeditor / tests / test_nsIHTMLObjectResizer_hideResizers.html
blob39679a546d90a3932430d601adc6fa0d020104bc
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Test for nsIHTMLObjectResizer.hideResizers()</title>
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script src="/tests/SimpleTest/EventUtils.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
8 </head>
9 <body>
10 <p id="display"></p>
11 <div id="content" style="display: none;">
13 </div>
15 <div id="editor" contenteditable></div>
16 <img src="green.png"><!-- for ensuring to load the image at first test of <img> case -->
17 <pre id="test">
19 <script class="testbody" type="application/javascript">
20 "use strict";
22 SimpleTest.waitForExplicitFinish();
23 SimpleTest.waitForFocus(async function() {
24 async function waitForSelectionChange() {
25 return new Promise(resolve => {
26 document.addEventListener("selectionchange", () => {
27 resolve();
28 }, {once: true});
29 });
32 document.execCommand("enableObjectResizing", false, true);
33 let editor = document.getElementById("editor");
34 editor.innerHTML = "<img id=\"target\" src=\"green.png\" width=\"100\" height=\"100\">";
35 let img = document.getElementById("target");
36 let promiseSelectionChangeEvent = waitForSelectionChange();
37 synthesizeMouseAtCenter(img, {});
38 await promiseSelectionChangeEvent;
39 ok(img.hasAttribute("_moz_resizing"), "resizers of the <img> should be visible");
40 getHTMLObjectResizer().hideResizers();
41 ok(!img.hasAttribute("_moz_resizing"), "resizers of the <img> should be hidden after a call of hideResizers()");
43 SimpleTest.finish();
44 });
46 function getHTMLObjectResizer() {
47 var Ci = SpecialPowers.Ci;
48 var editingSession = SpecialPowers.wrap(window).docShell.editingSession;
49 return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsIHTMLObjectResizer);
51 </script>
52 </pre>
53 </body>
54 </html>