Ensure media controls host exists before using it
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Aug 2017 16:25:21 +0000 (16:25 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Aug 2017 16:25:21 +0000 (16:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175833
<rdar://problem/34001219>

Reviewed by Jer Noble.

Source/WebCore:

Although we ensure that the media controls shadow root exists before updating the text track
container, we don't check that the media controls host has been created yet. We do check
and create in other places in HTMLMediaElement.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateTextTrackDisplay):

LayoutTests:

* media/track/track-display-before-controls-crash-expected.txt: Added.
* media/track/track-display-before-controls-crash.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221077 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/track/track-display-before-controls-crash-expected.txt [new file with mode: 0644]
LayoutTests/media/track/track-display-before-controls-crash.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp

index 284d0d1..aecb805 100644 (file)
@@ -1,3 +1,14 @@
+2017-08-23  Brent Fulgham  <bfulgham@apple.com>
+
+        Ensure media controls host exists before using it
+        https://bugs.webkit.org/show_bug.cgi?id=175833
+        <rdar://problem/34001219>
+
+        Reviewed by Jer Noble.
+
+        * media/track/track-display-before-controls-crash-expected.txt: Added.
+        * media/track/track-display-before-controls-crash.html: Added.
+
 2017-08-23  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         [WPE] Some event handlers not working.
diff --git a/LayoutTests/media/track/track-display-before-controls-crash-expected.txt b/LayoutTests/media/track/track-display-before-controls-crash-expected.txt
new file mode 100644 (file)
index 0000000..3f223b4
--- /dev/null
@@ -0,0 +1,9 @@
+Tests triggering track display before media controls are created. Test passes if it does not crash.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/media/track/track-display-before-controls-crash.html b/LayoutTests/media/track/track-display-before-controls-crash.html
new file mode 100644 (file)
index 0000000..a3dc617
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+<script>
+    description("Tests triggering track display before media controls are created. Test passes if it does not crash.");
+</script>
+</head>
+<body>
+    <template>
+        <video>
+            <source>
+                <audio>
+                    <track src="x" default="C">Test Track 1</track>
+                </audio>
+            </source>
+        </video>
+    </template>
+</body>
+</html>
index d3fa4d7..d7de685 100644 (file)
@@ -1,3 +1,18 @@
+2017-08-23  Brent Fulgham  <bfulgham@apple.com>
+
+        Ensure media controls host exists before using it
+        https://bugs.webkit.org/show_bug.cgi?id=175833
+        <rdar://problem/34001219>
+
+        Reviewed by Jer Noble.
+
+        Although we ensure that the media controls shadow root exists before updating the text track
+        container, we don't check that the media controls host has been created yet. We do check
+        and create in other places in HTMLMediaElement.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::updateTextTrackDisplay): 
+
 2017-08-23  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         [WPE] Some event handlers not working.
index 792f6de..65dfb32 100644 (file)
@@ -5966,7 +5966,8 @@ void HTMLMediaElement::updateTextTrackDisplay()
 {
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
     ensureMediaControlsShadowRoot();
-    ASSERT(m_mediaControlsHost);
+    if (!m_mediaControlsHost)
+        m_mediaControlsHost = MediaControlsHost::create(this);
     m_mediaControlsHost->updateTextTrackContainer();
 #else
     if (!hasMediaControls() && !createMediaControls())