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

Side by Side Diff: dart/tools/dom/src/dart2js_Conversions.dart

Issue 406143004: Bugfix in html_dart2js: Detect window objects in a way compatible with cross domain iframes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use 'postMessage', change tools/dom/src/dart2js_Conversions.dart Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/tests/html/cross_domain_iframe_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 // Conversions for Window. These check if the window is the local 6 // Conversions for Window. These check if the window is the local
7 // window, and if it's not, wraps or unwraps it with a secure wrapper. 7 // window, and if it's not, wraps or unwraps it with a secure wrapper.
8 // We need to test for EventTarget here as well as it's a base type. 8 // We need to test for EventTarget here as well as it's a base type.
9 // We omit an unwrapper for Window as no methods take a non-local 9 // We omit an unwrapper for Window as no methods take a non-local
10 // window as a parameter. 10 // window as a parameter.
11 11
12 part of html; 12 part of html;
13 13
14 WindowBase _convertNativeToDart_Window(win) { 14 WindowBase _convertNativeToDart_Window(win) {
15 if (win == null) return null; 15 if (win == null) return null;
16 return _DOMWindowCrossFrame._createSafe(win); 16 return _DOMWindowCrossFrame._createSafe(win);
17 } 17 }
18 18
19 EventTarget _convertNativeToDart_EventTarget(e) { 19 EventTarget _convertNativeToDart_EventTarget(e) {
20 if (e == null) { 20 if (e == null) {
21 return null; 21 return null;
22 } 22 }
23 // Assume it's a Window if it contains the setInterval property. It may be 23 // Assume it's a Window if it contains the postMessage property. It may be
24 // from a different frame - without a patched prototype - so we cannot 24 // from a different frame - without a patched prototype - so we cannot
25 // rely on Dart type checking. 25 // rely on Dart type checking.
26 if (JS('bool', r'"setInterval" in #', e)) { 26 if (JS('bool', r'"postMessage" in #', e)) {
27 var window = _DOMWindowCrossFrame._createSafe(e); 27 var window = _DOMWindowCrossFrame._createSafe(e);
28 // If it's a native window. 28 // If it's a native window.
29 if (window is EventTarget) { 29 if (window is EventTarget) {
30 return window; 30 return window;
31 } 31 }
32 return null; 32 return null;
33 } 33 }
34 else 34 else
35 return e; 35 return e;
36 } 36 }
37 37
38 EventTarget _convertDartToNative_EventTarget(e) { 38 EventTarget _convertDartToNative_EventTarget(e) {
39 if (e is _DOMWindowCrossFrame) { 39 if (e is _DOMWindowCrossFrame) {
40 return e._window; 40 return e._window;
41 } else { 41 } else {
42 return e; 42 return e;
43 } 43 }
44 } 44 }
45 45
46 _convertNativeToDart_XHR_Response(o) { 46 _convertNativeToDart_XHR_Response(o) {
47 if (o is Document) { 47 if (o is Document) {
48 return o; 48 return o;
49 } 49 }
50 return convertNativeToDart_SerializedScriptValue(o); 50 return convertNativeToDart_SerializedScriptValue(o);
51 } 51 }
OLDNEW
« no previous file with comments | « dart/tests/html/cross_domain_iframe_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698