Bug 1423098 - Ignore invalid time value specifications rather than failing; r?dholbert draft
authorBrian Birtles <birtles@gmail.com>
Thu, 14 Dec 2017 09:58:24 -0600
changeset 711766 e3c90f075eeb9c2e5e68f1b473a2a00104f492d2
parent 710476 a44e04c26913c97a61375a6fcd5867b965e1ce2a
child 711767 316d353eaa9f6348dfa2d53e2522128793ef922a
push id93135
push userbbirtles@mozilla.com
push dateThu, 14 Dec 2017 16:52:24 +0000
reviewersdholbert
bugs1423098
milestone59.0a1
Bug 1423098 - Ignore invalid time value specifications rather than failing; r?dholbert This matches the behavior of Chrome at least, and should reduce compatibility risk when we remove accessKey support in the next patch in this series by ensuring that specifications such as begin="3s; accessKey(s)" will continue to run the animation. MozReview-Commit-ID: E6sh48yrYSm
dom/smil/nsSMILTimedElement.cpp
dom/smil/test/test_smilTiming.xhtml
--- a/dom/smil/nsSMILTimedElement.cpp
+++ b/dom/smil/nsSMILTimedElement.cpp
@@ -1319,31 +1319,33 @@ nsSMILTimedElement::SetBeginOrEndSpec(co
 
   AutoIntervalUpdateBatcher updateBatcher(*this);
 
   nsCharSeparatedTokenizer tokenizer(aSpec, ';');
   if (!tokenizer.hasMoreTokens()) { // Empty list
     return NS_ERROR_FAILURE;
   }
 
-  nsresult rv = NS_OK;
-  while (tokenizer.hasMoreTokens() && NS_SUCCEEDED(rv)) {
+  bool hadFailure = false;
+  while (tokenizer.hasMoreTokens()) {
     nsAutoPtr<nsSMILTimeValueSpec>
       spec(new nsSMILTimeValueSpec(*this, aIsBegin));
-    rv = spec->SetSpec(tokenizer.nextToken(), aContextNode);
+    nsresult rv = spec->SetSpec(tokenizer.nextToken(), aContextNode);
     if (NS_SUCCEEDED(rv)) {
       timeSpecsList.AppendElement(spec.forget());
+    } else {
+      hadFailure = true;
     }
   }
 
-  if (NS_FAILED(rv)) {
-    ClearSpecs(timeSpecsList, instances, aRemove);
-  }
-
-  return rv;
+  // The return value from this function is only used to determine if we should
+  // print a console message or not, so we return failure if we had one or more
+  // failures but we don't need to differentiate between different types of
+  // failures or the number of failures.
+  return hadFailure ? NS_ERROR_FAILURE : NS_OK;
 }
 
 namespace
 {
   // Adaptor functor for RemoveInstanceTimes that allows us to use function
   // pointers instead.
   // Without this we'd have to either templatize ClearSpecs and all its callers
   // or pass bool flags around to specify which removal function to use here.
--- a/dom/smil/test/test_smilTiming.xhtml
+++ b/dom/smil/test/test_smilTiming.xhtml
@@ -127,20 +127,20 @@ function main() {
   testCases.push(StartTimeTest('05:40\u30D5', 'none'));
   testCases.push(StartTimeTest('05:40β', 'none'));
 
   // List syntax
   testCases.push(StartTimeTest('3', 3));
   testCases.push(StartTimeTest('3;', 3));
   testCases.push(StartTimeTest('3; ', 3));
   testCases.push(StartTimeTest('3 ; ', 3));
-  testCases.push(StartTimeTest('3;;', 'none'));
-  testCases.push(StartTimeTest('3;; ', 'none'));
-  testCases.push(StartTimeTest(';3', 'none'));
-  testCases.push(StartTimeTest(' ;3', 'none'));
+  testCases.push(StartTimeTest('3;;', 3));
+  testCases.push(StartTimeTest('3;; ', 3));
+  testCases.push(StartTimeTest(';3', 3));
+  testCases.push(StartTimeTest(' ;3', 3));
   testCases.push(StartTimeTest('3;4', 3));
   testCases.push(StartTimeTest(' 3 ; 4 ', 3));
 
   // List syntax on end times
   testCases.push({
     'attr' : { 'begin': '0s',
                'end': '1s; 2s' },
     'times': [ [ 0, 0 ],