Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: pkg/analyzer/test/src/task/html_test.dart

Issue 1516073002: Parse HTML files with keeping original attributes case. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/html.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.task.html_test; 5 library analyzer.test.src.task.html_test;
6 6
7 import 'package:analyzer/src/generated/source.dart'; 7 import 'package:analyzer/src/generated/source.dart';
8 import 'package:analyzer/src/task/html.dart'; 8 import 'package:analyzer/src/task/html.dart';
9 import 'package:analyzer/task/general.dart'; 9 import 'package:analyzer/task/general.dart';
10 import 'package:analyzer/task/html.dart'; 10 import 'package:analyzer/task/html.dart';
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 297
298 test_perform() { 298 test_perform() {
299 String code = r''' 299 String code = r'''
300 <!DOCTYPE html> 300 <!DOCTYPE html>
301 <html> 301 <html>
302 <head> 302 <head>
303 <title>test page</title> 303 <title>test page</title>
304 </head> 304 </head>
305 <body> 305 <body>
306 <h1>Test</h1> 306 <h1 myAttr='my value'>Test</h1>
307 </body> 307 </body>
308 </html> 308 </html>
309 '''; 309 ''';
310 AnalysisTarget target = newSource('/test.html', code); 310 AnalysisTarget target = newSource('/test.html', code);
311 computeResult(target, HTML_DOCUMENT); 311 computeResult(target, HTML_DOCUMENT);
312 expect(task, isParseHtmlTask); 312 expect(task, isParseHtmlTask);
313 expect(outputs[HTML_DOCUMENT], isNotNull);
314 expect(outputs[HTML_DOCUMENT_ERRORS], isEmpty); 313 expect(outputs[HTML_DOCUMENT_ERRORS], isEmpty);
314 // HTML_DOCUMENT
315 {
316 Document document = outputs[HTML_DOCUMENT];
317 expect(document, isNotNull);
318 // verify that attributes are not lower-cased
319 Element element = document.body.getElementsByTagName('h1').single;
320 expect(element.attributes['myAttr'], 'my value');
321 }
315 // LINE_INFO 322 // LINE_INFO
316 { 323 {
317 LineInfo lineInfo = outputs[LINE_INFO]; 324 LineInfo lineInfo = outputs[LINE_INFO];
318 expect(lineInfo, isNotNull); 325 expect(lineInfo, isNotNull);
319 { 326 {
320 int offset = code.indexOf('<!DOCTYPE'); 327 int offset = code.indexOf('<!DOCTYPE');
321 LineInfo_Location location = lineInfo.getLocation(offset); 328 LineInfo_Location location = lineInfo.getLocation(offset);
322 expect(location.lineNumber, 1); 329 expect(location.lineNumber, 1);
323 expect(location.columnNumber, 1); 330 expect(location.columnNumber, 1);
324 } 331 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 expect(bodyElement.localName, 'body'); 366 expect(bodyElement.localName, 'body');
360 // actual nodes 367 // actual nodes
361 expect(bodyElement.nodes, hasLength(4)); 368 expect(bodyElement.nodes, hasLength(4));
362 expect((bodyElement.nodes[0] as Element).localName, 'div'); 369 expect((bodyElement.nodes[0] as Element).localName, 'div');
363 expect((bodyElement.nodes[2] as Element).localName, 'span'); 370 expect((bodyElement.nodes[2] as Element).localName, 'span');
364 } 371 }
365 // it's OK to don't have DOCTYPE 372 // it's OK to don't have DOCTYPE
366 expect(outputs[HTML_DOCUMENT_ERRORS], isEmpty); 373 expect(outputs[HTML_DOCUMENT_ERRORS], isEmpty);
367 } 374 }
368 } 375 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/html.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698