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

Side by Side Diff: tests/html/custom/document_register_type_extensions_test.dart

Issue 29033003: Fixing custom element type extensions in Dartium to have correct native type ID (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/scripts/systemnative.py » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 document_register_type_extensions_test; 5 library document_register_type_extensions_test;
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_individual_config.dart'; 7 import 'package:unittest/html_individual_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import '../utils.dart'; 9 import '../utils.dart';
10 10
(...skipping 27 matching lines...) Expand all
38 factory Qux() => new Element.tag('input', tag); 38 factory Qux() => new Element.tag('input', tag);
39 Qux.created() : super.created(); 39 Qux.created() : super.created();
40 } 40 }
41 41
42 class FooBad extends DivElement { 42 class FooBad extends DivElement {
43 static const tag = 'x-foo'; 43 static const tag = 'x-foo';
44 factory FooBad() => new Element.tag('div', tag); 44 factory FooBad() => new Element.tag('div', tag);
45 FooBad.created() : super.created(); 45 FooBad.created() : super.created();
46 } 46 }
47 47
48 class MyCanvas extends CanvasElement {
49 static const tag = 'my-canvas';
50 factory MyCanvas() => new Element.tag('canvas', tag);
51
52 MyCanvas.created() : super.created();
53
54 void fillAsRed() {
55 width = 100;
56 height = 100;
57
58 var context = this.getContext('2d');
59 context.fillStyle = 'red';
60 context.fillRect(0, 0, width, height);
61 context.fill();
62
63 var data = context.getImageData(0, 0, 1, 1).data;
64 expect(data, [255, 0, 0, 255]);
65 }
66 }
67
48 main() { 68 main() {
49 useHtmlIndividualConfiguration(); 69 useHtmlIndividualConfiguration();
50 70
51 // Adapted from Blink's fast/dom/custom/document-register-type-extension test. 71 // Adapted from Blink's fast/dom/custom/document-register-type-extension test.
52 72
53 var testForm = new FormElement()..id = 'testForm'; 73 var testForm = new FormElement()..id = 'testForm';
54 document.body.append(testForm); 74 document.body.append(testForm);
55 75
56 var isFormControl = (element) { 76 var isFormControl = (element) {
57 testForm.append(element); 77 testForm.append(element);
58 return element.form == testForm; 78 return element.form == testForm;
59 }; 79 };
60 80
61 var registeredTypes = false; 81 var registeredTypes = false;
62 void registerTypes() { 82 void registerTypes() {
63 if (registeredTypes) { 83 if (registeredTypes) {
64 return; 84 return;
65 } 85 }
66 registeredTypes = true; 86 registeredTypes = true;
67 document.register(Foo.tag, Foo); 87 document.register(Foo.tag, Foo);
68 document.register(Bar.tag, Bar, extendsTag: 'input'); 88 document.register(Bar.tag, Bar, extendsTag: 'input');
69 document.register(Baz.tag, Baz); 89 document.register(Baz.tag, Baz);
70 document.register(Qux.tag, Qux, extendsTag: 'input'); 90 document.register(Qux.tag, Qux, extendsTag: 'input');
91 document.register(MyCanvas.tag, MyCanvas, extendsTag: 'canvas');
71 } 92 }
72 93
73 setUp(loadPolyfills); 94 setUp(loadPolyfills);
74 95
75 group('registration', () { 96 group('registration', () {
76 setUp(registerTypes); 97 setUp(registerTypes);
77 98
78 test('cannot register twice', () { 99 test('cannot register twice', () {
79 expect(() => document.register(FooBad.tag, Foo), throws); 100 expect(() => document.register(FooBad.tag, Foo), throws);
80 }); 101 });
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // Polyfill does not convert parsed unregistered custom elements to 281 // Polyfill does not convert parsed unregistered custom elements to
261 // HtmlElement. 282 // HtmlElement.
262 // expect(namedBarParsed is UnknownElement, isFalse); 283 // expect(namedBarParsed is UnknownElement, isFalse);
263 expect(namedBarParsed is HtmlElement, isTrue); 284 expect(namedBarParsed is HtmlElement, isTrue);
264 285
265 var divBarParsed = createElementFromHtml('<div is=x-bar>'); 286 var divBarParsed = createElementFromHtml('<div is=x-bar>');
266 expect(divBarParsed is Bar, isFalse); 287 expect(divBarParsed is Bar, isFalse);
267 expect(divBarParsed is DivElement, isTrue); 288 expect(divBarParsed is DivElement, isTrue);
268 }); 289 });
269 }); 290 });
291
292 group('functional', () {
293 setUp(registerTypes);
294
295 test('canvas', () {
296 var canvas = new MyCanvas();
297 canvas.fillAsRed();
298 });
299 });
270 } 300 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698