Add WebVTT parsing layout tests.  Patch also includes creating a TextTrackCueList
in TextTrack::cues() and observing WebVTT chronological cue order.
https://bugs.webkit.org/show_bug.cgi?id=72215

Reviewed by Eric Carlson.

Source/WebCore:

Tests: media/track/track-webvtt-tc000-empty.html
       media/track/track-webvtt-tc001-utf8.html
       media/track/track-webvtt-tc002-bom.html
       media/track/track-webvtt-tc003-newlines.html
       media/track/track-webvtt-tc004-magic-header.html
       media/track/track-webvtt-tc005-header-comment.html
       media/track/track-webvtt-tc006-cue-identifiers.html
       media/track/track-webvtt-tc007-cue-no-id.html
       media/track/track-webvtt-tc008-timings-no-hours.html
       media/track/track-webvtt-tc009-timings-hour.html
       media/track/track-webvtt-tc010-no-timings.html
       media/track/track-webvtt-tc011-blank-lines.html
       media/track/track-webvtt-tc012-out-of-order.html
       media/track/track-webvtt-tc013-settings.html
       media/track/track-webvtt-tc014-alignment.html
       media/track/track-webvtt-tc015-positioning.html
       media/track/track-webvtt-tc016-align-positioning.html
       media/track/track-webvtt-tc017-line-position.html
       media/track/track-webvtt-tc018-align-text-line-position.html
       media/track/track-webvtt-tc019-cue-size.html
       media/track/track-webvtt-tc020-cue-size-align.html
       media/track/track-webvtt-tc021-valign.html
       media/track/track-webvtt-tc022-entities.html
       media/track/track-webvtt-tc023-markup.html
       media/track/track-webvtt-tc024-timestamp.html
       media/track/track-webvtt-tc025-class-markup.html
       media/track/track-webvtt-tc026-voice.html
       media/track/track-webvtt-tc027-empty-cue.html
       media/track/track-webvtt-tc028-unsupported-markup.html

* html/TextTrack.cpp:
(WebCore::TextTrack::~TextTrack): Only call client if m_cues has been allocated.
(WebCore::TextTrack::cues): Create a TextTrackCueList if we don't already have one.
* html/TextTrack.h: The cues() function can no longer be const.
* html/TextTrackCueList.cpp:
(WebCore::TextTrackCueList::add): Only add the cue if the startTime comes after
    all other startTimes in the list.

LayoutTests:

