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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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 import 'dart:async';
6 import 'dart:html';
7 import 'dart:js';
8 import 'package:unittest/unittest.dart';
9 import 'package:unittest/html_config.dart';
10 import 'package:polymer/polymer.dart';
11
12 var done = new Completer();
13
14 class MyModel {
15 String value;
16 MyModel(this.value);
17 }
18
19 main() => initPolymer().run(() {
20 useHtmlConfiguration();
21
22 setUp(() => Polymer.onReady);
23
24 test('Polymer.import', () {
25 AutoBindingElement t = querySelector('#myTemplate');
26 var myModel = new MyModel('');
27 t.model = myModel;
28 t.on['template-bound'].listen((_) {
29 // 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 :)
30 var hasObjectObserve = context['Observer']['hasObjectObserve'];
31 if (hasObjectObserve != null && hasObjectObserve) {
32 myModel.value = 'test skipped due to Object.observe';
33 done.complete();
34 } else {
35 myModel.value = 'a';
36 var s = document.querySelector('span');
37 var a = document.querySelector('a');
38 document.on['visibilitychange'].listen((_) {
Siggi Cherem (dart-lang) 2014/11/25 17:53:41 on['visibilitychange'] => onVisibilityChange
39 print('visiblity change!');
40 });
41 window.on['message'].listen((e) {
Siggi Cherem (dart-lang) 2014/11/25 17:53:41 on['message'] => onMessage
42 if (e.data == 'popup-initialized') {
43 print('got popup initialized');
44 myModel.value = 'b';
45 new Future.delayed(new Duration(milliseconds: 300), () {
46 expect(document.hidden, true);
47 expect(s.text, 'a',
48 reason: 'change did not occur, and shouldn\'t');
49 print('send close');
50 e.source.postMessage('close', window.location.origin);
51 });
52 }
53 if (e.data == 'popup-closed') {
54 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?
55 expect(s.text, 'b', reason: 'change did occur, and should');
56 done.complete();
57 });
58 }
59 });
60 }
61 });
62 return done;
Siggi Cherem (dart-lang) 2014/11/25 17:53:41 return done.future;
63 });
64 });
65
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698