Commit d6092343 authored by ramya.v's avatar ramya.v Committed by Commit bot

InitEvent should not do anything if dispatch flag is set.

Spec: https://dom.spec.whatwg.org/#concept-event-initialize

BUG=563973

Review-Url: https://codereview.chromium.org/1925963002
Cr-Commit-Position: refs/heads/master@{#390348}
parent 5bb27fba
This is a testharness.js-based test.
PASS Newly-created Event
PASS After stopPropagation()
FAIL Reinitialized after stopPropagation() assert_equals: Propagation flag expected true but got false
PASS After stopImmediatePropagation()
FAIL Reinitialized after stopImmediatePropagation() assert_equals: Propagation flag expected true but got false
Harness: the test ran to completion.
...@@ -51,7 +51,7 @@ CompositionEvent::~CompositionEvent() ...@@ -51,7 +51,7 @@ CompositionEvent::~CompositionEvent()
void CompositionEvent::initCompositionEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view, const String& data) void CompositionEvent::initCompositionEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view, const String& data)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initUIEvent(type, canBubble, cancelable, view, 0); initUIEvent(type, canBubble, cancelable, view, 0);
......
...@@ -50,7 +50,7 @@ void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool ...@@ -50,7 +50,7 @@ void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool
void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> serializedDetail) void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> serializedDetail)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initEvent(type, canBubble, cancelable); initEvent(type, canBubble, cancelable);
......
...@@ -114,7 +114,7 @@ void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool ...@@ -114,7 +114,7 @@ void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool
void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg, EventTarget* relatedTarget) void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool cancelableArg, EventTarget* relatedTarget)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
m_propagationStopped = false; m_propagationStopped = false;
......
...@@ -216,7 +216,6 @@ protected: ...@@ -216,7 +216,6 @@ protected:
Event(const AtomicString& type, const EventInit&); Event(const AtomicString& type, const EventInit&);
virtual void receivedTarget(); virtual void receivedTarget();
bool dispatched() const { return m_target; }
void setCanBubble(bool bubble) { m_canBubble = bubble; } void setCanBubble(bool bubble) { m_canBubble = bubble; }
......
...@@ -113,7 +113,7 @@ KeyboardEvent::~KeyboardEvent() ...@@ -113,7 +113,7 @@ KeyboardEvent::~KeyboardEvent()
void KeyboardEvent::initKeyboardEvent(ScriptState* scriptState, const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view, void KeyboardEvent::initKeyboardEvent(ScriptState* scriptState, const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view,
const String& keyIdentifier, unsigned location, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) const String& keyIdentifier, unsigned location, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
if (scriptState->world().isIsolatedWorld()) if (scriptState->world().isIsolatedWorld())
......
...@@ -140,7 +140,7 @@ MessageEvent* MessageEvent::create(const AtomicString& type, const MessageEventI ...@@ -140,7 +140,7 @@ MessageEvent* MessageEvent::create(const AtomicString& type, const MessageEventI
void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePortArray* ports) void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePortArray* ports)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initEvent(type, canBubble, cancelable); initEvent(type, canBubble, cancelable);
...@@ -156,7 +156,7 @@ void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bo ...@@ -156,7 +156,7 @@ void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bo
void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePortArray* ports) void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePortArray* ports)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initEvent(type, canBubble, cancelable); initEvent(type, canBubble, cancelable);
......
...@@ -181,7 +181,7 @@ void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty ...@@ -181,7 +181,7 @@ void MouseEvent::initMouseEvent(ScriptState* scriptState, const AtomicString& ty
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey,
short button, EventTarget* relatedTarget, unsigned short buttons) short button, EventTarget* relatedTarget, unsigned short buttons)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
if (scriptState && scriptState->world().isIsolatedWorld()) if (scriptState && scriptState->world().isIsolatedWorld())
......
...@@ -49,7 +49,7 @@ void MutationEvent::initMutationEvent(const AtomicString& type, bool canBubble, ...@@ -49,7 +49,7 @@ void MutationEvent::initMutationEvent(const AtomicString& type, bool canBubble,
const String& prevValue, const String& newValue, const String& prevValue, const String& newValue,
const String& attrName, unsigned short attrChange) const String& attrName, unsigned short attrChange)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initEvent(type, canBubble, cancelable); initEvent(type, canBubble, cancelable);
......
...@@ -89,7 +89,7 @@ TextEvent::~TextEvent() ...@@ -89,7 +89,7 @@ TextEvent::~TextEvent()
void TextEvent::initTextEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view, const String& data) void TextEvent::initTextEvent(const AtomicString& type, bool canBubble, bool cancelable, AbstractView* view, const String& data)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initUIEvent(type, canBubble, cancelable, view, 0); initUIEvent(type, canBubble, cancelable, view, 0);
......
...@@ -68,7 +68,7 @@ void TouchEvent::initTouchEvent(ScriptState* scriptState, TouchList* touches, To ...@@ -68,7 +68,7 @@ void TouchEvent::initTouchEvent(ScriptState* scriptState, TouchList* touches, To
int, int, int, int, int, int, int, int,
bool ctrlKey, bool altKey, bool shiftKey, bool metaKey) bool ctrlKey, bool altKey, bool shiftKey, bool metaKey)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
if (scriptState->world().isIsolatedWorld()) if (scriptState->world().isIsolatedWorld())
......
...@@ -83,7 +83,7 @@ void UIEvent::initUIEvent(const AtomicString& typeArg, bool canBubbleArg, bool c ...@@ -83,7 +83,7 @@ void UIEvent::initUIEvent(const AtomicString& typeArg, bool canBubbleArg, bool c
void UIEvent::initUIEventInternal(const AtomicString& typeArg, bool canBubbleArg, bool cancelableArg, EventTarget* relatedTarget, AbstractView* viewArg, int detailArg, InputDeviceCapabilities* sourceCapabilitiesArg) void UIEvent::initUIEventInternal(const AtomicString& typeArg, bool canBubbleArg, bool cancelableArg, EventTarget* relatedTarget, AbstractView* viewArg, int detailArg, InputDeviceCapabilities* sourceCapabilitiesArg)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initEvent(typeArg, canBubbleArg, cancelableArg, relatedTarget); initEvent(typeArg, canBubbleArg, cancelableArg, relatedTarget);
......
...@@ -48,7 +48,7 @@ DeviceMotionEvent::DeviceMotionEvent(const AtomicString& eventType, DeviceMotion ...@@ -48,7 +48,7 @@ DeviceMotionEvent::DeviceMotionEvent(const AtomicString& eventType, DeviceMotion
void DeviceMotionEvent::initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceMotionData* deviceMotionData) void DeviceMotionEvent::initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceMotionData* deviceMotionData)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initEvent(type, bubbles, cancelable); initEvent(type, bubbles, cancelable);
......
...@@ -46,7 +46,7 @@ DeviceOrientationEvent::DeviceOrientationEvent(const AtomicString& eventType, De ...@@ -46,7 +46,7 @@ DeviceOrientationEvent::DeviceOrientationEvent(const AtomicString& eventType, De
void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, const Nullable<double>& alpha, const Nullable<double>& beta, const Nullable<double>& gamma, bool absolute) void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, const Nullable<double>& alpha, const Nullable<double>& beta, const Nullable<double>& gamma, bool absolute)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initEvent(type, bubbles, cancelable); initEvent(type, bubbles, cancelable);
......
...@@ -81,7 +81,7 @@ StorageEvent::StorageEvent(const AtomicString& type, const StorageEventInit& ini ...@@ -81,7 +81,7 @@ StorageEvent::StorageEvent(const AtomicString& type, const StorageEventInit& ini
void StorageEvent::initStorageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea) void StorageEvent::initStorageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea)
{ {
if (dispatched()) if (isBeingDispatched())
return; return;
initEvent(type, canBubble, cancelable); initEvent(type, canBubble, cancelable);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment