fix parse error with foreignObject end tag

it appears we inherited this from html5lib:
https://github.com/html5lib/html5lib-python/blob/5e3d432998b027cd2d200446f157d13a3461a92b/html5lib/html5parser.py#L2448
You'll notice the node.name.translate(asciiUpper2Lower) immediately below, in the same comparison

Most likely, this is not caught because it's not common to display HTML parse errors, and the actual tree construction is correct.

This fix does match the spec:
https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inforeign
See "Any other end tag, step 2":
> If node's tag name, converted to ASCII lowercase, is not the same as the tag name of the token, then this is a parse error.

We were missing the converted to lowercase step.

R=sigmund@google.com

Review URL: https://codereview.chromium.org//1222713008.
diff --git a/lib/parser.dart b/lib/parser.dart
index d81f888..113a1dd 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -3438,7 +3438,7 @@
   Token processEndTag(EndTagToken token) {
     var nodeIndex = tree.openElements.length - 1;
     var node = tree.openElements.last;
-    if (node.localName != token.name) {
+    if (asciiUpper2Lower(node.localName) != token.name) {
       parser.parseError(token.span, "unexpected-end-tag", {"name": token.name});
     }
 
diff --git a/test/parser_feature_test.dart b/test/parser_feature_test.dart
index 538113d..568819b 100644
--- a/test/parser_feature_test.dart
+++ b/test/parser_feature_test.dart
@@ -293,6 +293,20 @@
     expect(e.text, 'bar');
   });
 
+  test('foreignObject end tag', () {
+    var p = new HtmlParser('''
+<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"
+     version="1.1">
+    <foreignObject width="320px" height="200px">
+        <x-flow></x-flow>
+    </foreignObject>
+</svg>''');
+    var doc = p.parseFragment();
+    expect(p.errors, isEmpty);
+    var svg = doc.querySelector('svg');
+    expect(svg.children[0].children[0].localName, 'x-flow');
+  });
+
   group('Encoding pre-parser', () {
     getEncoding(s) => new EncodingParser(s.codeUnits).getEncoding();