* media/track/captions-webvtt/tc012-out-of-order.vtt: Fix typo.
* media/track/track-webvtt-tc000-empty-expected.txt: Added.
* media/track/track-webvtt-tc000-empty.html: Added.
* media/track/track-webvtt-tc001-utf8-expected.txt: Added.
* media/track/track-webvtt-tc001-utf8.html: Added.
* media/track/track-webvtt-tc002-bom-expected.txt: Added.
* media/track/track-webvtt-tc002-bom.html: Added.
* media/track/track-webvtt-tc003-newlines-expected.txt: Added.
* media/track/track-webvtt-tc003-newlines.html: Added.
* media/track/track-webvtt-tc004-magic-header-expected.txt: Added.
* media/track/track-webvtt-tc004-magic-header.html: Added.
* media/track/track-webvtt-tc005-header-comment-expected.txt: Added.
* media/track/track-webvtt-tc005-header-comment.html: Added.
* media/track/track-webvtt-tc006-cue-identifiers-expected.txt: Added.
* media/track/track-webvtt-tc006-cue-identifiers.html: Added.
* media/track/track-webvtt-tc007-cue-no-id-expected.txt: Added.
* media/track/track-webvtt-tc007-cue-no-id.html: Added.
* media/track/track-webvtt-tc008-timings-no-hours-expected.txt: Added.
* media/track/track-webvtt-tc008-timings-no-hours.html: Added.
* media/track/track-webvtt-tc009-timings-hour-expected.txt: Added.
* media/track/track-webvtt-tc009-timings-hour.html: Added.
* media/track/track-webvtt-tc010-no-timings-expected.txt: Added.
* media/track/track-webvtt-tc010-no-timings.html: Added.
* media/track/track-webvtt-tc011-blank-lines-expected.txt: Added.
* media/track/track-webvtt-tc011-blank-lines.html: Added.
* media/track/track-webvtt-tc012-out-of-order-expected.txt: Added.
* media/track/track-webvtt-tc012-out-of-order.html: Added.
* media/track/track-webvtt-tc013-settings-expected.txt: Added.
* media/track/track-webvtt-tc013-settings.html: Added.
* media/track/track-webvtt-tc014-alignment-expected.txt: Added.
* media/track/track-webvtt-tc014-alignment.html: Added.
* media/track/track-webvtt-tc015-positioning-expected.txt: Added.
* media/track/track-webvtt-tc015-positioning.html: Added.
* media/track/track-webvtt-tc016-align-positioning-expected.txt: Added.
* media/track/track-webvtt-tc016-align-positioning.html: Added.
* media/track/track-webvtt-tc017-line-position-expected.txt: Added.
* media/track/track-webvtt-tc017-line-position.html: Added.
* media/track/track-webvtt-tc018-align-text-line-position-expected.txt: Added.
* media/track/track-webvtt-tc018-align-text-line-position.html: Added.
* media/track/track-webvtt-tc019-cue-size-expected.txt: Added.
* media/track/track-webvtt-tc019-cue-size.html: Added.
* media/track/track-webvtt-tc020-cue-size-align-expected.txt: Added.
* media/track/track-webvtt-tc020-cue-size-align.html: Added.
* media/track/track-webvtt-tc021-valign-expected.txt: Added.
* media/track/track-webvtt-tc021-valign.html: Added.
* media/track/track-webvtt-tc022-entities-expected.txt: Added.
* media/track/track-webvtt-tc022-entities.html: Added.
* media/track/track-webvtt-tc023-markup-expected.txt: Added.
* media/track/track-webvtt-tc023-markup.html: Added.
* media/track/track-webvtt-tc024-timestamp-expected.txt: Added.
* media/track/track-webvtt-tc024-timestamp.html: Added.
* media/track/track-webvtt-tc025-class-markup-expected.txt: Added.
* media/track/track-webvtt-tc025-class-markup.html: Added.
* media/track/track-webvtt-tc026-voice-expected.txt: Added.
* media/track/track-webvtt-tc026-voice.html: Added.
* media/track/track-webvtt-tc027-empty-cue-expected.txt: Added.
* media/track/track-webvtt-tc027-empty-cue.html: Added.
* media/track/track-webvtt-tc028-unsupported-markup-expected.txt: Added.
* media/track/track-webvtt-tc028-unsupported-markup.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@100085 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/media/track/track-webvtt-tc004-magic-header.html b/LayoutTests/media/track/track-webvtt-tc004-magic-header.html
new file mode 100644
index 0000000..875bf15
--- /dev/null
+++ b/LayoutTests/media/track/track-webvtt-tc004-magic-header.html
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+        <script src=../media-file.js></script>
+        <script src=../video-test.js></script>
+        <script>            
+
+            numberOfTrackTests = 3;
+            
+            function trackLoaded()
+            {
+                numberOfTracksLoaded++;
+                if (numberOfTracksLoaded == numberOfTrackTests) {
+                    testTrack(0);
+                    testTrack(1);
+                    testTrackError(2);
+                }
+            }
+            
+            function testTrack(i)
+            {
+                findMediaElement();
+                var expected = 
+                {
+                    length : 2,
+                    tests:
+                    [
+                        {
+                            property : "id",
+                            values : [1, 2],
+                        },
+                        {
+                            property : "startTime",
+                            values : [0.0, 31.0],
+                        },
+                        {
+                            property : "endTime",
+                            values : [30.5, 1200.5],
+                        },
+                        {
+                            property : "getCueAsSource()",
+                            values : ["Bear is Coming!!!!!", "I said Bear is coming!!!!"],
+                        },
+                    ],
+                };
+                testCues(i, expected);
+
+                allTestsEnded();
+            }
+            
+            function testTrackError(i)
+            {
+                findMediaElement();
+                var expected = 
+                {
+                    length : 0,
+                    tests:
+                    [],
+                };
+                testCues(i, expected);
+
+                allTestsEnded();
+            }
+        </script>
+    </head>
+    <body>
+        <p>Tests that the magic file header "WEBVTT" leads to the file properly recognized as a WebVTT file.</p>
+        <video>
+            <track src="captions-webvtt/tc004-webvtt-file.vtt" onload="trackLoaded()">
+            <track src="captions-webvtt/tc004-webvtt-rubbish.vtt" onload="trackLoaded()">
+            <track src="captions-webvtt/tc004-no-webvtt.vtt" onerror="trackLoaded()">
+        </video>
+    </body>
+</html>
\ No newline at end of file