Title: [220064] branches/safari-604-branch

Diff

Modified: branches/safari-604-branch/Source/WebKit/ChangeLog (220063 => 220064)


--- branches/safari-604-branch/Source/WebKit/ChangeLog	2017-07-31 14:37:31 UTC (rev 220063)
+++ branches/safari-604-branch/Source/WebKit/ChangeLog	2017-07-31 14:37:34 UTC (rev 220064)
@@ -1,5 +1,25 @@
 2017-07-31  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r220033. rdar://problem/33619596
+
+    2017-07-28  Brady Eidson  <beid...@apple.com>
+
+            API tests that use URLSchemeHandler are failing.
+            https://bugs.webkit.org/show_bug.cgi?id=174950
+
+            Reviewed by Alex Christensen.
+
+            Make sure that in all cases where we remove the last task from the page->task map...
+            ...We also remove the map itself.
+
+            * UIProcess/WebURLSchemeHandler.cpp:
+            (WebKit::WebURLSchemeHandler::stopTask):
+            (WebKit::WebURLSchemeHandler::taskCompleted):
+            (WebKit::WebURLSchemeHandler::removeTaskFromPageMap):
+            * UIProcess/WebURLSchemeHandler.h:
+
+2017-07-31  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r220011. rdar://problem/33619596
 
     2017-07-28  Brady Eidson  <beid...@apple.com>

Modified: branches/safari-604-branch/Source/WebKit/UIProcess/WebURLSchemeHandler.cpp (220063 => 220064)


--- branches/safari-604-branch/Source/WebKit/UIProcess/WebURLSchemeHandler.cpp	2017-07-31 14:37:31 UTC (rev 220063)
+++ branches/safari-604-branch/Source/WebKit/UIProcess/WebURLSchemeHandler.cpp	2017-07-31 14:37:34 UTC (rev 220064)
@@ -80,17 +80,11 @@
     if (iterator == m_tasks.end())
         return;
 
-    auto pageIterator = m_tasksByPageIdentifier.find(page.pageID());
-    ASSERT(pageIterator != m_tasksByPageIdentifier.end());
-    ASSERT(pageIterator->value.contains(taskIdentifier));
-    pageIterator->value.remove(taskIdentifier);
-
     iterator->value->stop();
     platformStopTask(page, iterator->value);
 
+    removeTaskFromPageMap(page.pageID(), taskIdentifier);
     m_tasks.remove(iterator);
-    if (pageIterator->value.isEmpty())
-        m_tasksByPageIdentifier.remove(pageIterator);
 }
 
 void WebURLSchemeHandler::taskCompleted(WebURLSchemeTask& task)
@@ -97,11 +91,19 @@
 {
     auto takenTask = m_tasks.take(task.identifier());
     ASSERT_UNUSED(takenTask, takenTask->ptr() == &task);
+    removeTaskFromPageMap(task.pageID(), task.identifier());
 
-    ASSERT(m_tasksByPageIdentifier.get(task.pageID()).contains(task.identifier()));
-    m_tasksByPageIdentifier.get(task.pageID()).remove(task.identifier());
-
     platformTaskCompleted(task);
 }
 
+void WebURLSchemeHandler::removeTaskFromPageMap(uint64_t pageID, uint64_t taskID)
+{
+    auto iterator = m_tasksByPageIdentifier.find(pageID);
+    ASSERT(iterator != m_tasksByPageIdentifier.end());
+    ASSERT(iterator->value.contains(taskID));
+    iterator->value.remove(taskID);
+    if (iterator->value.isEmpty())
+        m_tasksByPageIdentifier.remove(iterator);
+}
+
 } // namespace WebKit

Modified: branches/safari-604-branch/Source/WebKit/UIProcess/WebURLSchemeHandler.h (220063 => 220064)


--- branches/safari-604-branch/Source/WebKit/UIProcess/WebURLSchemeHandler.h	2017-07-31 14:37:31 UTC (rev 220063)
+++ branches/safari-604-branch/Source/WebKit/UIProcess/WebURLSchemeHandler.h	2017-07-31 14:37:34 UTC (rev 220064)
@@ -59,6 +59,8 @@
     virtual void platformStopTask(WebPageProxy&, WebURLSchemeTask&) = 0;
     virtual void platformTaskCompleted(WebURLSchemeTask&) = 0;
 
+    void removeTaskFromPageMap(uint64_t pageID, uint64_t taskID);
+
     uint64_t m_identifier;
 
     HashMap<uint64_t, Ref<WebURLSchemeTask>> m_tasks;

Modified: branches/safari-604-branch/Tools/ChangeLog (220063 => 220064)


--- branches/safari-604-branch/Tools/ChangeLog	2017-07-31 14:37:31 UTC (rev 220063)
+++ branches/safari-604-branch/Tools/ChangeLog	2017-07-31 14:37:34 UTC (rev 220064)
@@ -1,3 +1,21 @@
+2017-07-31  Jason Marcell  <jmarc...@apple.com>
+
+        Cherry-pick r220033. rdar://problem/33619596
+
+    2017-07-28  Brady Eidson  <beid...@apple.com>
+
+            API tests that use URLSchemeHandler are failing.
+            https://bugs.webkit.org/show_bug.cgi?id=174950
+
+            Reviewed by Alex Christensen.
+
+            Fix the NoMIMEType test to be correct.
+
+            * TestWebKitAPI/Tests/WebKit2Cocoa/WKURLSchemeHandler-1.mm:
+            (-[SchemeHandler initWithData:mimeType:]):
+            (-[SchemeHandler webView:startURLSchemeTask:]):
+            (TEST):
+
 2017-07-28  Jason Marcell  <jmarc...@apple.com>
 
         Cherry-pick r219904. rdar://problem/33595576

Modified: branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKURLSchemeHandler-1.mm (220063 => 220064)


--- branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKURLSchemeHandler-1.mm	2017-07-31 14:37:31 UTC (rev 220063)
+++ branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKURLSchemeHandler-1.mm	2017-07-31 14:37:34 UTC (rev 220064)
@@ -41,6 +41,7 @@
 @interface SchemeHandler : NSObject <WKURLSchemeHandler>
 @property (readonly) NSMutableArray<NSURL *> *startedURLs;
 @property (readonly) NSMutableArray<NSURL *> *stoppedURLs;
+@property (assign) BOOL shouldFinish;
 - (instancetype)initWithData:(NSData *)data mimeType:(NSString *)inMIMEType;
 @end
 
@@ -59,6 +60,7 @@
     mimeType = inMIMEType;
     _startedURLs = [[NSMutableArray alloc] init];
     _stoppedURLs = [[NSMutableArray alloc] init];
+    _shouldFinish = YES;
 
     return self;
 }
@@ -84,7 +86,8 @@
     RetainPtr<NSURLResponse> response = adoptNS([[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:mimeType.get() expectedContentLength:1 textEncodingName:nil]);
     [task didReceiveResponse:response.get()];
     [task didReceiveData:resourceData.get()];
-    [task didFinish];
+    if (_shouldFinish)
+        [task didFinish];
 }
 
 - (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)task
@@ -133,6 +136,7 @@
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
 
     RetainPtr<SchemeHandler> handler = adoptNS([[SchemeHandler alloc] initWithData:[NSData dataWithBytesNoCopy:(void*)mainBytes length:sizeof(mainBytes) freeWhenDone:NO] mimeType:nil]);
+    handler.get().shouldFinish = NO;
     [configuration setURLSchemeHandler:handler.get() forURLScheme:@"testing"];
 
     RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to