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

Unified Diff: test/codegen/lib/html/hidden_dom_1_test.dart

Issue 1930043002: Add all dart:html tests from the sdk to test/codegen. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: ptal Created 4 years, 8 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 | « test/codegen/lib/html/geolocation_test.dart ('k') | test/codegen/lib/html/hidden_dom_2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/lib/html/hidden_dom_1_test.dart
diff --git a/test/codegen/lib/html/hidden_dom_1_test.dart b/test/codegen/lib/html/hidden_dom_1_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..120136b5a3da6069887ad8d67cd68acb304979d3
--- /dev/null
+++ b/test/codegen/lib/html/hidden_dom_1_test.dart
@@ -0,0 +1,45 @@
+library HiddenDom1Test;
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'dart:html';
+
+// Test that the dart:html API does not leak native jsdom methods:
+// onfocus setter.
+
+main() {
+ useHtmlConfiguration();
+
+ test('test1', () {
+ document.body.children.add(new Element.html(r'''
+<div id='div1'>
+Hello World!
+</div>'''));
+ Element e = document.query('#div1');
+ expect(e, isNotNull);
+
+ checkNoSuchMethod(() { confuse(e).onfocus = null; });
+ });
+
+}
+
+class Decoy {
+ void set onfocus(x) { throw 'dead code'; }
+}
+
+confuse(x) => opaqueTrue() ? x : (opaqueTrue() ? new Object() : new Decoy());
+
+/** Returns [:true:], but in a way that confuses the compiler. */
+opaqueTrue() => true; // Expand as needed.
+
+checkNoSuchMethod(action()) {
+ var ex = null;
+ try {
+ action();
+ } catch (e) {
+ ex = e;
+ }
+ if (ex == null)
+ expect(false, isTrue, reason: 'Action should have thrown exception');
+
+ expect(ex, isNoSuchMethodError);
+}
« no previous file with comments | « test/codegen/lib/html/geolocation_test.dart ('k') | test/codegen/lib/html/hidden_dom_2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698