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

Unified Diff: lib/html/src/dart2js_Conversions.dart

Issue 11074005: Wrap Window in case it's a window from a different page / frame. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comment Created 8 years, 2 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 | « lib/html/scripts/systemhtml.py ('k') | lib/html/src/dart2js_DOMImplementation.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/html/src/dart2js_Conversions.dart
diff --git a/lib/html/src/dart2js_Conversions.dart b/lib/html/src/dart2js_Conversions.dart
index a8f277156ae512826e3eb8ebf1da20c723282222..8f13a42a3b8c0a90d81e9ccc3ff2d7d8836d9ca4 100644
--- a/lib/html/src/dart2js_Conversions.dart
+++ b/lib/html/src/dart2js_Conversions.dart
@@ -20,6 +20,34 @@
// What is required is to ensure that an Lists in the key are actually
// JavaScript arrays, and any Dates are JavaScript Dates.
+// Conversions for Window. These check if the window is the local
+// window, and if it's not, wraps or unwraps it with a secure wrapper.
+// We need to test for EventTarget here as well as it's a base type.
+// We omit an unwrapper for Window as no methods take a non-local
+// window as a parameter.
+
+Window _convertNativeToDart_Window(win) {
+ return _DOMWindowCrossFrameImpl._createSafe(win);
+}
+
+EventTarget _convertNativeToDart_EventTarget(e) {
+ // Assume it's a Window if it contains the setInterval property. It may be
+ // from a different frame - without a patched prototype - so we cannot
+ // rely on Dart type checking.
+ if (JS('bool', r'"setInterval" in #', e))
+ return _DOMWindowCrossFrameImpl._createSafe(event);
+ else
+ return e;
+}
+
+EventTarget _convertDartToNative_EventTarget(e) {
+ if (e is _DOMWindowCrossFrameImpl) {
+ return e._window;
+ } else {
+ return e;
+ }
+}
+
// Conversions for ImageData
//
// On Firefox, the returned ImageData is a plain object.
« no previous file with comments | « lib/html/scripts/systemhtml.py ('k') | lib/html/src/dart2js_DOMImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698