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

Unified Diff: tests/html/js_test.dart

Issue 46533003: Add Event and Window to transferrable types (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/js/dartium/js_dartium.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/js_test.dart
diff --git a/tests/html/js_test.dart b/tests/html/js_test.dart
index e1aafae9bf828773cecb59329210ced0f874d3c3..6b37250aff9b20693f838d0cfbe9c54d00eecb4e 100644
--- a/tests/html/js_test.dart
+++ b/tests/html/js_test.dart
@@ -111,6 +111,10 @@ function getNewDivElement() {
return document.createElement("div");
}
+function getNewEvent() {
+ return new CustomEvent('test');
+}
+
function getNewBlob() {
var fileParts = ['<a id="a"><b id="b">hey!</b></a>'];
return new Blob(fileParts, {type : 'text/html'});
@@ -147,6 +151,12 @@ function addTestProperty(o) {
o.testProperty = "test";
}
+function fireClickEvent(w) {
+ var event = w.document.createEvent('Events');
+ event.initEvent('click', true, false);
+ w.document.body.dispatchEvent(event);
+}
+
function Bar() {
return "ret_value";
}
@@ -824,7 +834,34 @@ main() {
});
test('window', () {
- expect(context['window'] is Window, isFalse);
+ expect(context['window'] is Window, isTrue);
+ });
+
+ test('foreign browser objects should be proxied', () {
+ var iframe = new IFrameElement();
+ document.body.children.add(iframe);
+ var proxy = new JsObject.fromBrowserObject(iframe);
+
+ // Window
+ var contentWindow = proxy['contentWindow'];
+ expect(contentWindow, isNot(new isInstanceOf<Window>()));
+ expect(contentWindow, new isInstanceOf<JsObject>());
+
+ // Node
+ var foreignDoc = contentWindow['document'];
+ expect(foreignDoc, isNot(new isInstanceOf<Node>()));
+ expect(foreignDoc, new isInstanceOf<JsObject>());
+
+ // Event
+ var clicked = false;
+ foreignDoc['onclick'] = (e) {
+ expect(e, isNot(new isInstanceOf<Event>()));
+ expect(e, new isInstanceOf<JsObject>());
+ clicked = true;
+ };
+
+ context.callMethod('fireClickEvent', [contentWindow]);
+ expect(clicked, isTrue);
});
test('document', () {
@@ -842,6 +879,11 @@ main() {
expect(node is DivElement, isTrue);
});
+ test('Event', () {
+ var event = context.callMethod('getNewEvent');
+ expect(event is Event, true);
+ });
+
test('KeyRange', () {
if (IdbFactory.supported) {
var node = context.callMethod('getNewIDBKeyRange');
@@ -879,7 +921,7 @@ main() {
context['o'] = window;
var windowType = context['Window'];
expect(context.callMethod('isPropertyInstanceOf', ['o', windowType]),
- isFalse);
+ isTrue);
context.deleteProperty('o');
});
@@ -908,6 +950,14 @@ main() {
context.deleteProperty('o');
});
+ test('Event', () {
+ context['o'] = new CustomEvent('test');
+ var eventType = context['Event'];
+ expect(context.callMethod('isPropertyInstanceOf', ['o', eventType]),
+ isTrue);
+ context.deleteProperty('o');
+ });
+
test('KeyRange', () {
if (IdbFactory.supported) {
context['o'] = new KeyRange.only(1);
« no previous file with comments | « sdk/lib/js/dartium/js_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698