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

Unified Diff: pkg/polymer/test/visibility_test.dart

Issue 723393003: update to polymer js 0.5.1 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: little bit of cleanup Created 6 years, 1 month 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
Index: pkg/polymer/test/visibility_test.dart
diff --git a/pkg/polymer/test/visibility_test.dart b/pkg/polymer/test/visibility_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7d16654e4130df80fa3bbfdee83e4f91b040f11c
--- /dev/null
+++ b/pkg/polymer/test/visibility_test.dart
@@ -0,0 +1,65 @@
+// 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:async';
+import 'dart:html';
+import 'dart:js';
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'package:polymer/polymer.dart';
+
+var done = new Completer();
+
+class MyModel {
+ String value;
+ MyModel(this.value);
+}
+
+main() => initPolymer().run(() {
+ useHtmlConfiguration();
+
+ setUp(() => Polymer.onReady);
+
+ test('Polymer.import', () {
+ AutoBindingElement t = querySelector('#myTemplate');
+ var myModel = new MyModel('');
+ t.model = myModel;
+ t.on['template-bound'].listen((_) {
+ // TODO(jakemac): Is this check necessary on the dart side?
Siggi Cherem (dart-lang) 2014/11/25 17:53:41 nope, we can remove it :)
+ var hasObjectObserve = context['Observer']['hasObjectObserve'];
+ if (hasObjectObserve != null && hasObjectObserve) {
+ myModel.value = 'test skipped due to Object.observe';
+ done.complete();
+ } else {
+ myModel.value = 'a';
+ var s = document.querySelector('span');
+ var a = document.querySelector('a');
+ document.on['visibilitychange'].listen((_) {
Siggi Cherem (dart-lang) 2014/11/25 17:53:41 on['visibilitychange'] => onVisibilityChange
+ print('visiblity change!');
+ });
+ window.on['message'].listen((e) {
Siggi Cherem (dart-lang) 2014/11/25 17:53:41 on['message'] => onMessage
+ if (e.data == 'popup-initialized') {
+ print('got popup initialized');
+ myModel.value = 'b';
+ new Future.delayed(new Duration(milliseconds: 300), () {
+ expect(document.hidden, true);
+ expect(s.text, 'a',
+ reason: 'change did not occur, and shouldn\'t');
+ print('send close');
+ e.source.postMessage('close', window.location.origin);
+ });
+ }
+ if (e.data == 'popup-closed') {
+ new Future.delayed(new Duration(milliseconds: 300), () {
Siggi Cherem (dart-lang) 2014/11/25 17:53:41 not sure why we need the 300ms here and above?
+ expect(s.text, 'b', reason: 'change did occur, and should');
+ done.complete();
+ });
+ }
+ });
+ }
+ });
+ return done;
Siggi Cherem (dart-lang) 2014/11/25 17:53:41 return done.future;
+ });
+});
+

Powered by Google App Engine
This is Rietveld 408576698