mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 12:48:10 +00:00
13c0d42313
The "setTimeout" member in window object can only be accessed if the window object is from the same origin. Cross origin windows will throw a security error exception. This is fixed by checking for "postMessage" in the window object (which can be accessed even in cross-origin windows). BUG=http://dartbug.com/20166 R=blois@google.com Review URL: https://codereview.chromium.org//406143004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38517 260f80e4-7a28-3924-810f-c04153c831b5
30 lines
973 B
Dart
30 lines
973 B
Dart
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'dart:html';
|
|
|
|
import 'package:unittest/unittest.dart';
|
|
|
|
main() {
|
|
test('cross_domain_iframe', () {
|
|
var uri = Uri.parse(window.location.href);
|
|
|
|
var crossOriginPort = int.parse(uri.queryParameters['crossOriginPort']);
|
|
var crossOrigin = '${uri.scheme}://${uri.host}:$crossOriginPort';
|
|
var crossOriginUrl =
|
|
'$crossOrigin/root_dart/tests/html/cross_domain_iframe_script.html';
|
|
|
|
var iframe = new IFrameElement();
|
|
iframe.src = crossOriginUrl;
|
|
document.body.append(iframe);
|
|
|
|
window.onMessage.where((MessageEvent event) {
|
|
return event.origin == crossOrigin;
|
|
}).first.then(expectAsync((MessageEvent event) {
|
|
expect(event.data, equals('foobar'));
|
|
expect(event.source, isNotNull);
|
|
}));
|
|
});
|
|
}
|