<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210254] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210254">210254</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2017-01-03 15:51:39 -0800 (Tue, 03 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Make setting Event's cancelBubble to false a no-op
https://bugs.webkit.org/show_bug.cgi?id=166018
Reviewed by Ryosuke Niwa.
LayoutTests/imported/w3c:
Merge https://github.com/w3c/web-platform-tests/pull/4304 to extend / fix
test coverage.
* web-platform-tests/dom/events/Event-cancelBubble-expected.txt: Added.
* web-platform-tests/dom/events/Event-cancelBubble.html: Added.
* web-platform-tests/dom/events/Event-dispatch-bubble-canceled-expected.txt: Added.
* web-platform-tests/dom/events/Event-dispatch-bubble-canceled.html: Added.
* web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble-expected.txt: Added.
* web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble.html: Added.
* web-platform-tests/dom/events/Event-initEvent.html:
* web-platform-tests/dom/events/Event-propagation-expected.txt:
* web-platform-tests/dom/events/Event-propagation.html:
* web-platform-tests/dom/events/w3c-import.log:
Source/WebCore:
Align behavior of Event.cancelBubble with the latest DOM specification:
- https://dom.spec.whatwg.org/#dom-event-cancelbubble
Setting it to true sets the 'stop propagation' flag to true and setting
it to false is now a no-op.
Tests: imported/w3c/web-platform-tests/dom/events/Event-cancelBubble.html
imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled.html
imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble.html
* Modules/indexeddb/IDBEventDispatcher.cpp:
(WebCore::IDBEventDispatcher::dispatch):
* dom/Event.h:
(WebCore::Event::cancelBubble):
(WebCore::Event::setCancelBubble):
* dom/EventDispatcher.cpp:
(WebCore::dispatchEventInDOM):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventinitEventhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-initEvent.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventpropagationexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-propagation-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventpropagationhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-propagation.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsw3cimportlog">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBEventDispatchercpp">trunk/Source/WebCore/Modules/indexeddb/IDBEventDispatcher.cpp</a></li>
<li><a href="#trunkSourceWebCoredomEventh">trunk/Source/WebCore/dom/Event.h</a></li>
<li><a href="#trunkSourceWebCoredomEventDispatchercpp">trunk/Source/WebCore/dom/EventDispatcher.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventcancelBubbleexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-cancelBubble-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventcancelBubblehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-cancelBubble.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventdispatchbubblecanceledexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventdispatchbubblecanceledhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventdispatchmultiplecancelBubbleexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventdispatchmultiplecancelBubblehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (210253 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2017-01-03 23:18:45 UTC (rev 210253)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2017-01-03 Chris Dumez <cdumez@apple.com>
+
+ Make setting Event's cancelBubble to false a no-op
+ https://bugs.webkit.org/show_bug.cgi?id=166018
+
+ Reviewed by Ryosuke Niwa.
+
+ Merge https://github.com/w3c/web-platform-tests/pull/4304 to extend / fix
+ test coverage.
+
+ * web-platform-tests/dom/events/Event-cancelBubble-expected.txt: Added.
+ * web-platform-tests/dom/events/Event-cancelBubble.html: Added.
+ * web-platform-tests/dom/events/Event-dispatch-bubble-canceled-expected.txt: Added.
+ * web-platform-tests/dom/events/Event-dispatch-bubble-canceled.html: Added.
+ * web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble-expected.txt: Added.
+ * web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble.html: Added.
+ * web-platform-tests/dom/events/Event-initEvent.html:
+ * web-platform-tests/dom/events/Event-propagation-expected.txt:
+ * web-platform-tests/dom/events/Event-propagation.html:
+ * web-platform-tests/dom/events/w3c-import.log:
+
</ins><span class="cx"> 2016-12-20 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Remove initEvent quirk
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventcancelBubbleexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-cancelBubble-expected.txt (0 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-cancelBubble-expected.txt         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-cancelBubble-expected.txt        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+
+PASS cancelBubble must be false when an event is initially created.
+PASS Initializing an event must set cancelBubble to false.
+PASS stopPropagation() must set cancelBubble to true.
+PASS stopImmediatePropagation() must set cancelBubble to true.
+PASS Event.cancelBubble=false must have no effect.
+PASS Event.cancelBubble=false must have no effect during event propagation.
+PASS cancelBubble must be false after an event has been dispatched.
+PASS Event.cancelBubble=true must set the stop propagation flag.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventcancelBubblehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-cancelBubble.html (0 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-cancelBubble.html         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-cancelBubble.html        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -0,0 +1,132 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Event.cancelBubble</title>
+ <link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
+ <link rel="help" href="https://dom.spec.whatwg.org/#dom-event-cancelbubble">
+ <meta name="flags" content="dom">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+ <div id="outer">
+ <div id="middle">
+ <div id="inner"></div>
+ </div>
+ </div>
+ <script>
+test(function () {
+ // See https://dom.spec.whatwg.org/#stop-propagation-flag
+ var e = document.createEvent('Event');
+ assert_false(e.cancelBubble, "cancelBubble must be false after event creation.");
+}, "cancelBubble must be false when an event is initially created.");
+
+test(function () {
+ // See https://dom.spec.whatwg.org/#concept-event-initialize
+
+ // Event which bubbles.
+ var one = document.createEvent('Event');
+ one.cancelBubble = true;
+ one.initEvent('foo', true/*bubbles*/, false/*cancelable*/);
+ assert_false(one.cancelBubble, "initEvent() must set cancelBubble to false. [bubbles=true]");
+ // Re-initialization.
+ one.cancelBubble = true;
+ one.initEvent('foo', true/*bubbles*/, false/*cancelable*/);
+ assert_false(one.cancelBubble, "2nd initEvent() call must set cancelBubble to false. [bubbles=true]");
+
+ // Event which doesn't bubble.
+ var two = document.createEvent('Event');
+ two.cancelBubble = true;
+ two.initEvent('foo', false/*bubbles*/, false/*cancelable*/);
+ assert_false(two.cancelBubble, "initEvent() must set cancelBubble to false. [bubbles=false]");
+ // Re-initialization.
+ two.cancelBubble = true;
+ two.initEvent('foo', false/*bubbles*/, false/*cancelable*/);
+ assert_false(two.cancelBubble, "2nd initEvent() call must set cancelBubble to false. [bubbles=false]");
+}, "Initializing an event must set cancelBubble to false.");
+
+test(function () {
+ // See https://dom.spec.whatwg.org/#dom-event-stoppropagation
+ var e = document.createEvent('Event');
+ e.stopPropagation();
+ assert_true(e.cancelBubble, "stopPropagation() must set cancelBubble to true.");
+}, "stopPropagation() must set cancelBubble to true.");
+
+test(function () {
+ // See https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
+ var e = document.createEvent('Event');
+ e.stopImmediatePropagation();
+ assert_true(e.cancelBubble, "stopImmediatePropagation() must set cancelBubble to true.");
+}, "stopImmediatePropagation() must set cancelBubble to true.");
+
+test(function () {
+ var one = document.createEvent('Event');
+ one.stopPropagation();
+ one.cancelBubble = false;
+ assert_true(one.cancelBubble, "cancelBubble must still be true after attempting to set it to false.");
+}, "Event.cancelBubble=false must have no effect.");
+
+test(function (t) {
+ var outer = document.getElementById('outer');
+ var middle = document.getElementById('middle');
+ var inner = document.getElementById('inner');
+
+ outer.addEventListener('barbaz', t.step_func(function () {
+ assert_unreached("Setting Event.cancelBubble=false after setting Event.cancelBubble=true should have no effect.");
+ }), false/*useCapture*/);
+
+ middle.addEventListener('barbaz', function (e) {
+ e.cancelBubble = true;// Stop propagation.
+ e.cancelBubble = false;// Should be a no-op.
+ }, false/*useCapture*/);
+
+ var barbazEvent = document.createEvent('Event');
+ barbazEvent.initEvent('barbaz', true/*bubbles*/, false/*cancelable*/);
+ inner.dispatchEvent(barbazEvent);
+}, "Event.cancelBubble=false must have no effect during event propagation.");
+
+test(function () {
+ // See https://dom.spec.whatwg.org/#concept-event-dispatch
+ // "14. Unset event’s [...] stop propagation flag,"
+ var e = document.createEvent('Event');
+ e.initEvent('foobar', true/*bubbles*/, true/*cancelable*/);
+ document.body.addEventListener('foobar', function listener(e) {
+ e.stopPropagation();
+ });
+ document.body.dispatchEvent(e);
+ assert_false(e.cancelBubble, "cancelBubble must be false after an event has been dispatched.");
+}, "cancelBubble must be false after an event has been dispatched.");
+
+test(function (t) {
+ var outer = document.getElementById('outer');
+ var middle = document.getElementById('middle');
+ var inner = document.getElementById('inner');
+
+ var propagationStopper = function (e) {
+ e.cancelBubble = true;
+ };
+
+ // Bubble phase
+ middle.addEventListener('bar', propagationStopper, false/*useCapture*/);
+ outer.addEventListener('bar', t.step_func(function listenerOne() {
+ assert_unreached("Setting cancelBubble=true should stop the event from bubbling further.");
+ }), false/*useCapture*/);
+
+ var barEvent = document.createEvent('Event');
+ barEvent.initEvent('bar', true/*bubbles*/, false/*cancelable*/);
+ inner.dispatchEvent(barEvent);
+
+ // Capture phase
+ outer.addEventListener('qux', propagationStopper, true/*useCapture*/);
+ middle.addEventListener('qux', t.step_func(function listenerTwo() {
+ assert_unreached("Setting cancelBubble=true should stop the event from propagating further, including during the Capture Phase.");
+ }), true/*useCapture*/);
+
+ var quxEvent = document.createEvent('Event');
+ quxEvent.initEvent('qux', false/*bubbles*/, false/*cancelable*/);
+ inner.dispatchEvent(quxEvent);
+}, "Event.cancelBubble=true must set the stop propagation flag.");
+ </script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventdispatchbubblecanceledexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled-expected.txt (0 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled-expected.txt         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled-expected.txt        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+PASS Setting cancelBubble=true prior to dispatchEvent()
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventdispatchbubblecanceledhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled.html (0 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled.html         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled.html        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<title>Setting cancelBubble=true prior to dispatchEvent()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id="log"></div>
+
+<table id="table" border="1" style="display: none">
+ <tbody id="table-body">
+ <tr id="table-row">
+ <td id="table-cell">Shady Grove</td>
+ <td>Aeolian</td>
+ </tr>
+ <tr id="parent">
+ <td id="target">Over the river, Charlie</td>
+ <td>Dorian</td>
+ </tr>
+ </tbody>
+</table>
+
+<script>
+test(function() {
+ var event = "foo";
+ var target = document.getElementById("target");
+ var parent = document.getElementById("parent");
+ var tbody = document.getElementById("table-body");
+ var table = document.getElementById("table");
+ var body = document.body;
+ var html = document.documentElement;
+ var current_targets = [window, document, html, body, table, tbody, parent, target];
+ var expected_targets = [];
+ var actual_targets = [];
+ var expected_phases = [];
+ var actual_phases = [];
+
+ var test_event = function(evt) {
+ actual_targets.push(evt.currentTarget);
+ actual_phases.push(evt.eventPhase);
+ };
+
+ for (var i = 0; i < current_targets.length; ++i) {
+ current_targets[i].addEventListener(event, test_event, true);
+ current_targets[i].addEventListener(event, test_event, false);
+ }
+
+ var evt = document.createEvent("Event");
+ evt.initEvent(event, true, true);
+ evt.cancelBubble = true;
+ target.dispatchEvent(evt);
+
+ assert_array_equals(actual_targets, expected_targets, "actual_targets");
+ assert_array_equals(actual_phases, expected_phases, "actual_phases");
+});
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventdispatchmultiplecancelBubbleexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble-expected.txt (0 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble-expected.txt         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble-expected.txt        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+PASS Multiple dispatchEvent() and cancelBubble
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventdispatchmultiplecancelBubblehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble.html (0 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble.html         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble.html        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<title>Multiple dispatchEvent() and cancelBubble</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id=log></div>
+
+<div id="parent" style="display: none">
+ <input id="target" type="hidden" value=""/>
+</div>
+
+<script>
+test(function() {
+ var event_type = "foo";
+ var target = document.getElementById("target");
+ var parent = document.getElementById("parent");
+ var actual_result;
+ var test_event = function(evt) {
+ actual_result.push(evt.currentTarget);
+
+ if (parent == evt.currentTarget) {
+ evt.cancelBubble = true;
+ }
+ };
+
+ var evt = document.createEvent("Event");
+ evt.initEvent(event_type, true, true);
+
+ target.addEventListener(event_type, test_event, false);
+ parent.addEventListener(event_type, test_event, false);
+ document.addEventListener(event_type, test_event, false);
+ window.addEventListener(event_type, test_event, false);
+
+ actual_result = [];
+ target.dispatchEvent(evt);
+ assert_array_equals(actual_result, [target, parent]);
+
+ actual_result = [];
+ parent.dispatchEvent(evt);
+ assert_array_equals(actual_result, [parent]);
+
+ actual_result = [];
+ document.dispatchEvent(evt);
+ assert_array_equals(actual_result, [document, window]);
+});
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventinitEventhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-initEvent.html (210253 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-initEvent.html        2017-01-03 23:18:45 UTC (rev 210253)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-initEvent.html        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -85,6 +85,7 @@
</span><span class="cx"> var target = document.createElement("div")
</span><span class="cx"> var called = false
</span><span class="cx"> target.addEventListener("type", function() { called = true }, false)
</span><ins>+ assert_false(e.cancelBubble, "cancelBubble must be false")
</ins><span class="cx"> assert_true(target.dispatchEvent(e), "dispatchEvent must return true")
</span><span class="cx"> assert_true(called, "Listener must be called")
</span><span class="cx"> }, "Calling initEvent must unset the stop propagation flag.")
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventpropagationexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-propagation-expected.txt (210253 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-propagation-expected.txt        2017-01-03 23:18:45 UTC (rev 210253)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-propagation-expected.txt        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -4,4 +4,6 @@
</span><span class="cx"> PASS Reinitialized after stopPropagation()
</span><span class="cx"> PASS After stopImmediatePropagation()
</span><span class="cx"> PASS Reinitialized after stopImmediatePropagation()
</span><ins>+PASS After cancelBubble=true
+PASS Reinitialized after cancelBubble=true
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsEventpropagationhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-propagation.html (210253 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-propagation.html        2017-01-03 23:18:45 UTC (rev 210253)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-propagation.html        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -38,4 +38,11 @@
</span><span class="cx"> testPropagationFlag(ev, false, "After stopImmediatePropagation()");
</span><span class="cx"> ev.initEvent("foo", true, false);
</span><span class="cx"> testPropagationFlag(ev, true, "Reinitialized after stopImmediatePropagation()");
</span><ins>+
+var ev = document.createEvent("Event");
+ev.initEvent("foo", true, false);
+ev.cancelBubble = true;
+testPropagationFlag(ev, false, "After cancelBubble=true");
+ev.initEvent("foo", true, false);
+testPropagationFlag(ev, true, "Reinitialized after cancelBubble=true");
</ins><span class="cx"> </script>
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsdomeventsw3cimportlog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log (210253 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log        2017-01-03 23:18:45 UTC (rev 210253)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -18,15 +18,18 @@
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-once.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/CustomEvent.html
</span><ins>+/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-cancelBubble.html
</ins><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-constants.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-constructors.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented.html
</span><ins>+/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled.html
</ins><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-false.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubbles-true.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-click.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-detached-click.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-handlers-changed.html
</span><ins>+/LayoutTests/imported/w3c/web-platform-tests/dom/events/dom/events/Event-dispatch-multiple-cancelBubble.html
</ins><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-stopPropagation.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-omitted-capture.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-order.html
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210253 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-03 23:18:45 UTC (rev 210253)
+++ trunk/Source/WebCore/ChangeLog        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2017-01-03 Chris Dumez <cdumez@apple.com>
+
+ Make setting Event's cancelBubble to false a no-op
+ https://bugs.webkit.org/show_bug.cgi?id=166018
+
+ Reviewed by Ryosuke Niwa.
+
+ Align behavior of Event.cancelBubble with the latest DOM specification:
+ - https://dom.spec.whatwg.org/#dom-event-cancelbubble
+
+ Setting it to true sets the 'stop propagation' flag to true and setting
+ it to false is now a no-op.
+
+ Tests: imported/w3c/web-platform-tests/dom/events/Event-cancelBubble.html
+ imported/w3c/web-platform-tests/dom/events/Event-dispatch-bubble-canceled.html
+ imported/w3c/web-platform-tests/dom/events/Event-dispatch-multiple-cancelBubble.html
+
+ * Modules/indexeddb/IDBEventDispatcher.cpp:
+ (WebCore::IDBEventDispatcher::dispatch):
+ * dom/Event.h:
+ (WebCore::Event::cancelBubble):
+ (WebCore::Event::setCancelBubble):
+ * dom/EventDispatcher.cpp:
+ (WebCore::dispatchEventInDOM):
+
</ins><span class="cx"> 2017-01-03 Jer Noble <jer.noble@apple.com>
</span><span class="cx">
</span><span class="cx"> Check for the existence of AVSampleBufferAudioRenderer.h before redeclaring AVSampleBufferAudioRenderer
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBEventDispatchercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBEventDispatcher.cpp (210253 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBEventDispatcher.cpp        2017-01-03 23:18:45 UTC (rev 210253)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBEventDispatcher.cpp        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx"> event.setEventPhase(Event::AT_TARGET);
</span><span class="cx"> event.setCurrentTarget(eventTargets[0].get());
</span><span class="cx"> eventTargets[0]->fireEventListeners(event);
</span><del>- if (event.propagationStopped() || !event.bubbles() || event.cancelBubble())
</del><ins>+ if (event.propagationStopped() || !event.bubbles())
</ins><span class="cx"> goto doneDispatching;
</span><span class="cx">
</span><span class="cx"> event.setEventPhase(Event::BUBBLING_PHASE);
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> for (size_t i = 1; i < size; ++i) { // Don't do the first element.
</span><span class="cx"> event.setCurrentTarget(eventTargets[i].get());
</span><span class="cx"> eventTargets[i]->fireEventListeners(event);
</span><del>- if (event.propagationStopped() || event.cancelBubble())
</del><ins>+ if (event.propagationStopped())
</ins><span class="cx"> goto doneDispatching;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoredomEventh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Event.h (210253 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Event.h        2017-01-03 23:18:45 UTC (rev 210253)
+++ trunk/Source/WebCore/dom/Event.h        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -176,8 +176,8 @@
</span><span class="cx">
</span><span class="cx"> void setInPassiveListener(bool value) { m_isExecutingPassiveEventListener = value; }
</span><span class="cx">
</span><del>- bool cancelBubble() const { return m_cancelBubble; }
- void setCancelBubble(bool cancel) { m_cancelBubble = cancel; }
</del><ins>+ bool cancelBubble() const { return propagationStopped(); }
+ void setCancelBubble(bool);
</ins><span class="cx">
</span><span class="cx"> Event* underlyingEvent() const { return m_underlyingEvent.get(); }
</span><span class="cx"> void setUnderlyingEvent(Event*);
</span><span class="lines">@@ -207,7 +207,6 @@
</span><span class="cx"> bool m_immediatePropagationStopped { false };
</span><span class="cx"> bool m_defaultPrevented { false };
</span><span class="cx"> bool m_defaultHandled { false };
</span><del>- bool m_cancelBubble { false };
</del><span class="cx"> bool m_isTrusted { false };
</span><span class="cx"> bool m_isExecutingPassiveEventListener { false };
</span><span class="cx">
</span><span class="lines">@@ -226,6 +225,12 @@
</span><span class="cx"> m_immediatePropagationStopped = false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+inline void Event::setCancelBubble(bool cancel)
+{
+ if (cancel)
+ m_propagationStopped = true;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #define SPECIALIZE_TYPE_TRAITS_EVENT(ToValueTypeName) \
</span></span></pre></div>
<a id="trunkSourceWebCoredomEventDispatchercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (210253 => 210254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/EventDispatcher.cpp        2017-01-03 23:18:45 UTC (rev 210253)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp        2017-01-03 23:51:39 UTC (rev 210254)
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx"> const EventContext& eventContext = path.contextAt(i);
</span><span class="cx"> if (eventContext.currentTargetSameAsTarget())
</span><span class="cx"> event.setEventPhase(Event::AT_TARGET);
</span><del>- else if (event.bubbles() && !event.cancelBubble())
</del><ins>+ else if (event.bubbles())
</ins><span class="cx"> event.setEventPhase(Event::BUBBLING_PHASE);
</span><span class="cx"> else
</span><span class="cx"> continue;
</span></span></pre>
</div>
</div>
</body>
</html>