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

Unified Diff: tests/html/event_customevent_test.dart

Issue 18811006: Fixing CustomEvent.detail leaks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
Index: tests/html/event_customevent_test.dart
diff --git a/tests/html/event_customevent_test.dart b/tests/html/event_customevent_test.dart
index dc2951e85811c686495b6da97bd21c468765324a..f7740e816288112f9099ee0d692c7fb5ce887f52 100644
--- a/tests/html/event_customevent_test.dart
+++ b/tests/html/event_customevent_test.dart
@@ -8,22 +8,6 @@ import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html';
-// TODO(nweiz): Make this private to testEvents when Frog supports closures with
-// optional arguments.
-eventTest(String name, Event eventFn(), void validate(Event),
- [String type = 'foo']) {
- test(name, () {
- final el = new Element.tag('div');
- var fired = false;
- el.on[type].add((ev) {
- fired = true;
- validate(ev);
- });
- el.on[type].dispatch(eventFn());
- expect(fired, isTrue, reason: 'Expected event to be dispatched.');
- });
-}
-
main() {
useHtmlConfiguration();
@@ -34,12 +18,32 @@ main() {
var fired = false;
provider.forTarget(el).listen((ev) {
fired = true;
- expect(ev.detail, 'detail');
+ expect(ev.detail, {'type': 'detail'});
});
var ev = new CustomEvent('foo', canBubble: false, cancelable: false,
- detail: 'detail');
+ detail: {'type': 'detail'});
el.dispatchEvent(ev);
expect(fired, isTrue);
});
+
+ test('custom events from JS', () {
+ var scriptContents = '''
+ var event = document.createEvent("CustomEvent");
+ event.initCustomEvent("js_custom_event", true, true, {type: "detail"});
+ window.dispatchEvent(event);
+ ''';
+
+ var fired = false;
+ window.on['js_custom_event'].listen((ev) {
+ fired = true;
+ expect(ev.detail, {'type': 'detail'});
+ });
+
+ var script = new ScriptElement();
+ script.text = scriptContents;
+ document.body.append(script);
+
+ expect(fired, isTrue);
+ });
}

Powered by Google App Engine
This is Rietveld 408576698