Bug 924087 - Do not make editable elements as active, as their default action is disabled; r=smaug,dbaron
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 15 Jan 2015 22:42:52 -0500
changeset 251458 debc66b7bfe7822e79ceab4b61f1f1db7a7f80a6
parent 251457 369a8f14ccf8c41da54d76992cb205080fccce51
child 251459 e10a79c4ac9f40ac9556e7ef88a60a9da9587613
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, dbaron
bugs924087
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 924087 - Do not make editable elements as active, as their default action is disabled; r=smaug,dbaron
dom/events/EventStateManager.cpp
dom/events/test/mochitest.ini
dom/events/test/test_bug924087.html
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -4685,16 +4685,21 @@ EventStateManager::SetContentState(nsICo
     if (mCurrentTarget)
     {
       const nsStyleUserInterface* ui = mCurrentTarget->StyleUserInterface();
       if (ui->mUserInput == NS_STYLE_USER_INPUT_NONE)
         return false;
     }
 
     if (aState == NS_EVENT_STATE_ACTIVE) {
+      // Editable content can never become active since their default actions
+      // are disabled.
+      if (aContent && aContent->IsEditable()) {
+        aContent = nullptr;
+      }
       if (aContent != mActiveContent) {
         notifyContent1 = aContent;
         notifyContent2 = mActiveContent;
         mActiveContent = aContent;
       }
     } else {
       NS_ASSERTION(aState == NS_EVENT_STATE_HOVER, "How did that happen?");
       nsIContent* newHover;
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -120,16 +120,17 @@ skip-if = toolkit == 'android' #CRASH_DU
 [test_bug704423.html]
 [test_bug741666.html]
 skip-if = toolkit == 'android'
 [test_bug742376.html]
 [test_bug812744.html]
 [test_bug855741.html]
 [test_bug864040.html]
 skip-if = buildapp == 'mulet' || buildapp == 'b2g' # b2g(failing when the test gets moved around, and on debug)
+[test_bug924087.html]
 [test_bug930374-content.html]
 [test_bug944011.html]
 [test_bug944847.html]
 [test_bug946632.html]
 [test_bug967796.html]
 skip-if = toolkit == "gonk" || e10s
 [test_bug985988.html]
 [test_bug998809.html]
new file mode 100644
--- /dev/null
+++ b/dom/events/test/test_bug924087.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=924087
+-->
+<head>
+  <title>Test for Bug 924087</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<div contenteditable><a id="editable" href="#">editable link</a></div>
+<a id="noneditable" href="#">non-editable link</a>
+<pre id="test">
+<script type="application/javascript;version=1.8">
+
+/** Test for Bug 924087 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  var editable = document.querySelector("#editable");
+  var noneditable = document.querySelector("#noneditable");
+  synthesizeMouseAtCenter(noneditable, {type:"mousedown"});
+  is(document.querySelector(":active:link"), noneditable, "Normal links should become :active");
+  synthesizeMouseAtCenter(noneditable, {type:"mouseup"});
+  synthesizeMouseAtCenter(editable, {type:"mousedown"});
+  is(document.querySelector(":active:link"), null, "Editable links should not become :active");
+  synthesizeMouseAtCenter(editable, {type:"mouseup"});
+  SimpleTest.finish();
+});
+
+</script>
+</pre>
+
+</body>
+</html>