Backed out 3 changesets (bug 1452536) for causing crashes bug 1458166. a=backout
authorCosmin Sabou <csabou@mozilla.com>
Fri, 04 May 2018 20:56:41 +0300
changeset 473069 a91ca6e5ca820b53fad9bb98b256934353f5217a
parent 473068 01db12b43ae7906b83e066d6ab83e06a001edc0a
child 473082 5bc3f25f994e72e1325313d0a4a5de3bbf13bcd1
child 473088 7ba78b394fcbafc82a925ef3ca8b0ba3ef272b47
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1452536, 1458166
milestone61.0a1
backs out1259c5bc20a733a19d343819d6d88c61445ec86f
c454505cc025bdcfcf1a4e1c17c02570262cddbb
006f976d79630f70ea5e921a22ab266c2d08479f
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
Backed out 3 changesets (bug 1452536) for causing crashes bug 1458166. a=backout Backed out changeset 1259c5bc20a7 (bug 1452536) Backed out changeset c454505cc025 (bug 1452536) Backed out changeset 006f976d7963 (bug 1452536)
dom/events/EventStateManager.cpp
dom/media/test/file_autoplay_policy_key_blacklist.html
dom/media/test/mochitest.ini
dom/media/test/test_autoplay_policy_key_blacklist.html
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -8,17 +8,16 @@
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextComposition.h"
-#include "mozilla/TextEditor.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/DragEvent.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/FrameLoaderBinding.h"
 #include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/TabChild.h"
@@ -902,28 +901,16 @@ EventStateManager::PreHandleEvent(nsPres
     NotifyTargetUserActivation(aEvent, aTargetContent);
     break;
   default:
     break;
   }
   return NS_OK;
 }
 
-static bool
-IsTextInput(nsIContent* aContent)
-{
-  MOZ_ASSERT(aContent);
-  if (!aContent->IsElement()) {
-    return false;
-  }
-  TextEditor* textEditor =
-    aContent->AsElement()->GetTextEditorInternal();
-  return textEditor && !textEditor->IsReadonly();
-}
-
 void
 EventStateManager::NotifyTargetUserActivation(WidgetEvent* aEvent,
                                               nsIContent* aTargetContent)
 {
   if (!aEvent->IsTrusted()) {
     return;
   }
 
@@ -937,34 +924,16 @@ EventStateManager::NotifyTargetUserActiv
     return;
   }
 
   nsIDocument* doc = node->OwnerDoc();
   if (!doc || doc->HasBeenUserActivated()) {
     return;
   }
 
-  // Don't activate if the target content of the event is contentEditable or
-  // is inside an editable document, or is a text input control. Activating
-  // due to typing/clicking on a text input would be surprising user experience.
-  if (aTargetContent->IsEditable() ||
-      IsTextInput(aTargetContent)) {
-    return;
-  }
-
-  // Don't gesture activate for key events for keys which are likely
-  // to be interaction with the browser, OS, or likely to be scrolling.
-  WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
-  if (keyEvent && (!keyEvent->PseudoCharCode() ||
-                   (keyEvent->IsControl() && !keyEvent->IsAltGraph()) ||
-                   (keyEvent->IsAlt() && !keyEvent->IsAltGraph()) ||
-                   keyEvent->IsMeta() || keyEvent->IsOS())) {
-    return;
-  }
-
   MOZ_ASSERT(aEvent->mMessage == eKeyDown   ||
              aEvent->mMessage == eMouseDown ||
              aEvent->mMessage == ePointerDown ||
              aEvent->mMessage == eTouchEnd);
   doc->NotifyUserActivation();
 }
 
 already_AddRefed<EventStateManager>
