зеркало из https://github.com/mozilla/gecko-dev.git
Bug 674770 - contenteditable breaks middle-click to open links when middlemouse.paste=true; r=roc
--HG-- extra : rebase_source : b55ad48345f29c9d449417432b6830e7eef14bd2
This commit is contained in:
Родитель
5b57a0bec6
Коммит
e0e17852ac
|
@ -389,6 +389,16 @@ nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMEventTarget> target;
|
||||||
|
aMouseEvent->GetTarget(getter_AddRefs(target));
|
||||||
|
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(target);
|
||||||
|
NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
if (!mEditor->IsModifiableNode(node)) {
|
||||||
|
// We shouldn't handle the event for non-editable content.
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIDOMNSUIEvent> nsuiEvent = do_QueryInterface(aMouseEvent);
|
nsCOMPtr<nsIDOMNSUIEvent> nsuiEvent = do_QueryInterface(aMouseEvent);
|
||||||
NS_ENSURE_TRUE(nsuiEvent, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(nsuiEvent, NS_ERROR_NULL_POINTER);
|
||||||
|
|
|
@ -84,6 +84,8 @@ _TEST_FILES = \
|
||||||
test_bug629845.html \
|
test_bug629845.html \
|
||||||
test_bug640321.html \
|
test_bug640321.html \
|
||||||
test_bug668599.html \
|
test_bug668599.html \
|
||||||
|
test_bug674770.html \
|
||||||
|
file_bug674770.html \
|
||||||
test_bug674861.html \
|
test_bug674861.html \
|
||||||
test_CF_HTML_clipboard.html \
|
test_CF_HTML_clipboard.html \
|
||||||
test_contenteditable_focus.html \
|
test_contenteditable_focus.html \
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<!DOCTYPE>
|
||||||
|
<script>
|
||||||
|
localStorage["clicked"] = "true";
|
||||||
|
close();
|
||||||
|
</script>
|
|
@ -0,0 +1,69 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=674770
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 674770</title>
|
||||||
|
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||||
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.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=674770">Mozilla Bug 674770</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content">
|
||||||
|
<a href="file_bug674770.html" id="link1">test</a>
|
||||||
|
<div contenteditable>
|
||||||
|
<a href="file_bug674770.html" id="link2">test</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script type="application/javascript">
|
||||||
|
|
||||||
|
/** Test for Bug 674770 **/
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
SimpleTest.waitForFocus(function() {
|
||||||
|
SpecialPowers.setBoolPref("middlemouse.paste", true);
|
||||||
|
localStorage.removeItem("clicked");
|
||||||
|
window.linkWasClicked = false;
|
||||||
|
|
||||||
|
var link = document.querySelector("#link1");
|
||||||
|
addEventListener("storage", function(e) {
|
||||||
|
is(e.key, "clicked", "Correct event");
|
||||||
|
is(e.newValue, "true", "Correct value");
|
||||||
|
window.linkWasClicked = true;
|
||||||
|
}, false);
|
||||||
|
synthesizeMouseAtCenter(link, {button: 1});
|
||||||
|
|
||||||
|
hitEventLoop(function() {
|
||||||
|
ok(window.linkWasClicked, "The click operation worked successfully");
|
||||||
|
window.linkWasClicked = false;
|
||||||
|
|
||||||
|
link = document.querySelector("#link2");
|
||||||
|
localStorage.removeItem("clicked");
|
||||||
|
synthesizeMouseAtCenter(link, {button: 1});
|
||||||
|
|
||||||
|
hitEventLoop(function() {
|
||||||
|
ok(!window.linkWasClicked, "The click operation shouldn't work in the contenteditable area");
|
||||||
|
|
||||||
|
localStorage.removeItem("clicked");
|
||||||
|
SpecialPowers.clearUserPref("middlemouse.paste");
|
||||||
|
SimpleTest.finish();
|
||||||
|
}, 100);
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
|
||||||
|
function hitEventLoop(func, times) {
|
||||||
|
if (times > 0) {
|
||||||
|
setTimeout(hitEventLoop, 0, func, times - 1);
|
||||||
|
} else {
|
||||||
|
setTimeout(func, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
Загрузка…
Ссылка в новой задаче