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

Unified Diff: tests/html/custom/attribute_changed_callback_test.dart

Issue 25325004: Implementing CustomElement's attributeChanged callback. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/custom/entered_left_view_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/custom/attribute_changed_callback_test.dart
diff --git a/tests/html/custom/attribute_changed_callback_test.dart b/tests/html/custom/attribute_changed_callback_test.dart
index 618453c3eaa86408dd4533f56f62088cef275cba..7e16023c661a6d3b1cc028b48387ec34e3e0b057 100644
--- a/tests/html/custom/attribute_changed_callback_test.dart
+++ b/tests/html/custom/attribute_changed_callback_test.dart
@@ -3,9 +3,12 @@
// BSD-style license that can be found in the LICENSE file.
library attribute_changed_callback_test;
-import 'package:unittest/unittest.dart';
-import 'package:unittest/html_config.dart';
+
import 'dart:html';
+import 'dart:js' as js;
+import 'package:unittest/html_individual_config.dart';
+import 'package:unittest/unittest.dart';
+import '../utils.dart';
class A extends HtmlElement {
static final tag = 'x-a';
@@ -35,44 +38,75 @@ class B extends HtmlElement {
}
}
+// Pump custom events polyfill events.
+void customElementsTakeRecords() {
+ if (js.context.hasProperty('CustomElements')) {
+ js.context['CustomElements'].callMethod('takeRecords');
+ }
+}
+
main() {
- useHtmlConfiguration();
+ useHtmlIndividualConfiguration();
// Adapted from Blink's fast/dom/custom/attribute-changed-callback test.
- test('transfer attribute changed callback', () {
- document.register(A.tag, A);
- var element = new A();
-
- element.attributes['a'] = 'b';
- expect(A.attributeChangedInvocations, 1);
+ var registered = false;
+ setUp(() {
+ return loadPolyfills().then((_) {
+ if (!registered) {
+ registered = true;
+ document.register(A.tag, A);
+ document.register(B.tag, B);
+ }
+ });
});
- test('add, change and remove an attribute', () {
- document.register(B.tag, B);
- var b = new B();
- b.id = 'x';
- expect(B.invocations, ['created', 'id: null => x']);
+ group('fully supported', () {
+ test('transfer attribute changed callback', () {
+ var element = new A();
- B.invocations = [];
- b.attributes.remove('id');
- expect(B.invocations, ['id: x => null']);
+ element.attributes['a'] = 'b';
+ expect(A.attributeChangedInvocations, 1);
+ });
+
+ test('add, change and remove an attribute', () {
+ var b = new B();
+
+ B.invocations = [];
+ b.attributes['data-s'] = 't';
+ expect(B.invocations, ['data-s: null => t']);
+
+ b.attributes['data-v'] = 'w';
+ B.invocations = [];
+ b.attributes['data-v'] = 'x';
+ expect(B.invocations, ['data-v: w => x']);
+
+ B.invocations = [];
+ b.attributes['data-v'] = 'x';
+ expect(B.invocations, []);
+
+ b.attributes.remove('data-v');
+ expect(B.invocations, ['data-v: x => null']);
+ });
+ });
- B.invocations = [];
- b.attributes['data-s'] = 't';
- expect(B.invocations, ['data-s: null => t']);
+ group('unsupported_on_polyfill', () {
+ test('add, change ID', () {
+ var b = new B();
+ b.id = 'x';
+ expect(B.invocations, ['created', 'id: null => x']);
- B.invocations = [];
- b.classList.toggle('u');
- expect(B.invocations, ['class: null => u']);
+ B.invocations = [];
+ b.attributes.remove('id');
+ expect(B.invocations, ['id: x => null']);
+ });
- b.attributes['data-v'] = 'w';
- B.invocations = [];
- b.attributes['data-v'] = 'x';
- expect(B.invocations, ['data-v: w => x']);
+ test('add, change classes', () {
+ var b = new B();
- B.invocations = [];
- b.attributes['data-v'] = 'x';
- expect(B.invocations, []);
+ B.invocations = [];
+ b.classes.toggle('u');
+ expect(B.invocations, ['class: null => u']);
+ });
});
}
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/custom/entered_left_view_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698