ef6273cba0
This is a migration of 13 Chrome release about 1.5 years of Chrome releases. Update PYTHON scripts for cleaner and easier rolling. Here's a doc on the changes that might affect Dart users: https://docs.google.com/document/d/1Kj0nk3SueO3JKub8im7z3znu9j5oiI7vf49ejZrMxuE/edit# Change-Id: I768fbd09b04fe6884af36ac102d5813f67bae426 Reviewed-on: https://dart-review.googlesource.com/24501 Commit-Queue: Terry Lucas <terry@google.com> Reviewed-by: Terry Lucas <terry@google.com>
68 lines
1.8 KiB
Dart
68 lines
1.8 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'dart:html';
|
|
@MirrorsUsed(targets: const [A, B])
|
|
import 'dart:mirrors';
|
|
|
|
import 'package:unittest/html_individual_config.dart';
|
|
import 'package:unittest/unittest.dart';
|
|
|
|
import 'utils.dart';
|
|
|
|
/// Regression test for a tricky mirrors+custom_elements issue:
|
|
/// dart2js mirrors cache dispatch information on the Object's constructor.
|
|
/// This was failing for custom elements on IE 10, because the constructor was
|
|
/// HTMLUnknownElement for all of them. So mirrors called the wrong method.
|
|
main() {
|
|
useHtmlIndividualConfiguration();
|
|
|
|
var registered = false;
|
|
setUp(() => customElementsReady.then((_) {
|
|
if (!registered) {
|
|
registered = true;
|
|
document.registerElement2(A.tag, {'prototype': A});
|
|
document.registerElement2(B.tag, {'prototype': B});
|
|
}
|
|
}));
|
|
|
|
test('dynamic dispatch', () {
|
|
var a = new A();
|
|
expect(a.fooBar, 1);
|
|
reflect(a).setField(#fooBar, 123);
|
|
expect(a.fooBar, 123);
|
|
|
|
// Even though A was set first, B.fooBar= should dispatch to B.
|
|
var b = new B();
|
|
expect(b.fooBar, 2);
|
|
expect(b._fooBarSet, 0);
|
|
reflect(b).setField(#fooBar, 123);
|
|
expect(b.fooBar, 123);
|
|
expect(b._fooBarSet, 1);
|
|
});
|
|
}
|
|
|
|
class A extends HtmlElement {
|
|
static final tag = 'x-a';
|
|
factory A() => new Element.tag(tag);
|
|
A.created() : super.created();
|
|
|
|
int fooBar = 1;
|
|
}
|
|
|
|
class B extends HtmlElement {
|
|
static final tag = 'x-b';
|
|
factory B() => new Element.tag(tag);
|
|
B.created() : super.created();
|
|
|
|
int _fooBar = 2;
|
|
int _fooBarSet = 0;
|
|
|
|
int get fooBar => _fooBar;
|
|
set fooBar(value) {
|
|
_fooBarSet++;
|
|
_fooBar = value;
|
|
}
|
|
}
|