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

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

Issue 112613003: Fix for dart2js mirrors caching with custom elements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « pkg/custom_element/lib/custom-elements.min.js ('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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library tests.html.mirrors_test;
6
7 import 'dart:mirrors';
8 import 'dart:html';
9 import 'package:unittest/unittest.dart';
10 import 'package:unittest/html_config.dart';
11 import '../utils.dart';
12
13 /// Regression test for a tricky mirrors+custom_elements issue:
14 /// dart2js mirrors cache dispatch information on the Object's constructor.
15 /// This was failing for custom elements on IE 10, because the constructor was
16 /// HTMLUnknownElement for all of them. So mirrors called the wrong method.
17 main() {
18 useHtmlConfiguration();
19
20 var registered = false;
21 setUp(() => loadPolyfills().then((_) {
22 if (!registered) {
23 registered = true;
24 document.register(A.tag, A);
25 document.register(B.tag, B);
26 }
27 }));
28
29 test('dynamic dispatch', () {
30 var a = new A();
31 expect(a.fooBar, 1);
32 reflect(a).setField(#fooBar, 123);
33 expect(a.fooBar, 123);
34
35 // Even though A was set first, B.fooBar= should dispatch to B.
36 var b = new B();
37 expect(b.fooBar, 2);
38 expect(b._fooBarSet, 0);
39 reflect(b).setField(#fooBar, 123);
40 expect(b.fooBar, 123);
41 expect(b._fooBarSet, 1);
42 });
43 }
44
45 class A extends HtmlElement {
46 static final tag = 'x-a';
47 factory A() => new Element.tag(tag);
48 A.created() : super.created();
49
50 int fooBar = 1;
51 }
52
53 class B extends HtmlElement {
54 static final tag = 'x-b';
55 factory B() => new Element.tag(tag);
56 B.created() : super.created();
57
58 int _fooBar = 2;
59 int _fooBarSet = 0;
60
61 int get fooBar => _fooBar;
62 set fooBar(value) {
63 _fooBarSet++;
64 _fooBar = value;
65 }
66 }
OLDNEW
« no previous file with comments | « pkg/custom_element/lib/custom-elements.min.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698