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

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

Issue 9453004: Cross frame access tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Frog DOM support for safe cross-frame window access. 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
« no previous file with comments | « no previous file | client/dom/generated/src/frog/DOMWindow.dart » ('j') | client/dom/scripts/systemfrog.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/frog/dom_frog.dart
diff --git a/client/dom/frog/dom_frog.dart b/client/dom/frog/dom_frog.dart
index 624aaafa4f14df173c2d23fabc37a701d842a471..f07b4ca5b94a8c1df451cf9f5f26fd443cd57537 100644
--- a/client/dom/frog/dom_frog.dart
+++ b/client/dom/frog/dom_frog.dart
@@ -1207,8 +1207,6 @@ class _DOMWindowJs extends _EventTargetJs implements DOMWindow native "@*DOMWind
final _EventJs event;
- final _ElementJs frameElement;
-
final _DOMWindowJs frames;
final _HistoryJs history;
@@ -2975,15 +2973,14 @@ class _HTMLHtmlElementJs extends _HTMLElementJs implements HTMLHtmlElement nativ
String version;
}
+// 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 _HTMLIFrameElementJs extends _HTMLElementJs implements HTMLIFrameElement native "*HTMLIFrameElement" {
String align;
- final _DocumentJs contentDocument;
-
- final _DOMWindowJs contentWindow;
-
String frameBorder;
String height;
@@ -3005,6 +3002,72 @@ class _HTMLIFrameElementJs extends _HTMLElementJs implements HTMLIFrameElement n
String width;
_SVGDocumentJs getSVGDocument() native;
+
+
+ Window get _contentWindow() native """
sra1 2012/02/24 03:38:30 For short ones that fit on the same line I just go
vsm 2012/02/26 01:52:10 Done.
+ return this.contentWindow;
+ """;
+
+ // Override contentWindow to return secure wrapper.
+ Window get contentWindow() {
+ return _DOMWindowCrossFrameJs._createSafe(_contentWindow);
+ }
+}
+
+// TODO(vsm): Unify with Dartium version.
sra1 2012/02/24 03:38:30 The file(s) containing this function is missing fr
vsm 2012/02/26 01:52:10 File added. On 2012/02/24 03:38:30, sra1 wrote:
+class _DOMWindowCrossFrameJs implements DOMType, DOMWindow {
sra1 2012/02/24 03:38:30 Drop the 'Js'. That is for native classes.
vsm 2012/02/26 01:52:10 Done.
+ // 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);
+
+ // TODO(vsm): Why is this needed? How do I get a
+ // NoSuchMethodException.
+ var get document() { throw new Exception(); }
sra1 2012/02/24 03:38:30 This is weird. I wonder if it is related to the to
vsm 2012/02/26 01:52:10 I'm going to remove this and mark as a bug. On 20
+
+ // Methods.
+ void focus() {
+ _window.focus();
+ }
+
+ void blur() {
+ _window.blur();
+ }
+
+ void close() {
+ _window.close();
+ }
+
+ void postMessage(Dynamic message, String targetOrigin, [List messagePorts = null]) {
sra1 2012/02/24 03:38:30 Line length
vsm 2012/02/26 01:52:10 Done.
+ if (messagePorts == null) {
+ _window.postMessage(message, targetOrigin);
+ } else {
+ _window.postMessage(message, targetOrigin, messagePorts);
+ }
+ }
+
+ // Implementation support.
+ _DOMWindowCrossFrameJs(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 _DOMWindowCrossFrameJs(w);
+ }
}
class _HTMLImageElementJs extends _HTMLElementJs implements HTMLImageElement native "*HTMLImageElement" {
« no previous file with comments | « no previous file | client/dom/generated/src/frog/DOMWindow.dart » ('j') | client/dom/scripts/systemfrog.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698