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

Side by Side Diff: tests/compiler/dart2js_native/fake_thing_test.dart

Issue 23587015: Test for JS objects spoofing Dart objects (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/compiler/dart2js_native/dart2js_native.status ('k') | 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
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 import "package:expect/expect.dart";
6
7 // Test that native objects cannot accidentally or maliciously be mistaken for
8 // Dart objects.
9
10 class Thing {
11 }
12
13 make1() native;
14 make2() native;
15
16 void setup() native r"""
17 function A() {}
18 A.prototype.$isThing = true;
19 make1 = function(){return new A;};
20 make2 = function(){return {$isThing: true}};
21 """;
22
23 var inscrutable;
24 main() {
25 setup();
26 inscrutable = (x) => x;
27
28 var a = new Thing();
29 var b = make1();
30 var c = make2();
31 Expect.isTrue(inscrutable(a) is Thing);
32 Expect.isFalse(inscrutable(b) is Thing);
33 Expect.isFalse(inscrutable(c) is Thing);
34 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/dart2js_native.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698