<!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>[202772] 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/202772">202772</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2016-07-01 19:53:11 -0700 (Fri, 01 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION(<a href="http://trac.webkit.org/projects/webkit/changeset/189668">r189668</a>): Notification tests are flakey
https://bugs.webkit.org/show_bug.cgi?id=159375
&lt;rdar://problem/22760990&gt;

Reviewed by Alexey Proskuryakov.

Source/WebKit2:

Implement WKNotificationManagerGetLocalID(). For more information, see the entry in Tools/ChangeLog.

* UIProcess/API/C/WKNotificationManager.cpp:
(WKNotificationManagerGetLocalID):
* UIProcess/Notifications/WebNotificationManagerProxy.cpp:
(WebKit::WebNotificationManagerProxy::notificationLocalIDForTesting):
* UIProcess/Notifications/WebNotificationManagerProxy.h:
* WebKit2.xcodeproj/project.pbxproj:

Tools:

Notifications are objects which must exist in both the UI Process and the Web Process. Each process
identifies a notification object by a unique ID. When the Web Process sends a message regarding a
notification to the UI Process, the UI Process's WebNotificationManagerProxy holds a map from
(Page ID, Web Process notification ID) -&gt; UI Process notification ID. This works as intended.

Our tests, however, include an additional method, simulateWebNotificationClick(), which is implemented
by WebKitTestRunner in the Web Process via the Injected Bundle. This method involves sending a message
to the UI process, to handle the simulated click. However, that RPC didn't perform the same local -&gt;
global notification ID mapping, causing the wrong notification to be investigated.

The solution is for WebNotificationProvider, implemented in WebKitTestRunner in the UI Process, to
manually perform this same mapping. Luckily, this object already receives callbacks every time a
notification is created or destroyed. However, because this object is implemented outside WebKit,
it isn't privy to the internal Web Process ID used inside WebNotificationmanagerProxy. Therefore,
this patch adds a private testing function which returns this internal ID. Once given this intenal ID,
WebNotificationProvider can properly map between the different IDs.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::runTestingServerLoop):
(WTR::TestController::simulateWebNotificationClick):
* WebKitTestRunner/WebNotificationProvider.cpp:
(WTR::WebNotificationProvider::showWebNotification):
(WTR::removeGlobalIDFromIDMap):
(WTR::WebNotificationProvider::closeWebNotification):
(WTR::WebNotificationProvider::removeNotificationManager):
(WTR::WebNotificationProvider::simulateWebNotificationClick):
(WTR::WebNotificationProvider::reset):
* WebKitTestRunner/WebNotificationProvider.h:

LayoutTests:

