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

Unified Diff: tests/html/js_interop_element_test.dart

Issue 10883037: Serialize Elements through PortSync (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix line length Created 8 years, 4 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 | « lib/html/src/Isolates.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_interop_element_test.dart
diff --git a/tests/html/js_interop_obj_invoke_test.dart b/tests/html/js_interop_element_test.dart
similarity index 51%
copy from tests/html/js_interop_obj_invoke_test.dart
copy to tests/html/js_interop_element_test.dart
index 77a230d1fc452e884d2f0fc770239a77f9fa6c5a..622ee9282026dea698db13273bc6211aa2088fa0 100644
--- a/tests/html/js_interop_obj_invoke_test.dart
+++ b/tests/html/js_interop_element_test.dart
@@ -2,7 +2,7 @@
// 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
-#library('JsInteropObjInvokeTest');
+#library('JsInteropElementTest');
#import('../../pkg/unittest/unittest.dart');
#import('../../pkg/unittest/html_config.dart');
#import('dart:html');
@@ -15,37 +15,47 @@ injectSource(code) {
document.body.nodes.add(script);
}
-var jsProxyTest = """
- function TestType(x) {
- this.x = x;
- }
- TestType.prototype.razzle = function () {
- return this.x * 2;
- }
- var data = new TestType(21);
+var jsElementTest = """
+ var canvas = document.createElement('canvas');
+ document.body.appendChild(canvas);
var port = window.lookupPort('test1');
- port.callSync(data);
+ port.callSync(canvas);
+""";
+
+var dartElementTest = """
+ var port = new ReceivePortSync();
+ port.receive(function (data) {
+ return (data instanceof HTMLDivElement);
+ });
+ window.registerPort('test2', port.toSendPort());
""";
main() {
useHtmlConfiguration();
- test('js-proxy', () {
+ test('js-element', () {
int invoked = 0;
var port = new ReceivePortSync();
port.receive((data) {
- expect(data.x, equals(21));
- expect(data.razzle(), equals(42));
- data.x = 100;
- expect(data.razzle(), equals(200));
-
+ expect(data is CanvasElement);
++invoked;
});
window.registerPort('test1', port.toSendPort());
- injectSource(jsProxyTest);
+ injectSource(jsElementTest);
expect(invoked, equals(1));
});
+
+ test('dart-element', () {
+ injectSource(dartElementTest);
+
+ var port = window.lookupPort('test2');
+ var div = new DivElement();
+ var canvas = new CanvasElement(100,100);
+ document.body.nodes.addAll([div, canvas]);
+ expect(port.callSync(div));
+ expect(!port.callSync(canvas));
+ });
}
« no previous file with comments | « lib/html/src/Isolates.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698