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

Unified Diff: client/dom/frog/dom_frog.dart

Issue 9539003: Safely wrap window.top in frog dom. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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
Index: client/dom/frog/dom_frog.dart
diff --git a/client/dom/frog/dom_frog.dart b/client/dom/frog/dom_frog.dart
index a2be81d99cb1b4578c586ea9d33b5982292c6f1a..0dbfc42707319fe81884feae01490884ae2f3a7f 100644
--- a/client/dom/frog/dom_frog.dart
+++ b/client/dom/frog/dom_frog.dart
@@ -1180,6 +1180,9 @@ class _DOMTokenListJs extends _DOMTypeJs implements DOMTokenList native "*DOMTok
class _DOMURLJs extends _DOMTypeJs implements DOMURL native "*DOMURL" {
}
+// 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.
class _DOMWindowJs extends _EventTargetJs implements DOMWindow native "@*DOMWindow" {
@@ -1275,8 +1278,6 @@ class _DOMWindowJs extends _EventTargetJs implements DOMWindow native "@*DOMWind
final _BarInfoJs toolbar;
- final _DOMWindowJs top;
-
final _IDBFactoryJs webkitIndexedDB;
final _NotificationCenterJs webkitNotifications;
@@ -1370,6 +1371,14 @@ class _DOMWindowJs extends _EventTargetJs implements DOMWindow native "@*DOMWind
void webkitRequestFileSystem(int type, int size, FileSystemCallback successCallback, [ErrorCallback errorCallback = null]) native;
void webkitResolveLocalFileSystemURL(String url, [EntryCallback successCallback = null, ErrorCallback errorCallback = null]) native;
+
+
+ Window get _top() native "return this.top;";
+
+ // Override top to return secure wrapper.
+ Window get top() {
+ return _DOMWindowCrossFrameImpl._createSafe(_top);
+ }
}
class _DataTransferItemJs extends _DOMTypeJs implements DataTransferItem native "*DataTransferItem" {
@@ -3014,60 +3023,6 @@ class _HTMLIFrameElementJs extends _HTMLElementJs implements HTMLIFrameElement n
}
}
-// TODO(vsm): Unify with Dartium version.
-class _DOMWindowCrossFrameImpl implements DOMType, DOMWindow {
- // Private window.
- _DOMWindowJs _window;
-
- // DOMType
- var dartObjectLocalStorage;
- String get typeName() => "DOMWindow";
-
- // Fields.
- // TODO(vsm): Wrap these two.
- History get history() => _window.history;
- Location get location() => _window.location;
-
- bool get closed() => _window.closed;
- int get length() => _window.length;
- DOMWindow get opener() => _createDOMWindowCrossFrame(_window.opener);
- DOMWindow get parent() => _createDOMWindowCrossFrame(_window.parent);
- DOMWindow get top() => _createDOMWindowCrossFrame(_window.top);
-
- // Methods.
- void focus() {
- _window.focus();
- }
-
- void blur() {
- _window.blur();
- }
-
- void close() {
- _window.close();
- }
-
- void postMessage(Dynamic message,
- String targetOrigin,
- [List messagePorts = null]) {
- if (messagePorts == null) {
- _window.postMessage(message, targetOrigin);
- } else {
- _window.postMessage(message, targetOrigin, messagePorts);
- }
- }
-
- // Implementation support.
- _DOMWindowCrossFrameImpl(this._window);
-
- static DOMWindow _createSafe(w) {
- // TODO(vsm): Check if it's the top-level window. Return unwrapped.
-
- // TODO(vsm): Cache or implement equality.
- return new _DOMWindowCrossFrameImpl(w);
- }
-}
-
class _HTMLImageElementJs extends _HTMLElementJs implements HTMLImageElement native "*HTMLImageElement" {
String align;
@@ -23961,6 +23916,65 @@ class _Collections {
return !iterable.iterator().hasNext();
}
}
+// 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.
+
+// TODO(vsm): Unify with Dartium version.
+class _DOMWindowCrossFrameImpl implements DOMType, DOMWindow {
+ // Private window.
+ _DOMWindowJs _window;
+
+ // DOMType
+ var dartObjectLocalStorage;
+ String get typeName() => "DOMWindow";
+
+ // Fields.
+ // TODO(vsm): Wrap these two.
+ History get history() => _window.history;
+ Location get location() => _window.location;
+
+ bool get closed() => _window.closed;
+ int get length() => _window.length;
+ DOMWindow get opener() => _createSafe(_window.opener);
+ DOMWindow get parent() => _createSafe(_window.parent);
+ DOMWindow get top() => _createSafe(_window.top);
+
+ // Methods.
+ void focus() {
+ _window.focus();
+ }
+
+ void blur() {
+ _window.blur();
+ }
+
+ void close() {
+ _window.close();
+ }
+
+ void postMessage(Dynamic message,
+ String targetOrigin,
+ [List messagePorts = null]) {
+ if (messagePorts == null) {
+ _window.postMessage(message, targetOrigin);
+ } else {
+ _window.postMessage(message, targetOrigin, messagePorts);
+ }
+ }
+
+ // Implementation support.
+ _DOMWindowCrossFrameImpl(this._window);
+
+ static DOMWindow _createSafe(w) {
+ if (w === window) {
+ return w;
+ } else {
+ // TODO(vsm): Cache or implement equality.
+ return new _DOMWindowCrossFrameImpl(w);
+ }
+ }
+}
// Copyright (c) 2011, 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.

Powered by Google App Engine
This is Rietveld 408576698