* platform/mac/TestExpectations:
* platform/mac-wk2/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2TestExpectations">trunk/LayoutTests/platform/mac-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKNotificationManagercpp">trunk/Source/WebKit2/UIProcess/API/C/WKNotificationManager.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKNotificationManagerh">trunk/Source/WebKit2/UIProcess/API/C/WKNotificationManager.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessNotificationsWebNotificationManagerProxycpp">trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessNotificationsWebNotificationManagerProxyh">trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerWebNotificationProvidercpp">trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerWebNotificationProviderh">trunk/Tools/WebKitTestRunner/WebNotificationProvider.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/LayoutTests/ChangeLog        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-07-01  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        REGRESSION(r189668): Notification tests are flakey
+        https://bugs.webkit.org/show_bug.cgi?id=159375
+        &lt;rdar://problem/22760990&gt;
+
+        Reviewed by Alexey Proskuryakov.
+
+        * platform/mac/TestExpectations:
+        * platform/mac-wk2/TestExpectations:
+
</ins><span class="cx"> 2016-07-01  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r202766.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -1263,9 +1263,6 @@
</span><span class="cx"> # Marking test as flaky in El Capitan
</span><span class="cx"> webkit.org/b/149819 [ Debug ElCapitan+ ] compositing/video/video-poster.html [ Pass Crash ]
</span><span class="cx"> 
</span><del>-# Marking as flaky again, patch did not work
-webkit.org/b/149218 http/tests/notifications/events.html [ Pass Crash ]
-
</del><span class="cx"> # Flaky on Mac
</span><span class="cx"> webkit.org/b/148435 storage/domstorage/events/basic-body-attribute.html [ Pass Failure ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -276,8 +276,6 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/150241 webarchive/loading/object.html [ Pass Crash ] 
</span><span class="cx"> 
</span><del>-webkit.org/b/150736 http/tests/notifications/legacy/events.html [ Pass Crash ]
-
</del><span class="cx"> webkit.org/b/150942 animations/multiple-backgrounds.html [ Pass ImageOnlyFailure ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/151053 http/tests/security/cross-frame-access-put.html [ Pass Failure ]
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/Source/WebKit2/ChangeLog        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-07-01  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        REGRESSION(r189668): Notification tests are flakey
+        https://bugs.webkit.org/show_bug.cgi?id=159375
+        &lt;rdar://problem/22760990&gt;
+
+        Reviewed by Alexey Proskuryakov.
+
+        Implement WKNotificationManagerGetLocalID(). For more information, see the entry in Tools/ChangeLog.
+
+        * UIProcess/API/C/WKNotificationManager.cpp:
+        (WKNotificationManagerGetLocalID):
+        * UIProcess/Notifications/WebNotificationManagerProxy.cpp:
+        (WebKit::WebNotificationManagerProxy::notificationLocalIDForTesting):
+        * UIProcess/Notifications/WebNotificationManagerProxy.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2016-07-01  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r201405): Fullscreen video no longer enters low-power mode
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKNotificationManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKNotificationManager.cpp (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKNotificationManager.cpp        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKNotificationManager.cpp        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;WKNotificationManager.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;WKAPICast.h&quot;
</span><ins>+#include &quot;WebNotification.h&quot;
</ins><span class="cx"> #include &quot;WebNotificationManagerProxy.h&quot;
</span><span class="cx"> 
</span><span class="cx"> using namespace WebKit;
</span><span class="lines">@@ -65,3 +66,8 @@
</span><span class="cx"> {
</span><span class="cx">     toImpl(managerRef)-&gt;providerDidRemoveNotificationPolicies(toImpl(origins));
</span><span class="cx"> }
</span><ins>+
+uint64_t WKNotificationManagerGetLocalIDForTesting(WKNotificationManagerRef manager, WKNotificationRef notification)
+{
+    return toImpl(manager)-&gt;notificationLocalIDForTesting(toImpl(notification));
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKNotificationManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKNotificationManager.h (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKNotificationManager.h        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKNotificationManager.h        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> WK_EXPORT void WKNotificationManagerProviderDidCloseNotifications(WKNotificationManagerRef managerRef, WKArrayRef notificationIDs);
</span><span class="cx"> WK_EXPORT void WKNotificationManagerProviderDidUpdateNotificationPolicy(WKNotificationManagerRef managerRef, WKSecurityOriginRef origin, bool allowed);
</span><span class="cx"> WK_EXPORT void WKNotificationManagerProviderDidRemoveNotificationPolicies(WKNotificationManagerRef managerRef, WKArrayRef origins);
</span><ins>+WK_EXPORT uint64_t WKNotificationManagerGetLocalIDForTesting(WKNotificationManagerRef managerRef, WKNotificationRef notification);
</ins><span class="cx"> 
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessNotificationsWebNotificationManagerProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -256,4 +256,16 @@
</span><span class="cx">     processPool()-&gt;sendToAllProcesses(Messages::WebNotificationManager::DidRemoveNotificationDecisions(originStrings));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+uint64_t WebNotificationManagerProxy::notificationLocalIDForTesting(WebNotification* notification)
+{
+    if (!notification)
+        return 0;
+
+    auto it = m_globalNotificationMap.find(notification-&gt;notificationID());
+    if (it == m_globalNotificationMap.end())
+        return 0;
+
+    return it-&gt;value.second;
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessNotificationsWebNotificationManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -67,6 +67,8 @@
</span><span class="cx">     void providerDidUpdateNotificationPolicy(const API::SecurityOrigin*, bool allowed);
</span><span class="cx">     void providerDidRemoveNotificationPolicies(API::Array* origins);
</span><span class="cx"> 
</span><ins>+    uint64_t notificationLocalIDForTesting(WebNotification*);
+
</ins><span class="cx">     using API::Object::ref;
</span><span class="cx">     using API::Object::deref;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/Tools/ChangeLog        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2016-07-01  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        REGRESSION(r189668): Notification tests are flakey
+        https://bugs.webkit.org/show_bug.cgi?id=159375
+        &lt;rdar://problem/22760990&gt;
+
+        Reviewed by Alexey Proskuryakov.
+
+        Notifications are objects which must exist in both the UI Process and the Web Process. Each process
+        identifies a notification object by a unique ID. When the Web Process sends a message regarding a
+        notification to the UI Process, the UI Process's WebNotificationManagerProxy holds a map from
+        (Page ID, Web Process notification ID) -&gt; UI Process notification ID. This works as intended.
+
+        Our tests, however, include an additional method, simulateWebNotificationClick(), which is implemented
+        by WebKitTestRunner in the Web Process via the Injected Bundle. This method involves sending a message
+        to the UI process, to handle the simulated click. However, that RPC didn't perform the same local -&gt;
+        global notification ID mapping, causing the wrong notification to be investigated.
+
+        The solution is for WebNotificationProvider, implemented in WebKitTestRunner in the UI Process, to
+        manually perform this same mapping. Luckily, this object already receives callbacks every time a
+        notification is created or destroyed. However, because this object is implemented outside WebKit,
+        it isn't privy to the internal Web Process ID used inside WebNotificationmanagerProxy. Therefore,
+        this patch adds a private testing function which returns this internal ID. Once given this intenal ID,
+        WebNotificationProvider can properly map between the different IDs.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::runTestingServerLoop):
+        (WTR::TestController::simulateWebNotificationClick):
+        * WebKitTestRunner/WebNotificationProvider.cpp:
+        (WTR::WebNotificationProvider::showWebNotification):
+        (WTR::removeGlobalIDFromIDMap):
+        (WTR::WebNotificationProvider::closeWebNotification):
+        (WTR::WebNotificationProvider::removeNotificationManager):
+        (WTR::WebNotificationProvider::simulateWebNotificationClick):
+        (WTR::WebNotificationProvider::reset):
+        * WebKitTestRunner/WebNotificationProvider.h:
+
</ins><span class="cx"> 2016-07-01  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Simplify LayoutTestRelay
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -1746,7 +1746,7 @@
</span><span class="cx"> 
</span><span class="cx"> void TestController::simulateWebNotificationClick(uint64_t notificationID)
</span><span class="cx"> {
</span><del>-    m_webNotificationProvider.simulateWebNotificationClick(notificationID);
</del><ins>+    m_webNotificationProvider.simulateWebNotificationClick(mainWebView()-&gt;page(), notificationID);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TestController::setGeolocationPermission(bool enabled)
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerWebNotificationProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;WebKit/WKMutableArray.h&gt;
</span><span class="cx"> #include &lt;WebKit/WKNotification.h&gt;
</span><ins>+#include &lt;WebKit/WKNotificationManager.h&gt;
</ins><span class="cx"> #include &lt;WebKit/WKNumber.h&gt;
</span><span class="cx"> #include &lt;WebKit/WKSecurityOriginRef.h&gt;
</span><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span><span class="lines">@@ -95,10 +96,23 @@
</span><span class="cx">     ASSERT_UNUSED(addResult, addResult.isNewEntry);
</span><span class="cx">     auto addResult2 = m_owningManager.set(id, notificationManager);
</span><span class="cx">     ASSERT_UNUSED(addResult2, addResult2.isNewEntry);
</span><ins>+    auto addResult3 = m_localToGlobalNotificationIDMap.add(std::make_pair(page, WKNotificationManagerGetLocalIDForTesting(notificationManager, notification)), id);
+    ASSERT_UNUSED(addResult3, addResult3.isNewEntry);
</ins><span class="cx"> 
</span><span class="cx">     WKNotificationManagerProviderDidShowNotification(notificationManager, id);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void removeGlobalIDFromIDMap(HashMap&lt;std::pair&lt;WKPageRef, uint64_t&gt;, uint64_t&gt;&amp; map, uint64_t id)
+{
+    for (auto iter = map.begin(); iter != map.end(); ++iter) {
+        if (iter-&gt;value == id) {
+            map.remove(iter);
+            return;
+        }
+    }
+    ASSERT_NOT_REACHED();
+}
+
</ins><span class="cx"> void WebNotificationProvider::closeWebNotification(WKNotificationRef notification)
</span><span class="cx"> {
</span><span class="cx">     uint64_t id = WKNotificationGetID(notification);
</span><span class="lines">@@ -110,6 +124,8 @@
</span><span class="cx">     ASSERT_UNUSED(success, success);
</span><span class="cx">     m_owningManager.remove(id);
</span><span class="cx"> 
</span><ins>+    removeGlobalIDFromIDMap(m_localToGlobalNotificationIDMap, id);
+
</ins><span class="cx">     WKRetainPtr&lt;WKUInt64Ref&gt; wkID = WKUInt64Create(id);
</span><span class="cx">     WKRetainPtr&lt;WKMutableArrayRef&gt; array(AdoptWK, WKMutableArrayCreate());
</span><span class="cx">     WKArrayAppendItem(array.get(), wkID.get());
</span><span class="lines">@@ -132,6 +148,7 @@
</span><span class="cx">     for (uint64_t notificationID : toRemove) {
</span><span class="cx">         bool success = m_owningManager.remove(notificationID);
</span><span class="cx">         ASSERT_UNUSED(success, success);
</span><ins>+        removeGlobalIDFromIDMap(m_localToGlobalNotificationIDMap, notificationID);
</ins><span class="cx">         WKArrayAppendItem(array.get(), adoptWK(WKUInt64Create(notificationID)).get());
</span><span class="cx">     }
</span><span class="cx">     WKNotificationManagerProviderDidCloseNotifications(manager, array.get());
</span><span class="lines">@@ -143,10 +160,12 @@
</span><span class="cx">     return WKMutableDictionaryCreate();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebNotificationProvider::simulateWebNotificationClick(uint64_t notificationID)
</del><ins>+void WebNotificationProvider::simulateWebNotificationClick(WKPageRef page, uint64_t notificationID)
</ins><span class="cx"> {
</span><del>-    ASSERT(m_owningManager.contains(notificationID));
-    WKNotificationManagerProviderDidClickNotification(m_owningManager.get(notificationID), notificationID);
</del><ins>+    ASSERT(m_localToGlobalNotificationIDMap.contains(std::make_pair(page, notificationID)));
+    auto globalID = m_localToGlobalNotificationIDMap.get(std::make_pair(page, notificationID));
+    ASSERT(m_owningManager.contains(globalID));
+    WKNotificationManagerProviderDidClickNotification(m_owningManager.get(globalID), globalID);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebNotificationProvider::reset()
</span><span class="lines">@@ -162,6 +181,7 @@
</span><span class="cx">         WKNotificationManagerProviderDidCloseNotifications(notificationPair.key.get(), array.get());
</span><span class="cx">     }
</span><span class="cx">     m_owningManager.clear();
</span><ins>+    m_localToGlobalNotificationIDMap.clear();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WTR
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerWebNotificationProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/WebNotificationProvider.h (202771 => 202772)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/WebNotificationProvider.h        2016-07-02 02:32:39 UTC (rev 202771)
+++ trunk/Tools/WebKitTestRunner/WebNotificationProvider.h        2016-07-02 02:53:11 UTC (rev 202772)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">     void removeNotificationManager(WKNotificationManagerRef);
</span><span class="cx">     WKDictionaryRef notificationPermissions();
</span><span class="cx"> 
</span><del>-    void simulateWebNotificationClick(uint64_t notificationID);
</del><ins>+    void simulateWebNotificationClick(WKPageRef, uint64_t notificationID);
</ins><span class="cx">     void reset();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="lines">@@ -53,6 +53,8 @@
</span><span class="cx">     // Inverses of each other.
</span><span class="cx">     HashMap&lt;WKRetainPtr&lt;WKNotificationManagerRef&gt;, HashSet&lt;uint64_t&gt;&gt; m_ownedNotifications;
</span><span class="cx">     HashMap&lt;uint64_t, WKNotificationManagerRef&gt; m_owningManager;
</span><ins>+
+    HashMap&lt;std::pair&lt;WKPageRef, uint64_t&gt;, uint64_t&gt; m_localToGlobalNotificationIDMap;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>