diff options
author | Job Bautista <jobbautista9@protonmail.com> | 2023-02-09 20:51:34 +0800 |
---|---|---|
committer | Job Bautista <jobbautista9@protonmail.com> | 2023-02-09 20:51:34 +0800 |
commit | 42742eceae3cd56c2fdee9ec598253cd3d886ee6 (patch) | |
tree | 20bfb9ff6d039dc5e5bf064f33c7bb08b392a34e | |
parent | ffdba3d91e0ca7df003a97f564451fb0ae97fa8e (diff) | |
download | uxp-42742eceae3cd56c2fdee9ec598253cd3d886ee6.tar.gz |
Issue #2107 - Clean up caret when destroying editor.
Editor changes caret visibility during drag and drop. But when destroying
editor, we don't restore caret state. So we should restore it when destroying
editor.
Co-authored-by: Makoto Kato <m_kato@ga2.so-net.ne.jp>
-rw-r--r-- | editor/libeditor/EditorEventListener.cpp | 2 | ||||
-rw-r--r-- | layout/base/tests/bug1496118-ref.html | 24 | ||||
-rw-r--r-- | layout/base/tests/bug1496118.html | 37 | ||||
-rw-r--r-- | layout/base/tests/mochitest.ini | 2 | ||||
-rw-r--r-- | layout/base/tests/test_reftests_with_caret.html | 1 |
5 files changed, 66 insertions, 0 deletions
diff --git a/editor/libeditor/EditorEventListener.cpp b/editor/libeditor/EditorEventListener.cpp index 1a3beca6e6..32f3585288 100644 --- a/editor/libeditor/EditorEventListener.cpp +++ b/editor/libeditor/EditorEventListener.cpp @@ -238,6 +238,8 @@ EditorEventListener::Disconnect() void EditorEventListener::UninstallFromEditor() { + CleanupDragDropCaret(); + nsCOMPtr<EventTarget> piTarget = mEditorBase->GetDOMEventTarget(); if (!piTarget) { return; diff --git a/layout/base/tests/bug1496118-ref.html b/layout/base/tests/bug1496118-ref.html new file mode 100644 index 0000000000..feaf31476b --- /dev/null +++ b/layout/base/tests/bug1496118-ref.html @@ -0,0 +1,24 @@ +<!DOCTYPE HTML> +<html class="reftest-wait"> +<head> + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <style> + input, input:active { border: none; } + </style> +</head> +<body> +<input id="input1"> +<div id=div1 style="height: 100px;"> + <textarea id="textarea1" style="display: none;"></textarea> +</div> +<script> +SimpleTest.waitForFocus(() => { + let input1 = document.getElementById('input1'); + input1.focus(); + synthesizeKey("A"); + document.documentElement.removeAttribute("class"); +}); +</script> +</body> +</html> diff --git a/layout/base/tests/bug1496118.html b/layout/base/tests/bug1496118.html new file mode 100644 index 0000000000..7656e010ba --- /dev/null +++ b/layout/base/tests/bug1496118.html @@ -0,0 +1,37 @@ +<!DOCTYPE HTML> +<html class="reftest-wait"> +<head> + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <style> + input, input:active { border: none; } + </style> +</head> +<body> +<input id="input1" value="aaaaaaaaaaaaaaaaaaaa"> +<div id=div1 style="height: 100px;"> + <textarea id="textarea1"></textarea> +</div> +<script> +SimpleTest.waitForFocus(() => { + let div1 = document.getElementById('div1'); + let textarea1 = document.getElementById('textarea1'); + div1.addEventListener("drop", e => { + e.preventDefault(); + + textarea1.style = "display: none;"; + SimpleTest.executeSoon(() => { + synthesizeKey("A"); + document.documentElement.removeAttribute("class"); + }); + }); + + let input1 = document.getElementById('input1'); + input1.focus(); + input1.setSelectionRange(0, input1.value.length); + + synthesizeDrop(input1, textarea1, [[{type: "text/plain", data: "foo"}]]); +}); +</script> +</body> +</html> diff --git a/layout/base/tests/mochitest.ini b/layout/base/tests/mochitest.ini index fc616b1ef8..846ab52813 100644 --- a/layout/base/tests/mochitest.ini +++ b/layout/base/tests/mochitest.ini @@ -179,6 +179,8 @@ support-files = bug1263357-4-ref.html bug1263357-5.html bug1263357-5-ref.html + bug1496118.html + bug1496118-ref.html input-maxlength-valid-before-change.html input-maxlength-valid-change.html input-maxlength-invalid-change.html diff --git a/layout/base/tests/test_reftests_with_caret.html b/layout/base/tests/test_reftests_with_caret.html index 062c605b98..d39dd737ad 100644 --- a/layout/base/tests/test_reftests_with_caret.html +++ b/layout/base/tests/test_reftests_with_caret.html @@ -186,6 +186,7 @@ var tests = [ [ 'bug1263357-3.html' , 'bug1263357-3-ref.html'] , [ 'bug1263357-4.html' , 'bug1263357-4-ref.html'] , [ 'bug1263357-5.html' , 'bug1263357-5-ref.html'] , + [ 'bug1496118.html' , 'bug1496118-ref.html' ] , function() {SpecialPowers.pushPrefEnv({'clear': [['layout.accessiblecaret.enabled']]}, nextTest);} , ]; |