<!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>[193286] 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/193286">193286</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2015-12-03 11:06:45 -0800 (Thu, 03 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Promise callbacks should be called at microtask checkpoints
https://bugs.webkit.org/show_bug.cgi?id=147933

Reviewed by Chris Dumez.

Source/WebCore:

- Re-names MicroTaskQueue and MicroTask to MicrotaskQueue and Microtask to match the spec language.
- Re-implements MicrotaskQueue and Microtask support suspended Microtasks (via the new KeepInQueue
  result value a Microtask can have when running) and correct behavior when Microtasks are added to
  the queue during a Microtask checkpoint.
- MicrotaskQueue now has a mainThreadQueue() static function, replacing the old singleton() function,
  which can be used for the Document (non-Worker) Microtasks. For Workers, the a MicrotaskQueue 
  can be separately allocated for each WorkerGlobalScope (though this was not done in this change).
- Adds a helper subclass of Microtask, ActiveDOMCallbackMicrotask, for Microtasks that are
  per-ScriptExecutationContext, and need to act as ActiveDOMCallbacks.
- Re-implement Document (non-Worker) Promises on top of ActiveDOMCallbackMicrotask.
- Re-implement MutationObserver delivery on top of Microtask.

Layout Test:
    fast/dom/microtask-promise-mutation-observer-order.html

* CMakeLists.txt:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
Add new files.

* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::queueTaskToEventLoop):
Switch to using ActiveDOMCallbackMicrotask/MicrotaskQueue rather than ScriptExecutionContext's Task mechanism
for JavaScriptCore tasks.

* bindings/js/JSMainThreadExecState.cpp:
(WebCore::JSMainThreadExecState::didLeaveScriptContext):
Perform a microtask checkpoint rather than calling MutationObserver code explicitly now that mutation observers
use microtasks.

* dom/ActiveDOMCallbackMicrotask.cpp: Added.
(WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask):
(WebCore::ActiveDOMCallbackMicrotask::~ActiveDOMCallbackMicrotask):
(WebCore::ActiveDOMCallbackMicrotask::run):
(WebCore::ActiveDOMCallbackMicrotask::contextDestroyed):
* dom/ActiveDOMCallbackMicrotask.h: Added.
Add a helper subclass of Microtask which behaves like a ActiveDOMCallback (e.g. supports suspension
and context destruction).

* dom/MicroTask.cpp: Renamed to Microtasks.cpp.
* dom/MicroTask.h: Renamed to Microtasks.h.
* dom/Microtasks.cpp: Renamed from Source/WebCore/dom/MicroTask.cpp.
(WebCore::Microtask::removeSelfFromQueue):
(WebCore::MicrotaskQueue::mainThreadQueue):
(WebCore::MicrotaskQueue::append):
(WebCore::MicrotaskQueue::remove):
(WebCore::MicrotaskQueue::performMicrotaskCheckpoint):
(WebCore::MicroTaskQueue::singleton): Deleted.
(WebCore::MicroTaskQueue::queueMicroTask): Deleted.
(WebCore::MicroTaskQueue::runMicroTasks): Deleted.
* dom/Microtasks.h: Renamed from Source/WebCore/dom/MicroTask.h.
(WebCore::Microtask::~Microtask):
(WebCore::MicrotaskQueue::MicrotaskQueue):
(WebCore::MicrotaskQueue::~MicrotaskQueue):
(WebCore::MicroTask::~MicroTask): Deleted.
(WebCore::MicroTaskQueue::~MicroTaskQueue): Deleted.
(WebCore::MicroTaskQueue::MicroTaskQueue): Deleted.
Re-implement MicrotaskQueue and Microtask to support Microtask suspension (via the KeepInQueue result
value) and correct behavior when Microtasks are queued during checkpoints.

* dom/MutationObserver.cpp:
(WebCore::suspendedMutationObservers):
(WebCore::MutationObserverMicrotask::MutationObserverMicrotask):
(WebCore::MutationObserverMicrotask::~MutationObserverMicrotask):
(WebCore::MutationObserverMicrotask::run):
(WebCore::queueMutationObserverCompoundMicrotask):
(WebCore::MutationObserver::enqueueMutationRecord):
(WebCore::MutationObserver::setHasTransientRegistration):
* dom/MutationObserver.h:
Re-implement MutationObserver delivery on top of Microtasks.

* dom/ScriptRunner.cpp:
(WebCore::ScriptRunner::timerFired):
Remove unnecessary call to runMicroTasks().

