c265902bea
Review URL: https://chromiumcodereview.appspot.com//10836241 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10685 260f80e4-7a28-3924-810f-c04153c831b5
64 lines
1.6 KiB
Dart
64 lines
1.6 KiB
Dart
#library('InnerFrameTest');
|
|
#import('../../pkg/unittest/unittest.dart');
|
|
#import('../../pkg/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;
|
|
|
|
test('prepare', () {
|
|
iframe.on.load.add(expectAsync1((e) {}));
|
|
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);
|
|
});
|
|
}
|