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

Unified Diff: tests/compiler/dart2js_native/dispatch_property_initialization_test.dart

Issue 2359023002: Add another test for initializing dispatchPropertyName that runs outside the browser (Closed)
Patch Set: typo Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js_native/dispatch_property_initialization_test.dart
diff --git a/tests/compiler/dart2js_native/dispatch_property_initialization_test.dart b/tests/compiler/dart2js_native/dispatch_property_initialization_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..174eaf872af3c32f171ca9e487a3d24649648b59
--- /dev/null
+++ b/tests/compiler/dart2js_native/dispatch_property_initialization_test.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// 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.
+
+// Test for initialization of dispatchPropertyName.
+
+import "package:expect/expect.dart";
+import 'dart:_foreign_helper' show JS;
+import 'dart:_js_helper' show Native;
+
+@Native("Foo")
+class Foo {
+ String method(String x) native;
+}
+
+makeFoo() native;
+
+void setup() native r"""
+function Foo() {}
+Foo.prototype.method = function(x) { return 'Foo ' + x; }
+
+self.makeFoo = function() { return new Foo(); }
+""";
+
+
+main() {
+ setup();
+
+ // If the dispatchPropertyName is uninitialized, it will be `undefined` or
+ // `null` instead of the secret string or Symbol. These properties on
+ // `Object.prototype` will be retrieved by the lookup instead of `undefined`
+ // for the dispatch record.
+ JS('', r'self.Object.prototype["undefined"] = {}');
+ JS('', r'self.Object.prototype["null"] = {}');
+ Expect.equals('Foo A', makeFoo().method('A'));
+
+ // Slightly different version that has malformed dispatch records.
+ JS('', r'self.Object.prototype["undefined"] = {p: false}');
+ JS('', r'self.Object.prototype["null"] = {p: false}');
+ Expect.equals('Foo B', makeFoo().method('B'));
+}
« 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