deleted file mode 100644
--- a/dom/media/test/file_autoplay_policy_key_blacklist.html
+++ /dev/null
@@ -1,165 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-
-<head>
-  <title>Autoplay policy window</title>
-  <style>
-    video {
-      width: 50%;
-      height: 50%;
-    }
-    :focus {
-      background-color: blue;
-    }
-  </style>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <script type="text/javascript" src="manifest.js"></script>
-  <script type="text/javascript" src="AutoplayTestUtils.js"></script>
-</head>
-
-<body>
-  <div id="x">This is a div with id=x.</div>
-  <pre id="test">
-      <input type="text" id="text-input"/>
-      <script>
-
-        window.ok = window.opener.ok;
-        window.is = window.opener.is;
-        window.info = window.opener.info;
-
-        // Keys that are expected to be not considered interaction with the page, and
-        // so not gesture activate the document.
-        let blacklistKeyPresses = [
-          "Tab",
-          "CapsLock",
-          "NumLock",
-          "ScrollLock",
-          "FnLock",
-          "Meta",
-          "OS",
-          "Hyper",
-          "Super",
-          "ContextMenu",
-          "ArrowUp",
-          "ArrowDown",
-          "ArrowLeft",
-          "ArrowRight",
-          "PageUp",
-          "PageDown",
-          "Home",
-          "End",
-          "Backspace",
-          "Fn",
-          "Alt",
-          "AltGraph",
-          "Control",
-          "Shift",
-          "Escape",
-        ];
-
-        let modifiedKeys = [
-          { key: "c", modifiers: { ctrlKey: true } },
-          { key: "V", modifiers: { ctrlKey: true, shiftKey: true } },
-          { key: "a", modifiers: { altKey: true } },
-          { key: "KEY_ArrowRight", modifiers: { metaKey: true } },
-          { key: "KEY_ArrowRight", modifiers: { altKey: true } },
-        ];
-
-        async function sendInput(element, name, input) {
-          synthesizeMouseAtCenter(input, {});
-          let played = await element.play().then(() => true, () => false);
-          ok(!played, "Clicking " + name + " should not activate document and should not unblock play");
-
-          synthesizeCompositionChange({
-            composition: {
-              string: "\u30E9\u30FC\u30E1\u30F3",
-              clauses: [
-                { length: 4, attr: COMPOSITION_ATTR_RAW_CLAUSE }
-              ]
-            },
-            caret: { start: 4, length: 0 }
-          });
-          synthesizeComposition({ type: "compositioncommitasis" });
-          played = await element.play().then(() => true, () => false);
-          ok(!played, "Entering text to " + name + " via IME should not activate document and should not unblock play");
-
-          input.focus();
-          sendString("ascii text");
-          played = await element.play().then(() => true, () => false);
-          ok(!played, "Entering ASCII text into " + name + " should not activate document and should not unblock play");
-
-          input.blur();
-        }
-
-        async function testAutoplayKeyBlacklist(testCase, parent_window) {
-          let element = document.createElement("video");
-          element.preload = "auto";
-          element.src = "short.mp4";
-          document.body.appendChild(element);
-
-          await once(element, "loadedmetadata");
-
-          let played = await element.play().then(() => true, () => false);
-          is(played, false, "Document should start out not activated, with playback blocked.");
-
-          // Try pressing all the keys in the blacklist, then playing.
-          // Document should not be activated, so play should fail.
-
-          for (let key of blacklistKeyPresses) {
-            document.body.focus();
-            synthesizeKey("KEY_" + key);
-            played = await element.play().then(() => true, () => false);
-            is(played, false, "Key " + key + " should not activate document and should not unblock play");
-          }
-
-          // Try pressing some keys with modifiers.
-          let keyNames = (m) => Object.keys(m).join("+");
-          for (let x of modifiedKeys) {
-            document.body.focus();
-            synthesizeKey(x.key, x.modifiers);
-            played = await element.play().then(() => true, () => false);
-            is(played, false, "Key (" + x.key + "+" + keyNames(x.modifiers) + ") should not activate document and should not unblock play");
-          }
-
-          // Test that clicking/typing into an input element doesn't activate.
-          let input = document.getElementById("text-input");
-          await sendInput(element, "input", input);
-
-          // Test that clicking/typing into a contentEditable div element doesn't activate.
-          let div = document.getElementById("x");
-          div.contentEditable = "true";
-          await sendInput(element, "contentEditable div", div);
-          div.contentEditable = "false";
-
-          // Test that clicking/typing into a div inside a designMode document doesn't activate.
-          document.designMode = "on";
-          await sendInput(element, "div in designMode=on", div);
-          document.designMode = "off";
-
-          // Try pressing a key not in the blacklist, then playing.
-          // Document should be activated, and media should play.
-
-          is(document.activeElement, document.body, "Focus needs to be the document, not an editable or text control.");
-          synthesizeKey(" ");
-          played = await element.play().then(() => true, () => false);
-          is(played, true, "Space key should activate document and should unblock play");
-
-          removeNodeAndSource(element);
-        }
-
-        nextWindowMessage().then(
-          async (event) => {
-            try {
-              await testAutoplayKeyBlacklist(event.data, event.source);
-            } catch (e) {
-              ok(false, "Caught exception " + e + " " + e.message + " " + e.stackTrace);
-            }
-            event.source.postMessage("done", "*");
-          });
-
-      </script>
-    </pre>
-</body>
-
-</html>
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -433,17 +433,16 @@ support-files =
   detodos-short.opus
   detodos-short.opus^headers^
   dirac.ogg
   dirac.ogg^headers^
   dynamic_resource.sjs
   eme.js
   file_access_controls.html
   file_autoplay_policy_eventdown_activation.html
