Chrome moved clipboardData from Event to ClipboardEvent for security clipboard can only be accessed during a onCut/onCopy/onPaste event.

The polyfill class KeyEvent can no longer access clipboardData without listening for the cut, copy or paste event.

TBR=alanknight@google.com,sigmund@google.com

Review URL: https://codereview.chromium.org/1775923002 .
This commit is contained in:
Terry Lucas 2016-03-08 05:24:02 -08:00
parent 7772152fa1
commit af562187bc
8 changed files with 33 additions and 54 deletions

View file

@ -10254,12 +10254,12 @@ class Document extends Node
/// Stream of `copy` events handled by this [Document].
@DomName('Document.oncopy')
@DocsEditable()
Stream<Event> get onCopy => Element.copyEvent.forTarget(this);
Stream<ClipboardEvent> get onCopy => Element.copyEvent.forTarget(this);
/// Stream of `cut` events handled by this [Document].
@DomName('Document.oncut')
@DocsEditable()
Stream<Event> get onCut => Element.cutEvent.forTarget(this);
Stream<ClipboardEvent> get onCut => Element.cutEvent.forTarget(this);
/// Stream of `doubleclick` events handled by this [Document].
@DomName('Document.ondblclick')
@ -10411,7 +10411,7 @@ class Document extends Node
/// Stream of `paste` events handled by this [Document].
@DomName('Document.onpaste')
@DocsEditable()
Stream<Event> get onPaste => Element.pasteEvent.forTarget(this);
Stream<ClipboardEvent> get onPaste => Element.pasteEvent.forTarget(this);
@DomName('Document.onpause')
@DocsEditable()
@ -12095,12 +12095,12 @@ abstract class ElementList<T extends Element> extends ListBase<T> {
/// Stream of `copy` events handled by this [Element].
@DomName('Element.oncopy')
@DocsEditable()
ElementStream<Event> get onCopy;
ElementStream<ClipboardEvent> get onCopy;
/// Stream of `cut` events handled by this [Element].
@DomName('Element.oncut')
@DocsEditable()
ElementStream<Event> get onCut;
ElementStream<ClipboardEvent> get onCut;
/// Stream of `doubleclick` events handled by this [Element].
@DomName('Element.ondblclick')
@ -12348,7 +12348,7 @@ abstract class ElementList<T extends Element> extends ListBase<T> {
/// Stream of `paste` events handled by this [Element].
@DomName('Element.onpaste')
@DocsEditable()
ElementStream<Event> get onPaste;
ElementStream<ClipboardEvent> get onPaste;
@DomName('Element.onpause')
@DocsEditable()
@ -12627,12 +12627,12 @@ class _FrozenElementList extends ListBase
/// Stream of `copy` events handled by this [Element].
@DomName('Element.oncopy')
@DocsEditable()
ElementStream<Event> get onCopy => Element.copyEvent._forElementList(this);
ElementStream<ClipboardEvent> get onCopy => Element.copyEvent._forElementList(this);
/// Stream of `cut` events handled by this [Element].
@DomName('Element.oncut')
@DocsEditable()
ElementStream<Event> get onCut => Element.cutEvent._forElementList(this);
ElementStream<ClipboardEvent> get onCut => Element.cutEvent._forElementList(this);
/// Stream of `doubleclick` events handled by this [Element].
@DomName('Element.ondblclick')
@ -12880,7 +12880,7 @@ class _FrozenElementList extends ListBase
/// Stream of `paste` events handled by this [Element].
@DomName('Element.onpaste')
@DocsEditable()
ElementStream<Event> get onPaste => Element.pasteEvent._forElementList(this);
ElementStream<ClipboardEvent> get onPaste => Element.pasteEvent._forElementList(this);
@DomName('Element.onpause')
@DocsEditable()
@ -14322,7 +14322,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
*/
@DomName('Element.copyEvent')
@DocsEditable()
static const EventStreamProvider<Event> copyEvent = const EventStreamProvider<Event>('copy');
static const EventStreamProvider<ClipboardEvent> copyEvent = const EventStreamProvider<ClipboardEvent>('copy');
/**
* Static factory designed to expose `cut` events to event
@ -14332,7 +14332,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
*/
@DomName('Element.cutEvent')
@DocsEditable()
static const EventStreamProvider<Event> cutEvent = const EventStreamProvider<Event>('cut');
static const EventStreamProvider<ClipboardEvent> cutEvent = const EventStreamProvider<ClipboardEvent>('cut');
/**
* Static factory designed to expose `doubleclick` events to event
@ -14657,7 +14657,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
*/
@DomName('Element.pasteEvent')
@DocsEditable()
static const EventStreamProvider<Event> pasteEvent = const EventStreamProvider<Event>('paste');
static const EventStreamProvider<ClipboardEvent> pasteEvent = const EventStreamProvider<ClipboardEvent>('paste');
@DomName('Element.pauseEvent')
@DocsEditable()
@ -15455,12 +15455,12 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
/// Stream of `copy` events handled by this [Element].
@DomName('Element.oncopy')
@DocsEditable()
ElementStream<Event> get onCopy => copyEvent.forElement(this);
ElementStream<ClipboardEvent> get onCopy => copyEvent.forElement(this);
/// Stream of `cut` events handled by this [Element].
@DomName('Element.oncut')
@DocsEditable()
ElementStream<Event> get onCut => cutEvent.forElement(this);
ElementStream<ClipboardEvent> get onCut => cutEvent.forElement(this);
/// Stream of `doubleclick` events handled by this [Element].
@DomName('Element.ondblclick')
@ -15708,7 +15708,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
/// Stream of `paste` events handled by this [Element].
@DomName('Element.onpaste')
@DocsEditable()
ElementStream<Event> get onPaste => pasteEvent.forElement(this);
ElementStream<ClipboardEvent> get onPaste => pasteEvent.forElement(this);
@DomName('Element.onpause')
@DocsEditable()
@ -43307,8 +43307,6 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
static EventStreamProvider<KeyEvent> keyPressEvent =
new _KeyboardEventHandler('keypress');
/** Accessor to the clipboardData available for this event. */
DataTransfer get clipboardData => _parent.clipboardData;
String get code => _parent.code;
/** True if the ctrl key is pressed during this event. */
bool get ctrlKey => _parent.ctrlKey;
@ -43393,8 +43391,6 @@ class _WrappedEvent implements Event {
bool get cancelable => wrapped.cancelable;
DataTransfer get clipboardData => wrapped.clipboardData;
EventTarget get currentTarget => wrapped.currentTarget;
bool get defaultPrevented => wrapped.defaultPrevented;

View file

@ -11614,12 +11614,12 @@ class Document extends Node
/// Stream of `copy` events handled by this [Document].
@DomName('Document.oncopy')
@DocsEditable()
Stream<Event> get onCopy => Element.copyEvent.forTarget(this);
Stream<ClipboardEvent> get onCopy => Element.copyEvent.forTarget(this);
/// Stream of `cut` events handled by this [Document].
@DomName('Document.oncut')
@DocsEditable()
Stream<Event> get onCut => Element.cutEvent.forTarget(this);
Stream<ClipboardEvent> get onCut => Element.cutEvent.forTarget(this);
/// Stream of `doubleclick` events handled by this [Document].
@DomName('Document.ondblclick')
@ -11771,7 +11771,7 @@ class Document extends Node
/// Stream of `paste` events handled by this [Document].
@DomName('Document.onpaste')
@DocsEditable()
Stream<Event> get onPaste => Element.pasteEvent.forTarget(this);
Stream<ClipboardEvent> get onPaste => Element.pasteEvent.forTarget(this);
@DomName('Document.onpause')
@DocsEditable()
@ -13850,12 +13850,12 @@ abstract class ElementList<T extends Element> extends ListBase<T> {
/// Stream of `copy` events handled by this [Element].
@DomName('Element.oncopy')
@DocsEditable()
ElementStream<Event> get onCopy;
ElementStream<ClipboardEvent> get onCopy;
/// Stream of `cut` events handled by this [Element].
@DomName('Element.oncut')
@DocsEditable()
ElementStream<Event> get onCut;
ElementStream<ClipboardEvent> get onCut;
/// Stream of `doubleclick` events handled by this [Element].
@DomName('Element.ondblclick')
@ -14103,7 +14103,7 @@ abstract class ElementList<T extends Element> extends ListBase<T> {
/// Stream of `paste` events handled by this [Element].
@DomName('Element.onpaste')
@DocsEditable()
ElementStream<Event> get onPaste;
ElementStream<ClipboardEvent> get onPaste;
@DomName('Element.onpause')
@DocsEditable()
@ -14386,12 +14386,12 @@ class _FrozenElementList extends ListBase
/// Stream of `copy` events handled by this [Element].
@DomName('Element.oncopy')
@DocsEditable()
ElementStream<Event> get onCopy => Element.copyEvent._forElementList(this);
ElementStream<ClipboardEvent> get onCopy => Element.copyEvent._forElementList(this);
/// Stream of `cut` events handled by this [Element].
@DomName('Element.oncut')
@DocsEditable()
ElementStream<Event> get onCut => Element.cutEvent._forElementList(this);
ElementStream<ClipboardEvent> get onCut => Element.cutEvent._forElementList(this);
/// Stream of `doubleclick` events handled by this [Element].
@DomName('Element.ondblclick')
@ -14639,7 +14639,7 @@ class _FrozenElementList extends ListBase
/// Stream of `paste` events handled by this [Element].
@DomName('Element.onpaste')
@DocsEditable()
ElementStream<Event> get onPaste => Element.pasteEvent._forElementList(this);
ElementStream<ClipboardEvent> get onPaste => Element.pasteEvent._forElementList(this);
@DomName('Element.onpause')
@DocsEditable()
@ -15926,7 +15926,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
*/
@DomName('Element.copyEvent')
@DocsEditable()
static const EventStreamProvider<Event> copyEvent = const EventStreamProvider<Event>('copy');
static const EventStreamProvider<ClipboardEvent> copyEvent = const EventStreamProvider<ClipboardEvent>('copy');
/**
* Static factory designed to expose `cut` events to event
@ -15936,7 +15936,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
*/
@DomName('Element.cutEvent')
@DocsEditable()
static const EventStreamProvider<Event> cutEvent = const EventStreamProvider<Event>('cut');
static const EventStreamProvider<ClipboardEvent> cutEvent = const EventStreamProvider<ClipboardEvent>('cut');
/**
* Static factory designed to expose `doubleclick` events to event
@ -16267,7 +16267,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
*/
@DomName('Element.pasteEvent')
@DocsEditable()
static const EventStreamProvider<Event> pasteEvent = const EventStreamProvider<Event>('paste');
static const EventStreamProvider<ClipboardEvent> pasteEvent = const EventStreamProvider<ClipboardEvent>('paste');
@DomName('Element.pauseEvent')
@DocsEditable()
@ -16980,12 +16980,12 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
/// Stream of `copy` events handled by this [Element].
@DomName('Element.oncopy')
@DocsEditable()
ElementStream<Event> get onCopy => copyEvent.forElement(this);
ElementStream<ClipboardEvent> get onCopy => copyEvent.forElement(this);
/// Stream of `cut` events handled by this [Element].
@DomName('Element.oncut')
@DocsEditable()
ElementStream<Event> get onCut => cutEvent.forElement(this);
ElementStream<ClipboardEvent> get onCut => cutEvent.forElement(this);
/// Stream of `doubleclick` events handled by this [Element].
@DomName('Element.ondblclick')
@ -17233,7 +17233,7 @@ class Element extends Node implements NonDocumentTypeChildNode, GlobalEventHandl
/// Stream of `paste` events handled by this [Element].
@DomName('Element.onpaste')
@DocsEditable()
ElementStream<Event> get onPaste => pasteEvent.forElement(this);
ElementStream<ClipboardEvent> get onPaste => pasteEvent.forElement(this);
@DomName('Element.onpause')
@DocsEditable()
@ -50739,8 +50739,6 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
/** The currently registered target for this event. */
EventTarget get currentTarget => _currentTarget;
/** Accessor to the clipboardData available for this event. */
DataTransfer get clipboardData => _parent.clipboardData;
/** True if the ctrl key is pressed during this event. */
bool get ctrlKey => _parent.ctrlKey;
int get detail => _parent.detail;
@ -50828,8 +50826,6 @@ class _WrappedEvent implements Event {
bool get cancelable => wrapped.cancelable;
DataTransfer get clipboardData => wrapped.clipboardData;
EventTarget get currentTarget => wrapped.currentTarget;
bool get defaultPrevented => wrapped.defaultPrevented;

View file

@ -19,11 +19,6 @@ import 'package:compiler/src/diagnostics/messages.dart' show MessageKind;
*/
// TODO(johnniwinther): Support canonical URIs as keys.
const Map<String, List<String>> WHITE_LIST = const {
"html_dart2js.dart": const [
// These suppressions are tracked by issue 25928.
"The getter 'clipboardData' is not defined for the class 'Event'",
"The getter 'clipboardData' is not defined for the class 'KeyboardEvent'",
]
};
void main() {

View file

@ -43,8 +43,8 @@ _html_event_types = monitored.Dict('htmleventgenerator._html_event_types', {
'*.change': ('change', 'Event'),
'*.click': ('click', 'MouseEvent'),
'*.contextmenu': ('contextMenu', 'MouseEvent'),
'*.copy': ('copy', 'Event'),
'*.cut': ('cut', 'Event'),
'*.copy': ('copy', 'ClipboardEvent'),
'*.cut': ('cut', 'ClipboardEvent'),
'*.dblclick': ('doubleClick', 'Event'),
'*.drag': ('drag', 'MouseEvent'),
'*.dragend': ('dragEnd', 'MouseEvent'),
@ -79,7 +79,7 @@ _html_event_types = monitored.Dict('htmleventgenerator._html_event_types', {
'*.mousewheel': ('mouseWheel', 'WheelEvent'),
'*.offline': ('offline', 'Event'),
'*.online': ('online', 'Event'),
'*.paste': ('paste', 'Event'),
'*.paste': ('paste', 'ClipboardEvent'),
'*.pause': ('pause', 'Event'),
'*.play': ('play', 'Event'),
'*.playing': ('playing', 'Event'),

View file

@ -185,8 +185,6 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
static EventStreamProvider<KeyEvent> keyPressEvent =
new _KeyboardEventHandler('keypress');
/** Accessor to the clipboardData available for this event. */
DataTransfer get clipboardData => _parent.clipboardData;
String get code => _parent.code;
/** True if the ctrl key is pressed during this event. */
bool get ctrlKey => _parent.ctrlKey;

View file

@ -19,8 +19,6 @@ class _WrappedEvent implements Event {
bool get cancelable => wrapped.cancelable;
DataTransfer get clipboardData => wrapped.clipboardData;
EventTarget get currentTarget => wrapped.currentTarget;
bool get defaultPrevented => wrapped.defaultPrevented;

View file

@ -113,8 +113,6 @@ class KeyEvent extends _WrappedEvent implements KeyboardEvent {
/** The currently registered target for this event. */
EventTarget get currentTarget => _currentTarget;
/** Accessor to the clipboardData available for this event. */
DataTransfer get clipboardData => _parent.clipboardData;
/** True if the ctrl key is pressed during this event. */
bool get ctrlKey => _parent.ctrlKey;
int get detail => _parent.detail;

View file

@ -26,8 +26,6 @@ class _WrappedEvent implements Event {
bool get cancelable => wrapped.cancelable;
DataTransfer get clipboardData => wrapped.clipboardData;
EventTarget get currentTarget => wrapped.currentTarget;
bool get defaultPrevented => wrapped.defaultPrevented;