Clean attributes of mRoot between tests properly

This fixes commit https://github.com/chromium/dom-distiller/commit/f5070fd

BUG=483172
R=mdjones@chromium.org

Review URL: https://codereview.chromium.org/1784073002 .
diff --git a/javatests/org/chromium/distiller/DomDistillerJsTestCase.java b/javatests/org/chromium/distiller/DomDistillerJsTestCase.java
index 43dab5b..e5d4bc0 100644
--- a/javatests/org/chromium/distiller/DomDistillerJsTestCase.java
+++ b/javatests/org/chromium/distiller/DomDistillerJsTestCase.java
@@ -27,13 +27,19 @@
     protected void gwtSetUp() throws Exception {
         mRoot = Document.get().getDocumentElement();
         JsArray<Node> attrs = DomUtil.getAttributes(mRoot);
+        String[] attrNames = new String[attrs.length()];
         for (int i = 0; i < attrs.length(); i++) {
-            mRoot.removeAttribute(attrs.get(i).getNodeName());
+            attrNames[i] = attrs.get(i).getNodeName();
         }
+        for (int i = 0; i < attrNames.length; i++) {
+            mRoot.removeAttribute(attrNames[i]);
+        }
+        assertEquals(0, DomUtil.getAttributes(mRoot).length());
         NodeList<Node> children = mRoot.getChildNodes();
         for (int i = children.getLength() - 1; i >= 0; i--) {
             children.getItem(i).removeFromParent();
         }
+        assertEquals(0, mRoot.getChildNodes().getLength());
         mHead = Document.get().createElement("head");
         mRoot.appendChild(mHead);
         mBody = Document.get().createElement("body");
diff --git a/javatests/org/chromium/distiller/OpenGraphProtocolParserTest.java b/javatests/org/chromium/distiller/OpenGraphProtocolParserTest.java
index ada310d..6389000 100644
--- a/javatests/org/chromium/distiller/OpenGraphProtocolParserTest.java
+++ b/javatests/org/chromium/distiller/OpenGraphProtocolParserTest.java
@@ -434,20 +434,6 @@
         assertEquals("", parser.getDescription());
     }
 
-    @Override
-    protected void gwtSetUp() throws Exception {
-        super.gwtSetUp();
-
-        // Remove all attributes that specify prefix or namespace, so that each
-        // testcase starts with clean HTML and HEAD tags.  Otherwise. a testcase
-        // may run with the attributes set in a previous testcase, resulting in
-        // unexpected results.
-        mRoot.removeAttribute("prefix");
-        mRoot.removeAttribute("xmlns:tstog");
-        mRoot.removeAttribute("xmlns:tstpf");
-        mRoot.removeAttribute("xmlns:tsta");
-    }
-
     private void createDefaultTitle() {
         createMeta("og:title", "dummy title");
     }