* html/parser/HTMLScriptRunner.cpp:
(WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
(WebCore::HTMLScriptRunner::runScript):
Remove calls to MutationObserver::deliverAllMutations() now that the MicrotaskQueue will take care of it.

(WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
Remove unnecessary call to runMicroTasks().

* testing/Internals.cpp:
(WebCore::Internals::queueMicroTask):
Use ActiveDOMCallbackMicrotask rather than a custom test subclass.

* testing/MicroTaskTest.cpp: Removed.
* testing/MicroTaskTest.h: Removed.
Remove custom test subclass of Microtask, just use ActiveDOMCallbackMicrotask directly.

LayoutTests:

* fast/dom/microtask-promise-mutation-observer-order-expected.txt: Added.
* fast/dom/microtask-promise-mutation-observer-order.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMWindowBasecpp">trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSMainThreadExecStatecpp">trunk/Source/WebCore/bindings/js/JSMainThreadExecState.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDOMAllInOnecpp">trunk/Source/WebCore/dom/DOMAllInOne.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMutationObservercpp">trunk/Source/WebCore/dom/MutationObserver.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMutationObserverh">trunk/Source/WebCore/dom/MutationObserver.h</a></li>
<li><a href="#trunkSourceWebCoredomScriptRunnercpp">trunk/Source/WebCore/dom/ScriptRunner.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLScriptRunnercpp">trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdommicrotaskpromisemutationobserverorderexpectedtxt">trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdommicrotaskpromisemutationobserverorderhtml">trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order.html</a></li>
<li><a href="#trunkSourceWebCoredomActiveDOMCallbackMicrotaskcpp">trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp</a></li>
<li><a href="#trunkSourceWebCoredomActiveDOMCallbackMicrotaskh">trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h</a></li>
<li><a href="#trunkSourceWebCoredomMicrotaskscpp">trunk/Source/WebCore/dom/Microtasks.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMicrotasksh">trunk/Source/WebCore/dom/Microtasks.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoredomMicroTaskcpp">trunk/Source/WebCore/dom/MicroTask.cpp</a></li>
<li><a href="#trunkSourceWebCoredomMicroTaskh">trunk/Source/WebCore/dom/MicroTask.h</a></li>
<li><a href="#trunkSourceWebCoretestingMicroTaskTestcpp">trunk/Source/WebCore/testing/MicroTaskTest.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingMicroTaskTesth">trunk/Source/WebCore/testing/MicroTaskTest.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/LayoutTests/ChangeLog        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-12-02  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Promise callbacks should be called at microtask checkpoints
+        https://bugs.webkit.org/show_bug.cgi?id=147933
+
+        Reviewed by Chris Dumez.
+
+        * fast/dom/microtask-promise-mutation-observer-order-expected.txt: Added.
+        * fast/dom/microtask-promise-mutation-observer-order.html: Added.
+
</ins><span class="cx"> 2015-12-03  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         ASSERT_WITH_SECURITY_IMPLICATION in WebCore::DocumentOrderedMap::add()
</span></span></pre></div>
<a id="trunkLayoutTestsfastdommicrotaskpromisemutationobserverorderexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order-expected.txt (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order-expected.txt        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+Test that promises and mutation observers are both delivered from the same microtask queue.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Expected result: promise,mutate,timeout
+Actual result: promise,mutate,timeout
+PASS actualResult is expectedResult
+
+Expected result: mutate,promise,timeout
+Actual result: mutate,promise,timeout
+PASS actualResult is expectedResult
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdommicrotaskpromisemutationobserverorderhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order.html (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/microtask-promise-mutation-observer-order.html        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,80 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta charset=&quot;utf-8&quot;&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+
+description(&quot;Test that promises and mutation observers are both delivered from the same microtask queue.&quot;);
+var jsTestIsAsync = true;
+
+var actualResult = [];
+var expectedResult = [];
+var currentTest = 0;
+
+new MutationObserver(function() { 
+    actualResult.push('mutate');
+    checkIfDone();
+}).observe(document.body, { attributes: true });
+function mutate()
+{
+    document.body.setAttribute('data-random', Math.random());
+}
+function promise()
+{
+    Promise.resolve().then(function() { 
+        actualResult.push('promise');
+        checkIfDone();
+    });
+}
+function timeout()
+{
+    setTimeout(function() {
+        actualResult.push('timeout');
+        checkIfDone();
+    }, 0);
+}
+
+function checkIfDone()
+{
+    if (actualResult.length != expectedResult.length)
+        return;
+
+    debug(&quot;Expected result: &quot; + expectedResult);
+    debug(&quot;Actual result: &quot; + actualResult);
+    shouldBe(&quot;actualResult&quot;, &quot;expectedResult&quot;);
+    debug(&quot;&quot;);
+
+    ++currentTest
+    runNextTest();
+}
+
+var tests = [
+    [[timeout, promise, mutate], [&quot;promise&quot;, &quot;mutate&quot;, &quot;timeout&quot;]],
+    [[timeout, mutate, promise], [&quot;mutate&quot;, &quot;promise&quot;, &quot;timeout&quot;]]
+];
+
+function runNextTest()
+{
+    if (currentTest &gt;= tests.length) {
+        finishJSTest();
+        return;
+    }
+
+    actualResult = [];
+    tasks = tests[currentTest][0];
+    expectedResult = tests[currentTest][1];
+
+    for (task of tasks) {
+        task();
+    }
+}
+
+runNextTest()
+
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1413,6 +1413,7 @@
</span><span class="cx"> 
</span><span class="cx">     cssjit/SelectorCompiler.cpp
</span><span class="cx"> 
</span><ins>+    dom/ActiveDOMCallbackMicrotask.cpp
</ins><span class="cx">     dom/ActiveDOMObject.cpp
</span><span class="cx">     dom/AnimationEvent.cpp
</span><span class="cx">     dom/Attr.cpp
</span><span class="lines">@@ -1485,7 +1486,7 @@
</span><span class="cx">     dom/MessageEvent.cpp
</span><span class="cx">     dom/MessagePort.cpp
</span><span class="cx">     dom/MessagePortChannel.cpp
</span><del>-    dom/MicroTask.cpp
</del><ins>+    dom/Microtasks.cpp
</ins><span class="cx">     dom/MouseEvent.cpp
</span><span class="cx">     dom/MouseRelatedEvent.cpp
</span><span class="cx">     dom/MutationEvent.cpp
</span><span class="lines">@@ -3344,7 +3345,6 @@
</span><span class="cx"> 
</span><span class="cx">     testing/InternalSettings.cpp
</span><span class="cx">     testing/Internals.cpp
</span><del>-    testing/MicroTaskTest.cpp
</del><span class="cx">     testing/MockPageOverlayClient.cpp
</span><span class="cx"> 
</span><span class="cx">     testing/js/WebCoreTestSupport.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/ChangeLog        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,3 +1,102 @@
</span><ins>+2015-12-02  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        Promise callbacks should be called at microtask checkpoints
+        https://bugs.webkit.org/show_bug.cgi?id=147933
+
+        Reviewed by Chris Dumez.
+
+        - Re-names MicroTaskQueue and MicroTask to MicrotaskQueue and Microtask to match the spec language.
+        - Re-implements MicrotaskQueue and Microtask support suspended Microtasks (via the new KeepInQueue
+          result value a Microtask can have when running) and correct behavior when Microtasks are added to
+          the queue during a Microtask checkpoint.
+        - MicrotaskQueue now has a mainThreadQueue() static function, replacing the old singleton() function,
+          which can be used for the Document (non-Worker) Microtasks. For Workers, the a MicrotaskQueue 
+          can be separately allocated for each WorkerGlobalScope (though this was not done in this change).
+        - Adds a helper subclass of Microtask, ActiveDOMCallbackMicrotask, for Microtasks that are
+          per-ScriptExecutationContext, and need to act as ActiveDOMCallbacks.
+        - Re-implement Document (non-Worker) Promises on top of ActiveDOMCallbackMicrotask.
+        - Re-implement MutationObserver delivery on top of Microtask.
+
+        Layout Test:
+            fast/dom/microtask-promise-mutation-observer-order.html
+
+        * CMakeLists.txt:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/DOMAllInOne.cpp:
+        Add new files.
+
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::JSDOMWindowBase::queueTaskToEventLoop):
+        Switch to using ActiveDOMCallbackMicrotask/MicrotaskQueue rather than ScriptExecutionContext's Task mechanism
+        for JavaScriptCore tasks.
+
+        * bindings/js/JSMainThreadExecState.cpp:
+        (WebCore::JSMainThreadExecState::didLeaveScriptContext):
+        Perform a microtask checkpoint rather than calling MutationObserver code explicitly now that mutation observers
+        use microtasks.
+
+        * dom/ActiveDOMCallbackMicrotask.cpp: Added.
+        (WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask):
+        (WebCore::ActiveDOMCallbackMicrotask::~ActiveDOMCallbackMicrotask):
+        (WebCore::ActiveDOMCallbackMicrotask::run):
+        (WebCore::ActiveDOMCallbackMicrotask::contextDestroyed):
+        * dom/ActiveDOMCallbackMicrotask.h: Added.
+        Add a helper subclass of Microtask which behaves like a ActiveDOMCallback (e.g. supports suspension
+        and context destruction).
+
+        * dom/MicroTask.cpp: Renamed to Microtasks.cpp.
+        * dom/MicroTask.h: Renamed to Microtasks.h.
+        * dom/Microtasks.cpp: Renamed from Source/WebCore/dom/MicroTask.cpp.
+        (WebCore::Microtask::removeSelfFromQueue):
+        (WebCore::MicrotaskQueue::mainThreadQueue):
+        (WebCore::MicrotaskQueue::append):
+        (WebCore::MicrotaskQueue::remove):
+        (WebCore::MicrotaskQueue::performMicrotaskCheckpoint):
+        (WebCore::MicroTaskQueue::singleton): Deleted.
+        (WebCore::MicroTaskQueue::queueMicroTask): Deleted.
+        (WebCore::MicroTaskQueue::runMicroTasks): Deleted.
+        * dom/Microtasks.h: Renamed from Source/WebCore/dom/MicroTask.h.
+        (WebCore::Microtask::~Microtask):
+        (WebCore::MicrotaskQueue::MicrotaskQueue):
+        (WebCore::MicrotaskQueue::~MicrotaskQueue):
+        (WebCore::MicroTask::~MicroTask): Deleted.
+        (WebCore::MicroTaskQueue::~MicroTaskQueue): Deleted.
+        (WebCore::MicroTaskQueue::MicroTaskQueue): Deleted.
+        Re-implement MicrotaskQueue and Microtask to support Microtask suspension (via the KeepInQueue result
+        value) and correct behavior when Microtasks are queued during checkpoints.
+
+        * dom/MutationObserver.cpp:
+        (WebCore::suspendedMutationObservers):
+        (WebCore::MutationObserverMicrotask::MutationObserverMicrotask):
+        (WebCore::MutationObserverMicrotask::~MutationObserverMicrotask):
+        (WebCore::MutationObserverMicrotask::run):
+        (WebCore::queueMutationObserverCompoundMicrotask):
+        (WebCore::MutationObserver::enqueueMutationRecord):
+        (WebCore::MutationObserver::setHasTransientRegistration):
+        * dom/MutationObserver.h:
+        Re-implement MutationObserver delivery on top of Microtasks.
+
+        * dom/ScriptRunner.cpp:
+        (WebCore::ScriptRunner::timerFired):
+        Remove unnecessary call to runMicroTasks().
+
+        * html/parser/HTMLScriptRunner.cpp:
+        (WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent):
+        (WebCore::HTMLScriptRunner::runScript):
+        Remove calls to MutationObserver::deliverAllMutations() now that the MicrotaskQueue will take care of it.
+
+        (WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing):
+        Remove unnecessary call to runMicroTasks().
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::queueMicroTask):
+        Use ActiveDOMCallbackMicrotask rather than a custom test subclass.
+
+        * testing/MicroTaskTest.cpp: Removed.
+        * testing/MicroTaskTest.h: Removed.
+        Remove custom test subclass of Microtask, just use ActiveDOMCallbackMicrotask directly.
+
</ins><span class="cx"> 2015-12-03  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add GetterRaisesExceptionWithMessage and SetterRaisesExceptionWithMessage to the code generator.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -13554,6 +13554,20 @@
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\dom\ActiveDOMCallbackMicrotask.cpp&quot;&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='DebugSuffix|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\dom\ActiveDOMObject.cpp&quot;&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="lines">@@ -14493,7 +14507,7 @@
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><del>-    &lt;ClCompile Include=&quot;..\dom\MicroTask.cpp&quot;&gt;
</del><ins>+    &lt;ClCompile Include=&quot;..\dom\Microtasks.cpp&quot;&gt;
</ins><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="lines">@@ -22035,6 +22049,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\xml\parser\MarkupTokenizerInlines.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\xml\parser\XMLDocumentParser.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\xml\parser\XMLDocumentParserScope.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\dom\ActiveDOMCallbackMicrotask.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\dom\ActiveDOMObject.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dom\AnimationEvent.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dom\Attr.h&quot; /&gt;
</span><span class="lines">@@ -22126,7 +22141,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dom\MessageEvent.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dom\MessagePort.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dom\MessagePortChannel.h&quot; /&gt;
</span><del>-    &lt;ClInclude Include=&quot;..\dom\MicroTask.h&quot; /&gt;
</del><ins>+    &lt;ClInclude Include=&quot;..\dom\Microtasks.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\dom\MouseEvent.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dom\MouseRelatedEvent.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\dom\MutationEvent.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -2278,7 +2278,7 @@
</span><span class="cx">                 536D5A23193E8E0C00CE4CAB /* ParsingUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 536D5A22193E8E0C00CE4CAB /* ParsingUtilities.h */; };
</span><span class="cx">                 536D5A25193F40FC00CE4CAB /* SourceSizeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */; };
</span><span class="cx">                 536D5A27193F410B00CE4CAB /* SourceSizeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 536D5A26193F410B00CE4CAB /* SourceSizeList.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* MicroTask.h */; };
</del><ins>+                53B895AF19DC7ED9009CAA93 /* Microtasks.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B895AD19DC7C37009CAA93 /* Microtasks.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 53C8298D13D8D92700DE2DEB /* RenderFlexibleBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */; };
</span><span class="cx">                 53C8298E13D8D92700DE2DEB /* RenderFlexibleBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 53E29E5E167A8A1900586D3D /* InternalSettingsGenerated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53E29E5C167A8A1900586D3D /* InternalSettingsGenerated.cpp */; };
</span><span class="lines">@@ -2753,6 +2753,8 @@
</span><span class="cx">                 7CC69940191EC5F500AF2270 /* JSWebKitNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC6993E191EC5F500AF2270 /* JSWebKitNamespace.cpp */; };
</span><span class="cx">                 7CC69941191EC5F500AF2270 /* JSWebKitNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CC6993F191EC5F500AF2270 /* JSWebKitNamespace.h */; };
</span><span class="cx">                 7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */; };
</span><ins>+                7CD0BA041B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */; };
+                7CD0BA051B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */; };
</ins><span class="cx">                 7CD494CC1A86EB1D000A87EC /* RenderAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */; };
</span><span class="cx">                 7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 7CDEEE1E197610D700E352CD /* ViewStateChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDEEE1D197610D700E352CD /* ViewStateChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -5935,9 +5937,7 @@
</span><span class="cx">                 CA3BF67E10D99BAE00E6CE53 /* ScrollAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */; };
</span><span class="cx">                 CAE9F910146441F000C245B0 /* CSSAspectRatioValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */; };
</span><del>-                CB8CF0181A9358D4000D510B /* MicroTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF0151A934B43000D510B /* MicroTask.cpp */; };
-                CB8CF01D1A95DE42000D510B /* MicroTaskTest.h in Headers */ = {isa = PBXBuildFile; fileRef = CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */; };
-                CB8CF01F1A95DE59000D510B /* MicroTaskTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */; };
</del><ins>+                CB8CF0181A9358D4000D510B /* Microtasks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB8CF0151A934B43000D510B /* Microtasks.cpp */; };
</ins><span class="cx">                 CCC2B51415F613060048CDD6 /* DeviceClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51015F613060048CDD6 /* DeviceClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 CCC2B51515F613060048CDD6 /* DeviceController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CCC2B51115F613060048CDD6 /* DeviceController.cpp */; };
</span><span class="cx">                 CCC2B51615F613060048CDD6 /* DeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC2B51215F613060048CDD6 /* DeviceController.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -9745,7 +9745,7 @@
</span><span class="cx">                 536D5A22193E8E0C00CE4CAB /* ParsingUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParsingUtilities.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 536D5A24193F40FC00CE4CAB /* SourceSizeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SourceSizeList.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 536D5A26193F410B00CE4CAB /* SourceSizeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceSizeList.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                53B895AD19DC7C37009CAA93 /* MicroTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MicroTask.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                53B895AD19DC7C37009CAA93 /* Microtasks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Microtasks.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 53C8298B13D8D92700DE2DEB /* RenderFlexibleBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFlexibleBox.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFlexibleBox.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 53E29E5C167A8A1900586D3D /* InternalSettingsGenerated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InternalSettingsGenerated.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -10288,6 +10288,8 @@
</span><span class="cx">                 7CC6993E191EC5F500AF2270 /* JSWebKitNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitNamespace.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CC6993F191EC5F500AF2270 /* JSWebKitNamespace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitNamespace.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDNScriptWhiteList.txt; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActiveDOMCallbackMicrotask.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActiveDOMCallbackMicrotask.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderAttachment.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderAttachment.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7CDEEE1D197610D700E352CD /* ViewStateChangeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewStateChangeObserver.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -13776,9 +13778,7 @@
</span><span class="cx">                 CA3BF67D10D99BAE00E6CE53 /* ScrollAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimator.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CAE9F90D146441F000C245B0 /* CSSAspectRatioValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSAspectRatioValue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CAE9F90E146441F000C245B0 /* CSSAspectRatioValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAspectRatioValue.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                CB8CF0151A934B43000D510B /* MicroTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MicroTask.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MicroTaskTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
-                CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MicroTaskTest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><ins>+                CB8CF0151A934B43000D510B /* Microtasks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Microtasks.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 CCC2B51015F613060048CDD6 /* DeviceClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CCC2B51115F613060048CDD6 /* DeviceController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceController.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CCC2B51215F613060048CDD6 /* DeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -16470,8 +16470,6 @@
</span><span class="cx">                                 A7BE7EDE14C9175A0014489D /* MallocStatistics.idl */,
</span><span class="cx">                                 CD5393CB175DCCE600C07123 /* MemoryInfo.h */,
</span><span class="cx">                                 CD5393CC175DCCE600C07123 /* MemoryInfo.idl */,
</span><del>-                                CB8CF01E1A95DE59000D510B /* MicroTaskTest.cpp */,
-                                CB8CF01C1A95DE42000D510B /* MicroTaskTest.h */,
</del><span class="cx">                                 CDC26B3C160A62B00026757B /* MockCDM.cpp */,
</span><span class="cx">                                 CDC26B3D160A62B00026757B /* MockCDM.h */,
</span><span class="cx">                                 A1BF6B801AA96C7D00AF4A8A /* MockContentFilter.cpp */,
</span><span class="lines">@@ -23783,6 +23781,8 @@
</span><span class="cx">                                 2D5036661BCDDDC400E20BB3 /* mac */,
</span><span class="cx">                                 E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */,
</span><span class="cx">                                 E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */,
</span><ins>+                                7CD0BA021B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp */,
+                                7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */,
</ins><span class="cx">                                 319847FE1A1D816700A13318 /* AnimationEvent.cpp */,
</span><span class="cx">                                 319847FF1A1D816700A13318 /* AnimationEvent.h */,
</span><span class="cx">                                 319848001A1D816700A13318 /* AnimationEvent.idl */,
</span><span class="lines">@@ -23999,8 +23999,8 @@
</span><span class="cx">                                 E1ADECBD0E76ACF1004A1A5E /* MessagePort.h */,
</span><span class="cx">                                 E1ADECC60E76AD1F004A1A5E /* MessagePort.idl */,
</span><span class="cx">                                 41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */,
</span><del>-                                CB8CF0151A934B43000D510B /* MicroTask.cpp */,
-                                53B895AD19DC7C37009CAA93 /* MicroTask.h */,
</del><ins>+                                CB8CF0151A934B43000D510B /* Microtasks.cpp */,
+                                53B895AD19DC7C37009CAA93 /* Microtasks.h */,
</ins><span class="cx">                                 85031B2F0A44EFC700F992E0 /* MouseEvent.cpp */,
</span><span class="cx">                                 85031B300A44EFC700F992E0 /* MouseEvent.h */,
</span><span class="cx">                                 141B94E509EC4223000E9413 /* MouseEvent.idl */,
</span><span class="lines">@@ -24571,7 +24571,6 @@
</span><span class="cx">                                 CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */,
</span><span class="cx">                                 A19AEA211AAA808600B52B25 /* JSMockContentFilterSettings.h in Headers */,
</span><span class="cx">                                 EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
</span><del>-                                CB8CF01D1A95DE42000D510B /* MicroTaskTest.h in Headers */,
</del><span class="cx">                                 CDC26B41160A8CCE0026757B /* MockCDM.h in Headers */,
</span><span class="cx">                                 A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */,
</span><span class="cx">                                 A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */,
</span><span class="lines">@@ -26819,7 +26818,7 @@
</span><span class="cx">                                 A78E52701346BD1700AD9C31 /* MeterShadowElement.h in Headers */,
</span><span class="cx">                                 37DDCDA51384501C0008B793 /* MHTMLArchive.h in Headers */,
</span><span class="cx">                                 37DDCDA71384501C0008B793 /* MHTMLParser.h in Headers */,
</span><del>-                                53B895AF19DC7ED9009CAA93 /* MicroTask.h in Headers */,
</del><ins>+                                53B895AF19DC7ED9009CAA93 /* Microtasks.h in Headers */,
</ins><span class="cx">                                 37DDCD9513844FD50008B793 /* MIMEHeader.h in Headers */,
</span><span class="cx">                                 BC772C4F0C4EB3040083285F /* MIMETypeRegistry.h in Headers */,
</span><span class="cx">                                 52F10866162B6DA8009AC81E /* MixedContentChecker.h in Headers */,
</span><span class="lines">@@ -27500,6 +27499,7 @@
</span><span class="cx">                                 84730D931248F0B300D3A9C9 /* SpotLightSource.h in Headers */,
</span><span class="cx">                                 97BC6A3B1505F081001B74AC /* SQLCallbackWrapper.h in Headers */,
</span><span class="cx">                                 97BC6A3C1505F081001B74AC /* SQLError.h in Headers */,
</span><ins>+                                7CD0BA051B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h in Headers */,
</ins><span class="cx">                                 97BC6A3F1505F081001B74AC /* SQLException.h in Headers */,
</span><span class="cx">                                 1A22464A0CC98DDB00C05240 /* SQLiteDatabase.h in Headers */,
</span><span class="cx">                                 7E474E1F12494DC900235364 /* SQLiteDatabaseTracker.h in Headers */,
</span><span class="lines">@@ -28510,7 +28510,6 @@
</span><span class="cx">                                 A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */,
</span><span class="cx">                                 A1E5B31F1AAD1DA4006EBEFB /* JSMockContentFilterSettingsCustom.cpp in Sources */,
</span><span class="cx">                                 EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
</span><del>-                                CB8CF01F1A95DE59000D510B /* MicroTaskTest.cpp in Sources */,
</del><span class="cx">                                 CDC26B40160A8CC60026757B /* MockCDM.cpp in Sources */,
</span><span class="cx">                                 A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */,
</span><span class="cx">                                 A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */,
</span><span class="lines">@@ -28968,6 +28967,7 @@
</span><span class="cx">                                 49FC7A501444AF5F00A5D864 /* DisplayRefreshMonitor.cpp in Sources */,
</span><span class="cx">                                 2D29ECC5192ECC8300984B78 /* DisplayRefreshMonitorClient.cpp in Sources */,
</span><span class="cx">                                 0F97A658155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm in Sources */,
</span><ins>+                                7CD0BA041B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.cpp in Sources */,
</ins><span class="cx">                                 49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */,
</span><span class="cx">                                 2D29ECC7192ECC8300984B78 /* DisplayRefreshMonitorManager.cpp in Sources */,
</span><span class="cx">                                 CD52481A18E200ED0008A07D /* DisplaySleepDisabler.cpp in Sources */,
</span><span class="lines">@@ -30519,7 +30519,7 @@
</span><span class="cx">                                 75793E830D0CE0B3007FC0AC /* MessageEvent.cpp in Sources */,
</span><span class="cx">                                 E1ADECC00E76ACF1004A1A5E /* MessagePort.cpp in Sources */,
</span><span class="cx">                                 A78E526F1346BD1700AD9C31 /* MeterShadowElement.cpp in Sources */,
</span><del>-                                CB8CF0181A9358D4000D510B /* MicroTask.cpp in Sources */,
</del><ins>+                                CB8CF0181A9358D4000D510B /* Microtasks.cpp in Sources */,
</ins><span class="cx">                                 37DDCD9413844FD50008B793 /* MIMEHeader.cpp in Sources */,
</span><span class="cx">                                 BC772C4E0C4EB3040083285F /* MIMETypeRegistry.cpp in Sources */,
</span><span class="cx">                                 E453901D0EAFCACA003695C8 /* MIMETypeRegistryIOS.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMWindowBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -24,12 +24,14 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;JSDOMWindowBase.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;ActiveDOMCallbackMicrotask.h&quot;
</ins><span class="cx"> #include &quot;Chrome.h&quot;
</span><span class="cx"> #include &quot;DOMWindow.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;InspectorController.h&quot;
</span><span class="cx"> #include &quot;JSDOMGlobalObjectTask.h&quot;
</span><span class="cx"> #include &quot;JSDOMWindowCustom.h&quot;
</span><ins>+#include &quot;JSMainThreadExecState.h&quot;
</ins><span class="cx"> #include &quot;JSModuleLoader.h&quot;
</span><span class="cx"> #include &quot;JSNode.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="lines">@@ -39,6 +41,7 @@
</span><span class="cx"> #include &quot;SecurityOrigin.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;WebCoreJSClientData.h&quot;
</span><ins>+#include &lt;heap/StrongInlines.h&gt;
</ins><span class="cx"> #include &lt;runtime/JSInternalPromiseDeferred.h&gt;
</span><span class="cx"> #include &lt;runtime/Microtask.h&gt;
</span><span class="cx"> #include &lt;wtf/MainThread.h&gt;
</span><span class="lines">@@ -240,10 +243,46 @@
</span><span class="cx">     return frame-&gt;settings().javaScriptRuntimeFlags();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void JSDOMWindowBase::queueTaskToEventLoop(const JSGlobalObject* object, PassRefPtr&lt;Microtask&gt; task)
</del><ins>+class JSDOMWindowMicrotaskCallback : public RefCounted&lt;JSDOMWindowMicrotaskCallback&gt; {
+public:
+    static Ref&lt;JSDOMWindowMicrotaskCallback&gt; create(JSDOMWindowBase* globalObject, PassRefPtr&lt;JSC::Microtask&gt; task)
+    {
+        return adoptRef(*new JSDOMWindowMicrotaskCallback(globalObject, task));
+    }
+
+    void call()
+    {
+        Ref&lt;JSDOMWindowMicrotaskCallback&gt; protect(*this);
+        JSLockHolder lock(m_globalObject-&gt;vm());
+
+        ExecState* exec = m_globalObject-&gt;globalExec();
+
+        JSMainThreadExecState::runTask(exec, *m_task.get());
+
+        ASSERT(!exec-&gt;hadException());
+    }
+
+private:
+    JSDOMWindowMicrotaskCallback(JSDOMWindowBase* globalObject, PassRefPtr&lt;JSC::Microtask&gt; task)
+        : m_globalObject(globalObject-&gt;vm(), globalObject)
+        , m_task(task)
+    {
+    }
+
+    Strong&lt;JSDOMWindowBase&gt; m_globalObject;
+    RefPtr&lt;JSC::Microtask&gt; m_task;
+};
+
+void JSDOMWindowBase::queueTaskToEventLoop(const JSGlobalObject* object, PassRefPtr&lt;JSC::Microtask&gt; task)
</ins><span class="cx"> {
</span><span class="cx">     const JSDOMWindowBase* thisObject = static_cast&lt;const JSDOMWindowBase*&gt;(object);
</span><del>-    thisObject-&gt;scriptExecutionContext()-&gt;postTask(JSGlobalObjectTask((JSDOMWindowBase*)thisObject, task));
</del><ins>+
+    RefPtr&lt;JSDOMWindowMicrotaskCallback&gt; callback = JSDOMWindowMicrotaskCallback::create((JSDOMWindowBase*)thisObject, task);
+    auto microtask = std::make_unique&lt;ActiveDOMCallbackMicrotask&gt;(MicrotaskQueue::mainThreadQueue(), *thisObject-&gt;scriptExecutionContext(), [callback]() mutable {
+        callback-&gt;call();
+    });
+
+    MicrotaskQueue::mainThreadQueue().append(WTF::move(microtask));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void JSDOMWindowBase::willRemoveFromWindowShell()
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSMainThreadExecStatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSMainThreadExecState.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSMainThreadExecState.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/bindings/js/JSMainThreadExecState.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -25,6 +25,8 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;JSMainThreadExecState.h&quot;
</span><ins>+
+#include &quot;Microtasks.h&quot;
</ins><span class="cx"> #include &quot;MutationObserver.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(INDEXED_DATABASE)
</span><span class="lines">@@ -43,7 +45,7 @@
</span><span class="cx">     IDBPendingTransactionMonitor::deactivateNewTransactions();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    MutationObserver::deliverAllMutations();
</del><ins>+    MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSC::JSValue functionCallHandlerFromAnyThread(JSC::ExecState* exec, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData&amp; callData, JSC::JSValue thisValue, const JSC::ArgList&amp; args, NakedPtr&lt;JSC::Exception&gt;&amp; returnedException)
</span></span></pre></div>
<a id="trunkSourceWebCoredomActiveDOMCallbackMicrotaskcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp                                (rev 0)
+++ trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;ActiveDOMCallbackMicrotask.h&quot;
+
+namespace WebCore {
+
+ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask(MicrotaskQueue&amp; queue, ScriptExecutionContext&amp; scriptExecutionContext, std::function&lt;void()&gt;&amp;&amp; task)
+    : ActiveDOMCallback(&amp;scriptExecutionContext)
+    , m_queue(queue)
+    , m_task(WTF::move(task))
+{
+}
+
+ActiveDOMCallbackMicrotask::~ActiveDOMCallbackMicrotask()
+{
+}
+
+Microtask::Result ActiveDOMCallbackMicrotask::run()
+{
+    if (!canInvokeCallback())
+        return Result::KeepInQueue;
+
+    m_task();
+    return Result::Done;
+}
+
+void ActiveDOMCallbackMicrotask::contextDestroyed()
+{
+    // NOTE: Calling the function below will cause this to be destroyed.
+    removeSelfFromQueue(m_queue);
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoredomActiveDOMCallbackMicrotaskh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h                                (rev 0)
+++ trunk/Source/WebCore/dom/ActiveDOMCallbackMicrotask.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ActiveDOMCallbackMicrotask_h
+#define ActiveDOMCallbackMicrotask_h
+
+#include &quot;ActiveDOMCallback.h&quot;
+#include &quot;Microtasks.h&quot;
+#include &lt;functional&gt;
+
+namespace WebCore {
+
+class ActiveDOMCallbackMicrotask : public Microtask, public ActiveDOMCallback {
+public:
+    WEBCORE_EXPORT ActiveDOMCallbackMicrotask(MicrotaskQueue&amp;, ScriptExecutionContext&amp;, std::function&lt;void()&gt;&amp;&amp;);
+    virtual ~ActiveDOMCallbackMicrotask();
+
+    virtual Result run() override;
+
+private:
+    virtual void contextDestroyed() override;
+
+    // FIXME: It should not be necessary to have the queue as a member. Instead, it should
+    // be accessed via the ScriptExecutionContext, which should hold a reference to the relevent
+    // queue.
+    MicrotaskQueue&amp; m_queue;
+    std::function&lt;void()&gt; m_task;
+};
+
+} // namespace WebCore
+
+#endif // ActiveDOMCallbackMicrotask_h
</ins></span></pre></div>
<a id="trunkSourceWebCoredomDOMAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DOMAllInOne.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
</span><span class="cx"> 
</span><ins>+#include &quot;ActiveDOMCallbackMicrotask.cpp&quot;
</ins><span class="cx"> #include &quot;ActiveDOMObject.cpp&quot;
</span><span class="cx"> #include &quot;AnimationEvent.cpp&quot;
</span><span class="cx"> #include &quot;Attr.cpp&quot;
</span><span class="lines">@@ -97,7 +98,7 @@
</span><span class="cx"> #include &quot;MessageEvent.cpp&quot;
</span><span class="cx"> #include &quot;MessagePort.cpp&quot;
</span><span class="cx"> #include &quot;MessagePortChannel.cpp&quot;
</span><del>-#include &quot;MicroTask.cpp&quot;
</del><ins>+#include &quot;Microtasks.cpp&quot;
</ins><span class="cx"> #include &quot;MouseEvent.cpp&quot;
</span><span class="cx"> #include &quot;MouseRelatedEvent.cpp&quot;
</span><span class="cx"> #include &quot;MutationEvent.cpp&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoredomMicroTaskcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/dom/MicroTask.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MicroTask.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/MicroTask.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,51 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 Yoav Weiss (yoav@yoav.ws)
- * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include &quot;config.h&quot;
-#include &quot;MicroTask.h&quot;
-
-#include &quot;Document.h&quot;
-
-namespace WebCore {
-
-MicroTaskQueue&amp; MicroTaskQueue::singleton()
-{
-    ASSERT(isMainThread());
-    static NeverDestroyed&lt;MicroTaskQueue&gt; queue;
-    return queue;
-}
-
-void MicroTaskQueue::queueMicroTask(std::unique_ptr&lt;MicroTask&gt; task)
-{
-    ASSERT(isMainThread());
-    m_microTaskQueue.append(WTF::move(task));
-}
-
-void MicroTaskQueue::runMicroTasks()
-{
-    ASSERT(isMainThread());
-    for (auto&amp; task : m_microTaskQueue)
-        task-&gt;run();
-    m_microTaskQueue.clear();
-}
-
-} // namespace WebCore
-
</del></span></pre></div>
<a id="trunkSourceWebCoredomMicroTaskh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/dom/MicroTask.h (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MicroTask.h        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/MicroTask.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,55 +0,0 @@
</span><del>-/*
- * Copyright (C) 2014 Yoav Weiss (yoav@yoav.ws)
- * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef MicroTask_h
-#define MicroTask_h
-
-#include &lt;wtf/NeverDestroyed.h&gt;
-#include &lt;wtf/Vector.h&gt;
-
-
-namespace WebCore {
-
-class MicroTask {
-public:
-    virtual void run() = 0;
-    virtual ~MicroTask() { }
-};
-
-class MicroTaskQueue {
-    friend NeverDestroyed&lt;MicroTaskQueue&gt;;
-
-public:
-    WEBCORE_EXPORT static MicroTaskQueue&amp; singleton();
-    ~MicroTaskQueue() { }
-
-    WEBCORE_EXPORT void queueMicroTask(std::unique_ptr&lt;MicroTask&gt;);
-
-    void runMicroTasks();
-
-private:
-    MicroTaskQueue() { }
-    Vector&lt;std::unique_ptr&lt;MicroTask&gt;&gt; m_microTaskQueue;
-};
-
-} // namespace WebCore
-
-#endif // MicroTask_h
</del></span></pre></div>
<a id="trunkSourceWebCoredomMicrotaskscppfromrev192969trunkSourceWebCoredomMicroTaskcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/Microtasks.cpp (from rev 192969, trunk/Source/WebCore/dom/MicroTask.cpp) (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Microtasks.cpp                                (rev 0)
+++ trunk/Source/WebCore/dom/Microtasks.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,106 @@
</span><ins>+/*
+ * Copyright (C) 2014 Yoav Weiss (yoav@yoav.ws)
+ * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include &quot;config.h&quot;
+#include &quot;Microtasks.h&quot;
+
+#include &lt;wtf/MainThread.h&gt;
+#include &lt;wtf/TemporaryChange.h&gt;
+
+namespace WebCore {
+
+void Microtask::removeSelfFromQueue(MicrotaskQueue&amp; queue)
+{
+    queue.remove(*this);
+}
+
+MicrotaskQueue::MicrotaskQueue()
+    : m_timer(*this, &amp;MicrotaskQueue::timerFired)
+{
+}
+
+MicrotaskQueue::~MicrotaskQueue()
+{
+}
+
+MicrotaskQueue&amp; MicrotaskQueue::mainThreadQueue()
+{
+    ASSERT(isMainThread());
+    static NeverDestroyed&lt;MicrotaskQueue&gt; queue;
+    return queue;
+}
+
+void MicrotaskQueue::append(std::unique_ptr&lt;Microtask&gt;&amp;&amp; task)
+{
+    if (m_performingMicrotaskCheckpoint)
+        m_tasksAppendedDuringMicrotaskCheckpoint.append(WTF::move(task));
+    else
+        m_microtaskQueue.append(WTF::move(task));
+
+    m_timer.startOneShot(0);
+}
+
+void MicrotaskQueue::remove(const Microtask&amp; task)
+{
+    for (size_t i = 0; i &lt; m_microtaskQueue.size(); ++i) {
+        if (m_microtaskQueue[i].get() == &amp;task) {
+            m_microtaskQueue.remove(i);
+            return;
+        }
+    }
+    for (size_t i = 0; i &lt; m_tasksAppendedDuringMicrotaskCheckpoint.size(); ++i) {
+        if (m_tasksAppendedDuringMicrotaskCheckpoint[i].get() == &amp;task) {
+            m_tasksAppendedDuringMicrotaskCheckpoint.remove(i);
+            return;
+        }
+    }
+}
+
+void MicrotaskQueue::timerFired()
+{
+    performMicrotaskCheckpoint();
+}
+
+void MicrotaskQueue::performMicrotaskCheckpoint()
+{
+    if (m_performingMicrotaskCheckpoint)
+        return;
+
+    TemporaryChange&lt;bool&gt; change(m_performingMicrotaskCheckpoint, true);
+
+    Vector&lt;std::unique_ptr&lt;Microtask&gt;&gt; queue = WTF::move(m_microtaskQueue);
+    for (auto&amp; task : queue) {
+        auto result = task-&gt;run();
+        switch (result) {
+        case Microtask::Result::Done:
+            break;
+        case Microtask::Result::KeepInQueue:
+            m_microtaskQueue.append(WTF::move(task));
+            break;
+        }
+    }
+
+    for (auto&amp; task : m_tasksAppendedDuringMicrotaskCheckpoint)
+        m_microtaskQueue.append(WTF::move(task));
+    m_tasksAppendedDuringMicrotaskCheckpoint.clear();
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoredomMicrotaskshfromrev192969trunkSourceWebCoredomMicroTaskh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/dom/Microtasks.h (from rev 192969, trunk/Source/WebCore/dom/MicroTask.h) (0 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Microtasks.h                                (rev 0)
+++ trunk/Source/WebCore/dom/Microtasks.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+/*
+ * Copyright (C) 2014 Yoav Weiss (yoav@yoav.ws)
+ * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef Microtasks_h
+#define Microtasks_h
+
+#include &quot;Timer.h&quot;
+#include &lt;wtf/NeverDestroyed.h&gt;
+#include &lt;wtf/Vector.h&gt;
+
+namespace WebCore {
+
+class MicrotaskQueue;
+
+class Microtask {
+public:
+    virtual ~Microtask()
+    {
+    }
+
+    enum class Result {
+        Done,
+        KeepInQueue
+    };
+
+    virtual Result run() = 0;
+
+protected:
+    void removeSelfFromQueue(MicrotaskQueue&amp;);
+};
+
+class MicrotaskQueue {
+    friend NeverDestroyed&lt;MicrotaskQueue&gt;;
+    friend class Microtask;
+public:
+    WEBCORE_EXPORT static MicrotaskQueue&amp; mainThreadQueue();
+
+    WEBCORE_EXPORT MicrotaskQueue();
+    WEBCORE_EXPORT ~MicrotaskQueue();
+
+    WEBCORE_EXPORT void append(std::unique_ptr&lt;Microtask&gt;&amp;&amp;);
+    WEBCORE_EXPORT void performMicrotaskCheckpoint();
+
+private:
+    WEBCORE_EXPORT void remove(const Microtask&amp;);
+
+    void timerFired();
+
+    bool m_performingMicrotaskCheckpoint = false;
+    Vector&lt;std::unique_ptr&lt;Microtask&gt;&gt; m_microtaskQueue;
+    Vector&lt;std::unique_ptr&lt;Microtask&gt;&gt; m_tasksAppendedDuringMicrotaskCheckpoint;
+
+    // FIXME: Instead of a Timer, we should have a centralized Event Loop that calls performMicrotaskCheckpoint()
+    // on every iteration, implementing https://html.spec.whatwg.org/multipage/webappapis.html#processing-model-9
+    Timer m_timer;
+};
+
+} // namespace WebCore
+
+#endif // Microtask_h
</ins></span></pre></div>
<a id="trunkSourceWebCoredomMutationObservercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MutationObserver.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MutationObserver.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/MutationObserver.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;Dictionary.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><ins>+#include &quot;Microtasks.h&quot;
</ins><span class="cx"> #include &quot;MutationCallback.h&quot;
</span><span class="cx"> #include &quot;MutationObserverRegistration.h&quot;
</span><span class="cx"> #include &quot;MutationRecord.h&quot;
</span><span class="lines">@@ -154,17 +155,54 @@
</span><span class="cx">     return suspendedObservers;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static bool mutationObserverCompoundMicrotaskQueuedFlag;
+
+class MutationObserverMicrotask : public Microtask {
+public:
+    MutationObserverMicrotask()
+    {
+    }
+
+    virtual ~MutationObserverMicrotask()
+    {
+    }
+
+private:    
+    virtual Result run()
+    {
+        mutationObserverCompoundMicrotaskQueuedFlag = false;
+
+        MutationObserver::deliverAllMutations();
+
+        return Result::Done;
+    }
+};
+
+static void queueMutationObserverCompoundMicrotask()
+{
+    if (mutationObserverCompoundMicrotaskQueuedFlag)
+        return;
+    mutationObserverCompoundMicrotaskQueuedFlag = true;
+
+    auto microtask = std::make_unique&lt;MutationObserverMicrotask&gt;();
+    MicrotaskQueue::mainThreadQueue().append(WTF::move(microtask));
+}
+
</ins><span class="cx"> void MutationObserver::enqueueMutationRecord(PassRefPtr&lt;MutationRecord&gt; mutation)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span><span class="cx">     m_records.append(mutation);
</span><span class="cx">     activeMutationObservers().add(this);
</span><ins>+
+    queueMutationObserverCompoundMicrotask();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MutationObserver::setHasTransientRegistration()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span><span class="cx">     activeMutationObservers().add(this);
</span><ins>+
+    queueMutationObserverCompoundMicrotask();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> HashSet&lt;Node*&gt; MutationObserver::getObservedNodes() const
</span></span></pre></div>
<a id="trunkSourceWebCoredomMutationObserverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/MutationObserver.h (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/MutationObserver.h        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/MutationObserver.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> typedef unsigned char MutationRecordDeliveryOptions;
</span><span class="cx"> 
</span><span class="cx"> class MutationObserver : public RefCounted&lt;MutationObserver&gt; {
</span><ins>+    friend class MutationObserverMicrotask;
</ins><span class="cx"> public:
</span><span class="cx">     enum MutationType {
</span><span class="cx">         ChildList = 1 &lt;&lt; 0,
</span><span class="lines">@@ -73,7 +74,6 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     static Ref&lt;MutationObserver&gt; create(PassRefPtr&lt;MutationCallback&gt;);
</span><del>-    static void deliverAllMutations();
</del><span class="cx"> 
</span><span class="cx">     ~MutationObserver();
</span><span class="cx"> 
</span><span class="lines">@@ -94,6 +94,7 @@
</span><span class="cx">     explicit MutationObserver(PassRefPtr&lt;MutationCallback&gt;);
</span><span class="cx">     void deliver();
</span><span class="cx"> 
</span><ins>+    static void deliverAllMutations();
</ins><span class="cx">     static bool validateOptions(MutationObserverOptions);
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;MutationCallback&gt; m_callback;
</span></span></pre></div>
<a id="trunkSourceWebCoredomScriptRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ScriptRunner.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ScriptRunner.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/dom/ScriptRunner.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CachedScript.h&quot;
</span><span class="cx"> #include &quot;Element.h&quot;
</span><del>-#include &quot;MicroTask.h&quot;
</del><span class="cx"> #include &quot;PendingScript.h&quot;
</span><span class="cx"> #include &quot;ScriptElement.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -120,7 +119,6 @@
</span><span class="cx">         toScriptElementIfPossible(element.get())-&gt;execute(cachedScript);
</span><span class="cx">         m_document.decrementLoadEventDelayCount();
</span><span class="cx">     }
</span><del>-    MicroTaskQueue::singleton().runMicroTasks();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLScriptRunnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/html/parser/HTMLScriptRunner.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;HTMLScriptRunnerHost.h&quot;
</span><span class="cx"> #include &quot;IgnoreDestructiveWriteCountIncrementer.h&quot;
</span><del>-#include &quot;MicroTask.h&quot;
</del><ins>+#include &quot;Microtasks.h&quot;
</ins><span class="cx"> #include &quot;MutationObserver.h&quot;
</span><span class="cx"> #include &quot;NestingLevelIncrementer.h&quot;
</span><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><span class="lines">@@ -129,10 +129,8 @@
</span><span class="cx">     if (pendingScript.cachedScript() &amp;&amp; pendingScript.watchingForLoad())
</span><span class="cx">         stopWatchingForLoad(pendingScript);
</span><span class="cx"> 
</span><del>-    if (!isExecutingScript()) {
-        MutationObserver::deliverAllMutations();
-        MicroTaskQueue::singleton().runMicroTasks();
-    }
</del><ins>+    if (!isExecutingScript())
+        MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
</ins><span class="cx"> 
</span><span class="cx">     // Clear the pending script before possible rentrancy from executeScript()
</span><span class="cx">     RefPtr&lt;Element&gt; element = pendingScript.releaseElementAndClear();
</span><span class="lines">@@ -233,8 +231,6 @@
</span><span class="cx">         if (!m_document)
</span><span class="cx">             return false;
</span><span class="cx">     }
</span><del>-    if (!isExecutingScript())
-        MicroTaskQueue::singleton().runMicroTasks();
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -297,10 +293,8 @@
</span><span class="cx">         // every script element, even if it's not ready to execute yet. There's
</span><span class="cx">         // unfortuantely no obvious way to tell if prepareScript is going to
</span><span class="cx">         // execute the script from out here.
</span><del>-        if (!isExecutingScript()) {
-            MutationObserver::deliverAllMutations();
-            MicroTaskQueue::singleton().runMicroTasks();
-        }
</del><ins>+        if (!isExecutingScript())
+            MicrotaskQueue::mainThreadQueue().performMicrotaskCheckpoint();
</ins><span class="cx"> 
</span><span class="cx">         InsertionPointRecord insertionPointRecord(m_host.inputStream());
</span><span class="cx">         NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/testing/Internals.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include &quot;Internals.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AXObjectCache.h&quot;
</span><ins>+#include &quot;ActiveDOMCallbackMicrotask.h&quot;
</ins><span class="cx"> #include &quot;AnimationController.h&quot;
</span><span class="cx"> #include &quot;ApplicationCacheStorage.h&quot;
</span><span class="cx"> #include &quot;BackForwardController.h&quot;
</span><span class="lines">@@ -81,8 +82,6 @@
</span><span class="cx"> #include &quot;MediaPlayer.h&quot;
</span><span class="cx"> #include &quot;MemoryCache.h&quot;
</span><span class="cx"> #include &quot;MemoryInfo.h&quot;
</span><del>-#include &quot;MicroTask.h&quot;
-#include &quot;MicroTaskTest.h&quot;
</del><span class="cx"> #include &quot;MockPageOverlayClient.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PageCache.h&quot;
</span><span class="lines">@@ -3055,8 +3054,15 @@
</span><span class="cx"> 
</span><span class="cx"> void Internals::queueMicroTask(int testNumber)
</span><span class="cx"> {
</span><del>-    if (contextDocument())
-        MicroTaskQueue::singleton().queueMicroTask(std::make_unique&lt;MicroTaskTest&gt;(contextDocument()-&gt;createWeakPtr(), testNumber));
</del><ins>+    Document* document = contextDocument();
+    if (!document)
+        return;
+
+    auto microtask = std::make_unique&lt;ActiveDOMCallbackMicrotask&gt;(MicrotaskQueue::mainThreadQueue(), *document, [document, testNumber]() {
+        document-&gt;addConsoleMessage(MessageSource::JS, MessageLevel::Debug, makeString(&quot;MicroTask #&quot;, String::number(testNumber), &quot; has run.&quot;));
+    });
+
+    MicrotaskQueue::mainThreadQueue().append(WTF::move(microtask));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_FILTERING)
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMicroTaskTestcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/testing/MicroTaskTest.cpp (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MicroTaskTest.cpp        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/testing/MicroTaskTest.cpp        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,34 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include &quot;config.h&quot;
-#include &quot;MicroTaskTest.h&quot;
-
-#include &quot;Document.h&quot;
-
-namespace WebCore {
-
-void MicroTaskTest::run()
-{
-    if (m_document)
-        m_document-&gt;addConsoleMessage(MessageSource::JS, MessageLevel::Debug, makeString(&quot;MicroTask #&quot;, String::number(m_testNumber), &quot; has run.&quot;));
-}
-
-} // namespace WebCore
</del></span></pre></div>
<a id="trunkSourceWebCoretestingMicroTaskTesth"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/testing/MicroTaskTest.h (193285 => 193286)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MicroTaskTest.h        2015-12-03 19:06:40 UTC (rev 193285)
+++ trunk/Source/WebCore/testing/MicroTaskTest.h        2015-12-03 19:06:45 UTC (rev 193286)
</span><span class="lines">@@ -1,49 +0,0 @@
</span><del>-/*
- * Copyright (C) 2015 Akamai Technologies Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef MicroTaskTest_h
-#define MicroTaskTest_h
-
-#include &quot;MicroTask.h&quot;
-#include &lt;wtf/WeakPtr.h&gt;
-
-namespace WebCore {
-
-class Document;
-
-class MicroTaskTest : public MicroTask {
-public:
-    MicroTaskTest(WeakPtr&lt;Document&gt; document, int testNumber)
-        : m_document(document)
-        , m_testNumber(testNumber)
-    {
-    }
-
-    virtual void run() override;
-    WEBCORE_TESTSUPPORT_EXPORT static std::unique_ptr&lt;MicroTaskTest&gt; create(WeakPtr&lt;Document&gt;, int testNumber);
-
-private:
-    WeakPtr&lt;Document&gt; m_document;
-    int m_testNumber;
-};
-
-} // namespace WebCore
-
-#endif
</del></span></pre>
</div>
</div>

</body>
</html>