Changeset 190593 in webkit
- Timestamp:
- Oct 5, 2015 4:45:56 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r190592 r190593 1 2015-10-05 Myles C. Maxfield <mmaxfield@apple.com> 2 3 REGRESSION(189668?): http/tests/notifications/events.html flakily asserts or times out 4 https://bugs.webkit.org/show_bug.cgi?id=149218 5 6 Reviewed by Alexey Proskuryakov. 7 8 * TestExpectations: 9 1 10 2015-10-05 Dean Jackson <dino@apple.com> 2 11 -
trunk/LayoutTests/TestExpectations
r190518 r190593 677 677 678 678 http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overrides.html [ Failure Pass ] 679 680 webkit.org/b/149218 http/tests/notifications/events.html [ Pass Crash Timeout ] -
trunk/Tools/ChangeLog
r190584 r190593 1 2015-10-05 Myles C. Maxfield <mmaxfield@apple.com> 2 3 REGRESSION(189668?): http/tests/notifications/events.html flakily asserts or times out 4 https://bugs.webkit.org/show_bug.cgi?id=149218 5 6 Reviewed by Alexey Proskuryakov. 7 8 Because of r189668, WebKitTestRunner now tears down and recreates its WKNotificationManagerRef 9 when the TestOptions change. Previously, WebNotificationProvider only could handle a single 10 WKNotificationManagerRef. Because the ower of the WKNotificationManagerRef is reference counted, 11 and AppKit internally retains some objects which end up retaining the WKNotificationManagerRef, 12 the old WKNotificationManager may not be destroyed before the new one is created. Therefore, 13 WebNotificationProvider must be updated to appropriately handle multiple 14 WKNotificationManagerRefs in flight at the same time. 15 16 * WebKitTestRunner/WebNotificationProvider.cpp: 17 (WTR::WebNotificationProvider::~WebNotificationProvider): 18 (WTR::WebNotificationProvider::showWebNotification): 19 (WTR::WebNotificationProvider::closeWebNotification): 20 (WTR::WebNotificationProvider::addNotificationManager): 21 (WTR::WebNotificationProvider::removeNotificationManager): 22 (WTR::WebNotificationProvider::simulateWebNotificationClick): 23 (WTR::WebNotificationProvider::reset): 24 * WebKitTestRunner/WebNotificationProvider.h: 25 1 26 2015-10-05 Daniel Bates <dabates@apple.com> 2 27 -
trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp
r189668 r190593 66 66 WebNotificationProvider::~WebNotificationProvider() 67 67 { 68 if (m_currentNotificationManager)69 WKNotificationManagerSetProvider(m _currentNotificationManager.get(), nullptr);68 for (auto& manager : m_ownedNotifications) 69 WKNotificationManagerSetProvider(manager.key.get(), nullptr); 70 70 } 71 71 … … 85 85 } 86 86 87 void WebNotificationProvider::showWebNotification(WKPageRef , WKNotificationRef notification)87 void WebNotificationProvider::showWebNotification(WKPageRef page, WKNotificationRef notification) 88 88 { 89 if (!m_currentNotificationManager) 90 return; 89 auto context = WKPageGetContext(page); 90 auto notificationManager = WKContextGetNotificationManager(context); 91 uint64_t id = WKNotificationGetID(notification); 91 92 92 uint64_t id = WKNotificationGetID(notification); 93 ASSERT(!m_shownNotifications.contains(id)); 94 m_shownNotifications.add(id); 93 ASSERT(m_ownedNotifications.contains(notificationManager)); 94 auto addResult = m_ownedNotifications.find(notificationManager)->value.add(id); 95 ASSERT_UNUSED(addResult, addResult.isNewEntry); 96 auto addResult2 = m_owningManager.set(id, notificationManager); 97 ASSERT_UNUSED(addResult2, addResult2.isNewEntry); 95 98 96 WKNotificationManagerProviderDidShowNotification( m_currentNotificationManager.get(), WKNotificationGetID(notification));99 WKNotificationManagerProviderDidShowNotification(notificationManager, id); 97 100 } 98 101 99 102 void WebNotificationProvider::closeWebNotification(WKNotificationRef notification) 100 103 { 101 if (!m_currentNotificationManager) 102 return; 104 uint64_t id = WKNotificationGetID(notification); 105 ASSERT(m_owningManager.contains(id)); 106 auto notificationManager = m_owningManager.get(id); 103 107 104 uint64_t id = WKNotificationGetID(notification); 108 ASSERT(m_ownedNotifications.contains(notificationManager)); 109 bool success = m_ownedNotifications.find(notificationManager)->value.remove(id); 110 ASSERT_UNUSED(success, success); 111 m_owningManager.remove(id); 112 105 113 WKRetainPtr<WKUInt64Ref> wkID = WKUInt64Create(id); 106 114 WKRetainPtr<WKMutableArrayRef> array(AdoptWK, WKMutableArrayCreate()); 107 115 WKArrayAppendItem(array.get(), wkID.get()); 108 m_shownNotifications.remove(id); 109 WKNotificationManagerProviderDidCloseNotifications(m_currentNotificationManager.get(), array.get()); 116 WKNotificationManagerProviderDidCloseNotifications(notificationManager, array.get()); 110 117 } 111 118 112 119 void WebNotificationProvider::addNotificationManager(WKNotificationManagerRef manager) 113 120 { 114 m_ currentNotificationManager = manager;121 m_ownedNotifications.add(manager, HashSet<uint64_t>()); 115 122 } 116 123 117 124 void WebNotificationProvider::removeNotificationManager(WKNotificationManagerRef manager) 118 125 { 126 auto iterator = m_ownedNotifications.find(manager); 127 ASSERT(iterator != m_ownedNotifications.end()); 128 auto toRemove = iterator->value; 129 WKRetainPtr<WKNotificationManagerRef> guard(manager); 130 m_ownedNotifications.remove(iterator); 131 WKRetainPtr<WKMutableArrayRef> array = adoptWK(WKMutableArrayCreate()); 132 for (uint64_t notificationID : toRemove) { 133 bool success = m_owningManager.remove(notificationID); 134 ASSERT_UNUSED(success, success); 135 WKArrayAppendItem(array.get(), adoptWK(WKUInt64Create(notificationID)).get()); 136 } 137 WKNotificationManagerProviderDidCloseNotifications(manager, array.get()); 119 138 } 120 139 … … 127 146 void WebNotificationProvider::simulateWebNotificationClick(uint64_t notificationID) 128 147 { 129 if (!m_currentNotificationManager) 130 return; 131 132 ASSERT(m_shownNotifications.contains(notificationID)); 133 WKNotificationManagerProviderDidClickNotification(m_currentNotificationManager.get(), notificationID); 148 ASSERT(m_owningManager.contains(notificationID)); 149 WKNotificationManagerProviderDidClickNotification(m_owningManager.get(notificationID), notificationID); 134 150 } 135 151 136 152 void WebNotificationProvider::reset() 137 153 { 138 if (!m_currentNotificationManager) { 139 m_shownNotifications.clear(); 140 return; 154 for (auto& notificationPair : m_ownedNotifications) { 155 if (notificationPair.value.isEmpty()) 156 continue; 157 WKRetainPtr<WKMutableArrayRef> array = adoptWK(WKMutableArrayCreate()); 158 for (uint64_t notificationID : notificationPair.value) 159 WKArrayAppendItem(array.get(), adoptWK(WKUInt64Create(notificationID)).get()); 160 161 notificationPair.value.clear(); 162 WKNotificationManagerProviderDidCloseNotifications(notificationPair.key.get(), array.get()); 141 163 } 142 143 WKRetainPtr<WKMutableArrayRef> array(AdoptWK, WKMutableArrayCreate()); 144 HashSet<uint64_t>::const_iterator itEnd = m_shownNotifications.end(); 145 for (HashSet<uint64_t>::const_iterator it = m_shownNotifications.begin(); it != itEnd; ++it) { 146 WKRetainPtr<WKUInt64Ref> wkID = WKUInt64Create(*it); 147 WKArrayAppendItem(array.get(), wkID.get()); 148 } 149 150 m_shownNotifications.clear(); 151 WKNotificationManagerProviderDidCloseNotifications(m_currentNotificationManager.get(), array.get()); 164 m_owningManager.clear(); 152 165 } 153 166 -
trunk/Tools/WebKitTestRunner/WebNotificationProvider.h
r189668 r190593 30 30 #include <WebKit/WKNotificationProvider.h> 31 31 #include <WebKit/WKRetainPtr.h> 32 #include <wtf/HashMap.h> 32 33 #include <wtf/HashSet.h> 33 34 … … 50 51 51 52 private: 52 WKRetainPtr<WKNotificationManagerRef> m_currentNotificationManager; 53 HashSet<uint64_t> m_shownNotifications; 53 // Inverses of each other. 54 HashMap<WKRetainPtr<WKNotificationManagerRef>, HashSet<uint64_t>> m_ownedNotifications; 55 HashMap<uint64_t, WKNotificationManagerRef> m_owningManager; 54 56 }; 55 57
Note: See TracChangeset
for help on using the changeset viewer.