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

Unified Diff: tests/html/inner_frame_test.dart

Issue 10331009: Port two more tests to dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « tests/html/html.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/inner_frame_test.dart
diff --git a/tests/html/inner_frame_test.dart b/tests/html/inner_frame_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f330de7c47a640ccac3008e35164e184900e6559
--- /dev/null
+++ b/tests/html/inner_frame_test.dart
@@ -0,0 +1,63 @@
+#library('InnerFrameTest');
+#import('../../lib/unittest/unittest.dart');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
+
+main() {
+ if (window != window.top) {
+ // Child frame.
+
+ // The child's frame should not be able to access its parent's
+ // document.
+
+ // Check window.frameElement.
+ try {
+ var parentDocument = window.frameElement.document;
+ var div = parentDocument.$dom_createElement("div");
+ div.id = "illegalFrameElement";
+ parentDocument.body.nodes.add(div);
+ Expect.fail('Should not reach here.');
+ } catch (NoSuchMethodException e) {
+ // Expected.
+ }
+
+ // Check window.top.
+ try {
+ final top = window.top;
+ var parentDocument = top.document;
+ var div = parentDocument.$dom_createElement("div");
+ div.id = "illegalTop";
+ parentDocument.body.nodes.add(div);
+ Expect.fail('Should not reach here.');
+ } catch (var e) {
+ // Expected.
+ // TODO(vsm): Enforce this is a NoSuchMethodException.
+ }
+ return;
+ }
+
+ // Parent / test frame
+ useHtmlConfiguration();
+
+ final iframe = new Element.tag('iframe');
+ iframe.src = window.location.href;
+
+ asyncTest('prepare', 1, () {
+ iframe.on.load.add((e) => callbackDone());
+ document.body.nodes.add(iframe);
+ });
+
+ test('frameElement', () {
+ var div = document.query('#illegalFrameElement');
+
+ // Ensure that this parent frame was not modified by its child.
+ Expect.isNull(div);
+ });
+
+ test('top', () {
+ var div = document.query('#illegalTop');
+
+ // Ensure that this parent frame was not modified by its child.
+ Expect.isNull(div);
+ });
+}
« no previous file with comments | « tests/html/html.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698