Bug 709083 - Call DoneCreatingElement before children have been appended to the element. r=bzbarsky.
authorHenri Sivonen <hsivonen@iki.fi>
Fri, 03 Feb 2012 15:32:31 +0200
changeset 109278 53c74908b3120efca76187f3b0cf57e9a3ee6a45
parent 109277 8e8971f022efe13ca1a6dc44a23dba3e6364c91e
child 109279 69af84a809a05813bc0cde18356cf71189c609c8
push id2248
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 19:23:44 +0000
treeherdermozilla-aurora@118a3b748323 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs709083
milestone13.0a1
Bug 709083 - Call DoneCreatingElement before children have been appended to the element. r=bzbarsky.
accessible/tests/mochitest/name/test_browserui.xul
parser/html/nsHtml5TreeBuilderCppSupplement.h
parser/htmlparser/tests/mochitest/Makefile.in
parser/htmlparser/tests/mochitest/test_bug709083.html
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -462,16 +462,33 @@ nsHtml5TreeBuilder::elementPushed(PRInt3
     return;
   }
   if (aName == nsHtml5Atoms::body || aName == nsHtml5Atoms::frameset) {
     nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
     NS_ASSERTION(treeOp, "Tree op allocation failed.");
     treeOp->Init(eTreeOpStartLayout);
     return;
   }
+  if (aName == nsHtml5Atoms::input ||
+      aName == nsHtml5Atoms::button) {
+    if (!formPointer) {
+      // If form inputs don't belong to a form, their state preservation
+      // won't work right without an append notification flush at this
+      // point. See bug 497861.
+      mOpQueue.AppendElement()->Init(eTreeOpFlushPendingAppendNotifications);
+    }
+    mOpQueue.AppendElement()->Init(eTreeOpDoneCreatingElement, aElement);
+    return;
+  }
+  if (aName == nsHtml5Atoms::audio ||
+      aName == nsHtml5Atoms::video ||
+      aName == nsHtml5Atoms::menuitem) {
+    mOpQueue.AppendElement()->Init(eTreeOpDoneCreatingElement, aElement);
+    return;
+  }
 }
 
 void
 nsHtml5TreeBuilder::elementPopped(PRInt32 aNamespace, nsIAtom* aName, nsIContent** aElement)
 {
   NS_ASSERTION(aNamespace == kNameSpaceID_XHTML || aNamespace == kNameSpaceID_SVG || aNamespace == kNameSpaceID_MathML, "Element isn't HTML, SVG or MathML!");
   NS_ASSERTION(aName, "Element doesn't have local name!");
   NS_ASSERTION(aElement, "No element!");
@@ -539,45 +556,22 @@ nsHtml5TreeBuilder::elementPopped(PRInt3
       NS_ASSERTION(treeOp, "Tree op allocation failed.");
       treeOp->Init(eTreeOpFlushPendingAppendNotifications);
     }
     nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
     NS_ASSERTION(treeOp, "Tree op allocation failed.");
     treeOp->Init(eTreeOpDoneAddingChildren, aElement);
     return;
   }
-  if (aName == nsHtml5Atoms::input ||
-      aName == nsHtml5Atoms::button ||
-      aName == nsHtml5Atoms::menuitem) {
-    if (!formPointer) {
-      // If form inputs don't belong to a form, their state preservation
-      // won't work right without an append notification flush at this 
-      // point. See bug 497861.
-      nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
-      NS_ASSERTION(treeOp, "Tree op allocation failed.");
-      treeOp->Init(eTreeOpFlushPendingAppendNotifications);
-    }
-    nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
-    NS_ASSERTION(treeOp, "Tree op allocation failed.");
-    treeOp->Init(eTreeOpDoneCreatingElement, aElement);
-    return;
-  }
   if (aName == nsHtml5Atoms::meta && !fragment) {
     nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
     NS_ASSERTION(treeOp, "Tree op allocation failed.");
     treeOp->Init(eTreeOpProcessMeta, aElement);
     return;
   }
-  if (aName == nsHtml5Atoms::audio || aName == nsHtml5Atoms::video) {
-    nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
-    NS_ASSERTION(treeOp, "Tree op allocation failed.");
-    treeOp->Init(eTreeOpDoneCreatingElement, aElement);
-    return;
-  }   
-
   return;
 }
 
 void
 nsHtml5TreeBuilder::accumulateCharacters(const PRUnichar* aBuf, PRInt32 aStart, PRInt32 aLength)
 {
   PRInt32 newFillLen = charBufferLen + aLength;
   if (newFillLen > charBuffer.length) {
--- a/parser/htmlparser/tests/mochitest/Makefile.in
+++ b/parser/htmlparser/tests/mochitest/Makefile.in
@@ -90,16 +90,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug613662.html \
 		test_bug613662.xhtml \
 		test_bug642908.html \
 		file_bug642908.sjs \
 		test_bug645115.html \
 		test_bug655682.html \
 		file_bug655682.sjs \
 		test_viewsource.html \
+		test_bug709083.html \
 		test_bug715112.html \
 		test_bug715739.html \
 		$(NULL)
 
 # Disabled test due to orange on Linux
 #		test_bug568470.html \
 #		file_bug568470.sjs \
 #		file_bug568470-script.sjs \
new file mode 100644
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/test_bug709083.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=709083
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 709083</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=709083">Mozilla Bug 709083</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<video muted>
+<script type="application/javascript">
+
+/** Test for Bug 709083 **/
+
+ok(document.getElementsByTagName("video")[0].muted, "Should be muted already.");
+
+</script>
+</video>
+</pre>
+</body>
+</html>