Ensure media controls host exists before using it
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 19:54:09 +0000 (19:54 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Aug 2017 19:54:09 +0000 (19:54 +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.

Tests: media/track/track-display-before-controls-crash.html

* 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@221033 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 a4ebca1..6a5148a 100644 (file)
@@ -1,3 +1,14 @@
+2017-08-22  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-22  Chris Dumez  <cdumez@apple.com>
 
        Unreviewed, beacon/contentextensions is only expected to work on Sierra+.
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..6ae7b92
--- /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 1c79eb7..359ce4d 100644 (file)
@@ -1,3 +1,20 @@
+2017-08-22  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.
+
+        Tests: media/track/track-display-before-controls-crash.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::updateTextTrackDisplay): 
+
 2017-08-22  Youenn Fablet  <youenn@apple.com>
 
         [Cache API] Optimize whitespace trimming in Vary header values
index c9ba4a0..9068b73 100644 (file)
@@ -5967,6 +5967,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())