-  file_autoplay_policy_key_blacklist.html
   file_autoplay_policy_unmute_pauses.html
   file_autoplay_policy_activation_window.html
   file_autoplay_policy_activation_frame.html
   file_autoplay_policy_play_before_loadedmetadata.html
   flac-s24.flac
   flac-s24.flac^headers^
   flac-noheader-s16.flac
   flac-noheader-s16.flac^headers^
@@ -693,18 +692,16 @@ skip-if = true # bug 475110 - disabled s
 [test_autoplay_contentEditable.html]
 skip-if = android_version == '15' || android_version == '17' || android_version == '22' # android(bug 1232305, bug 1232318, bug 1372457)
 [test_autoplay_policy.html]
 skip-if = android_version == '23' # bug 1424903
 [test_autoplay_policy_activation.html]
 skip-if = android_version == '23' # bug 1424903
 [test_autoplay_policy_eventdown_activation.html]
 skip-if = android_version == '23' # bug 1424903
-[test_autoplay_policy_key_blacklist.html]
-skip-if = android_version == '23' # bug 1424903
 [test_autoplay_policy_unmute_pauses.html]
 skip-if = android_version == '23' # bug 1424903
 [test_autoplay_policy_play_before_loadedmetadata.html]
 skip-if = android_version == '23' # bug 1424903
 [test_buffered.html]
 skip-if = android_version == '15' || android_version == '22' # bug 1308388, android(bug 1232305)
 [test_bug448534.html]
 [test_bug463162.xhtml]
deleted file mode 100644
--- a/dom/media/test/test_autoplay_policy_key_blacklist.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-
-<head>
-  <title>Autoplay policy test</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-  <script type="text/javascript" src="manifest.js"></script>
-  <script type="text/javascript" src="AutoplayTestUtils.js"></script>
-</head>
-
-<body>
-  <pre id="test">
-      <script>
-
-        // Tests that keypresses for non-printable characters,
-        // and mouse/keyboard interaction with editable elements,
-        // don't gesture activate documents, and don't unblock
-        // audible autoplay.
-
-        gTestPrefs.push(["media.autoplay.enabled", false],
-          ["media.autoplay.enabled.user-gestures-needed", true]);
-
-        SpecialPowers.pushPrefEnv({ 'set': gTestPrefs }, () => {
-          runTest();
-        });
-
-        let child_url = "file_autoplay_policy_key_blacklist.html";
-
-        async function runTest() {
-          // Run test in a new window, to ensure its user gesture
-          // activation state isn't tainted by preceeding tests.
-          let child = window.open(child_url, "", "width=500,height=500");
-          await once(child, "load");
-          child.postMessage("run test", window.origin);
-          let result = await nextWindowMessage();
-          child.close();
-          SimpleTest.finish();
-        }
-
-        SimpleTest.waitForExplicitFinish();
-
-      </script>
-    </pre>
-</body>
-
-</html>
\ No newline at end of file