Bug 1283803 - part3 : rename function parseSignature. r=rillian
authorAlastor Wu <alwu@mozilla.com>
Tue, 19 Jul 2016 16:30:54 +0800
changeset 389891 4a0f37eba059b634f2b8be5faa150938117611d5
parent 389890 96fbf1b61d8fff513168e624d14d125c72742de2
child 389892 3cadccaea6c964c4ce036cd458a3418d365d3821
push id23555
push userg.maone@informaction.com
push dateWed, 20 Jul 2016 09:15:43 +0000
reviewersrillian
bugs1283803
milestone50.0a1
Bug 1283803 - part3 : rename function parseSignature. r=rillian MozReview-Commit-ID: ImBH5Xq4sJX
dom/media/webvtt/vtt.jsm
--- a/dom/media/webvtt/vtt.jsm
+++ b/dom/media/webvtt/vtt.jsm
@@ -1360,21 +1360,24 @@ this.EXPORTED_SYMBOLS = ["WebVTT"];
           // reference it.
           self.regionList.push({
             id: settings.get("id"),
             region: region
           });
         }
       }
 
-      // WebVTT parser algorithm step1 - step9.
-      function parseSignature(input) {
+      // Parsing the WebVTT signature, it contains parsing algo step1 to step9.
+      // See spec, https://w3c.github.io/webvtt/#file-parsing
+      function parseSignatureMayThrow(input) {
         let signature = collectNextLine();
         if (!/^WEBVTT([ \t].*)?$/.test(signature)) {
           throw new ParsingError(ParsingError.Errors.BadSignature);
+        } else {
+          self.state = "HEADER";
         }
       }
 
       // Parsing the region and style information.
       // See spec, https://w3c.github.io/webvtt/#collect-a-webvtt-block
       //
       // There are sereval things would appear in header,
       //   1. Region or Style setting
@@ -1417,18 +1420,17 @@ this.EXPORTED_SYMBOLS = ["WebVTT"];
           line = null
         }
         return line;
       }
 
       // 5.1 WebVTT file parsing.
       try {
         if (self.state === "INITIAL") {
-          parseSignature();
-          self.state = "HEADER";
+          parseSignatureMayThrow();
         }
 
         var line;
         if (self.state === "HEADER") {
           line = parseHeader();
         }
 
         while (self.buffer) {