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

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

Issue 11553015: Add a fall-back for novel HTML Elements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
ngeoffray 2012/12/12 08:14:10 2011 is so almost 2 years ago :-)
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 // Test to see if novel HTML tags are interpreted as HTMLElement.
6
7 class Element native "*HTMLElement" {
8 String foo(int x) => '[${bar(x+1)}]';
9 String bar(int x) native;
10 }
11
12 makeE() native;
13 makeF() native;
14
15 void setup() native """
16 // A novel HTML element.
17 function HTMLGoofyElement(){}
18 HTMLGoofyElement.prototype.bar = function(a){return 'Goofy.foo(' + a + ')';}
19 makeE = function(){return new HTMLGoofyElement};
20
21 // A non-HTML element with a misleading name.
22 function HTMLFakeyElement(){}
23 HTMLFakeyElement.prototype.bar = function(a){return 'Fakey.foo(' + a + ')';}
24 makeF = function(){return new HTMLFakeyElement};
25
26 // Make the HTMLGoofyElement look like a real host object.
27 var theRealObjectToString = Object.prototype.toString;
28 Object.prototype.toString = function() {
29 if (this instanceof HTMLGoofyElement) return '[object HTMLGoofyElement]';
30 return theRealObjectToString.call(this);
31 }
32 """;
33
34
35 main() {
36 setup();
37
38 print(123);
kasperl 2012/12/12 06:43:50 Is this needed?
39 var e = makeE();
40 Expect.equals('[Goofy.foo(11)]', e.foo(10));
41
42 var f = makeF();
43 expectNoSuchMethod(() => f.foo(20), 'f.foo(20) should fail');
44 }
45
46 expectNoSuchMethod(action, note) {
kasperl 2012/12/12 06:43:50 Can you use Expect.throws?
47 bool caught = false;
48 try {
49 action();
50 } catch (ex) {
51 caught = true;
52 Expect.isTrue(ex is NoSuchMethodError, note);
53 }
54 Expect.isTrue(caught, note);
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698