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

Side by Side Diff: tests/html/event_customevent_test.dart

Issue 27536010: Fixing custom event test on IE (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library EventCustomEventTest; 5 library EventCustomEventTest;
6 6
7 import '../../pkg/unittest/lib/unittest.dart'; 7 import '../../pkg/unittest/lib/unittest.dart';
8 import '../../pkg/unittest/lib/html_config.dart'; 8 import '../../pkg/unittest/lib/html_config.dart';
9 import 'dart:html'; 9 import 'dart:html';
10 import 'dart:js' as js;
10 11
11 class DartPayloadData { 12 class DartPayloadData {
12 final dartValue; 13 final dartValue;
13 14
14 DartPayloadData(this.dartValue); 15 DartPayloadData(this.dartValue);
15 } 16 }
16 17
17 main() { 18 main() {
18 useHtmlConfiguration(); 19 useHtmlConfiguration();
19 20
(...skipping 27 matching lines...) Expand all
47 }); 48 });
48 49
49 var script = new ScriptElement(); 50 var script = new ScriptElement();
50 script.text = scriptContents; 51 script.text = scriptContents;
51 document.body.append(script); 52 document.body.append(script);
52 53
53 expect(fired, isTrue); 54 expect(fired, isTrue);
54 }); 55 });
55 56
56 test('custom events to JS', () { 57 test('custom events to JS', () {
58 expect(js.context['gotDartEvent'], isNull);
57 var scriptContents = ''' 59 var scriptContents = '''
58 window.addEventListener('dart_custom_event', function(e) { 60 window.addEventListener('dart_custom_event', function(e) {
59 if (e.detail == 'dart_message') { 61 if (e.detail == 'dart_message') {
60 e.preventDefault(); 62 e.preventDefault();
63 window.gotDartEvent = true;
61 } 64 }
65 window.console.log('here' + e.detail);
vsm 2013/10/16 23:49:01 Do we need this print?
blois 2013/10/17 00:05:32 Nope, gone.
62 }, false);'''; 66 }, false);''';
63 67
64 document.body.append(new ScriptElement()..text = scriptContents); 68 document.body.append(new ScriptElement()..text = scriptContents);
65 69
66 var event = new CustomEvent('dart_custom_event', detail: 'dart_message'); 70 var event = new CustomEvent('dart_custom_event', detail: 'dart_message');
67 window.dispatchEvent(event); 71 window.dispatchEvent(event);
68 expect(event.defaultPrevented, isTrue); 72 expect(js.context['gotDartEvent'], isTrue);
69 }); 73 });
70 74
71 test('custom data to Dart', () { 75 test('custom data to Dart', () {
72 var data = new DartPayloadData(666); 76 var data = new DartPayloadData(666);
73 var event = new CustomEvent('dart_custom_data_event', detail: data); 77 var event = new CustomEvent('dart_custom_data_event', detail: data);
74 78
75 var future = window.on['dart_custom_data_event'].first.then((_) { 79 var future = window.on['dart_custom_data_event'].first.then((_) {
76 expect(event.detail.dartValue, 666); 80 expect(event.detail.dartValue, 666);
77 }); 81 });
78 82
79 document.body.dispatchEvent(event); 83 document.body.dispatchEvent(event);
80 return future; 84 return future;
81 }); 85 });
82 } 86 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698