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

Unified Diff: test/codegen/lib/html/hidden_dom_2_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/hidden_dom_1_test.dart ('k') | test/codegen/lib/html/history_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_2_test.dart
diff --git a/test/codegen/lib/html/hidden_dom_2_test.dart b/test/codegen/lib/html/hidden_dom_2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e8abc4eee6192db3aeb01a7d882ff5d52857ff4e
--- /dev/null
+++ b/test/codegen/lib/html/hidden_dom_2_test.dart
@@ -0,0 +1,48 @@
+library HiddenDom2Test;
+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:
+// appendChild operation.
+
+main() {
+ useHtmlConfiguration();
+
+ test('test1', () {
+ document.body.children.add(new Element.html(r'''
+<div id='div1'>
+Hello World!
+</div>'''));
+ Element e = document.query('#div1');
+ Element e2 = new Element.html(r"<div id='xx'>XX</div>");
+ expect(e, isNotNull);
+
+ checkNoSuchMethod(() { confuse(e).appendChild(e2); });
+
+ });
+}
+
+class Decoy {
+ void appendChild(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;
+ bool threw = false;
+ try {
+ action();
+ } catch (e) {
+ threw = true;
+ ex = e;
+ }
+ if (!threw)
+ expect(false, isTrue, reason: 'Action should have thrown exception');
+
+ expect(ex, isNoSuchMethodError);
+}
« no previous file with comments | « test/codegen/lib/html/hidden_dom_1_test.dart ('k') | test/codegen/lib/html/history_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698