| Index: lib/html/scripts/systemhtml.py
|
| diff --git a/lib/html/scripts/systemhtml.py b/lib/html/scripts/systemhtml.py
|
| index 0fa664ca5c42b9708c1e195706849407352bfc5a..e7303da4a9f63478f9e889a4be74b25507894219 100644
|
| --- a/lib/html/scripts/systemhtml.py
|
| +++ b/lib/html/scripts/systemhtml.py
|
| @@ -25,13 +25,13 @@ _js_custom_members = set([
|
| 'MouseEvent.offsetX',
|
| 'MouseEvent.offsetY',
|
| 'TableElement.createTBody',
|
| - 'Window.document',
|
| - 'Window.indexedDB',
|
| - 'Window.location',
|
| - 'Window.open',
|
| - 'Window.top',
|
| - 'Window.webkitCancelAnimationFrame',
|
| - 'Window.webkitRequestAnimationFrame',
|
| + 'LocalWindow.document',
|
| + 'LocalWindow.indexedDB',
|
| + 'LocalWindow.location',
|
| + 'LocalWindow.open',
|
| + 'LocalWindow.top',
|
| + 'LocalWindow.webkitCancelAnimationFrame',
|
| + 'LocalWindow.webkitRequestAnimationFrame',
|
| ])
|
|
|
| # This map controls merging of interfaces in dart:html library.
|
| @@ -52,6 +52,22 @@ _merged_html_interfaces = {
|
| 'HTMLElement': 'Element'
|
| }
|
|
|
| +# Types that are accessible cross-frame in a limited fashion.
|
| +# In these cases, the base type (e.g., Window) provides restricted access
|
| +# while the subtype (e.g., LocalWindow) provides full access to the
|
| +# corresponding objects if there are from the same frame.
|
| +_secure_base_types = {
|
| + 'LocalWindow': 'Window',
|
| + 'LocalLocation': 'Location',
|
| + 'LocalHistory': 'History',
|
| +}
|
| +
|
| +def SecureOutputType(generator, type_name):
|
| + dart_name = generator._DartType(type_name)
|
| + if dart_name in _secure_base_types:
|
| + return _secure_base_types[dart_name]
|
| + return dart_name
|
| +
|
| # Information for generating element constructors.
|
| #
|
| # TODO(sra): maybe remove all the argument complexity and use cascades.
|
| @@ -250,6 +266,9 @@ class HtmlDartInterfaceGenerator(object):
|
| suppressed_implements.append('%s.%s' %
|
| (self._common_prefix, self._DartType(parent.type.id)))
|
|
|
| + if typename in _secure_base_types:
|
| + implements.append(_secure_base_types[typename])
|
| +
|
| comment = ' extends'
|
| implements_str = ''
|
| if implements:
|
| @@ -455,7 +474,7 @@ class HtmlDartInterfaceGenerator(object):
|
|
|
| self._members_emitter.Emit(template,
|
| NAME=html_name,
|
| - TYPE=self._DartType(attribute.type.id))
|
| + TYPE=SecureOutputType(self, attribute.type.id))
|
|
|
| self._backend.AddAttribute(attribute, html_name, read_only)
|
|
|
| @@ -490,7 +509,7 @@ class HtmlDartInterfaceGenerator(object):
|
| else:
|
| self._members_emitter.Emit('\n'
|
| ' $TYPE $NAME($PARAMS);\n',
|
| - TYPE=self._DartType(info.type_name),
|
| + TYPE=SecureOutputType(self, info.type_name),
|
| NAME=html_name,
|
| PARAMS=info.ParametersInterfaceDeclaration(self._DartType))
|
| self._backend.AddOperation(info, html_name)
|
| @@ -1047,7 +1066,7 @@ class Dart2JSBackend(object):
|
| return self._NarrowToImplementationType(type_name)
|
|
|
| def _NarrowOutputType(self, type_name):
|
| - return self._NarrowToImplementationType(type_name)
|
| + return SecureOutputType(self, self._NarrowToImplementationType(type_name))
|
|
|
| def _FindShadowedAttribute(self, attr, merged_interfaces={}):
|
| """Returns (attribute, superinterface) or (None, None)."""
|
|
|