Changeset 254367 in webkit
- Timestamp:
- Jan 10, 2020 2:38:30 PM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r254359 r254367 1 2020-01-10 Alex Christensen <achristensen@webkit.org> 2 3 Fix test assertions after r254345 4 https://bugs.webkit.org/show_bug.cgi?id=206037 5 6 There were two assertions being hit in the new tests: 7 1. Beacon sends POST requests, so the HTTP server that receives them needs to be able to handle POST requests. 8 2. There was an assertion in the destructor of NetworkResourceLoader because we were destroying a WKWebView during a sync xhr. 9 This isn't a problem in practice, but we may as well wait for the sync xhr to finish before completing the test so we can 10 keep the sync xhr assertion, which is useful to prevent hangs. 11 12 * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm: 13 (-[TestUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 14 (TEST): 15 * TestWebKitAPI/cocoa/HTTPServer.mm: 16 (TestWebKitAPI::HTTPServer::respondToRequests): 17 1 18 2020-01-10 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 19 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm
r254357 r254367 81 81 @end 82 82 83 @interface TestUIDelegate : NSObject <WKUIDelegate> 84 85 @property (nonatomic, copy) void (^runJavaScriptAlertPanelWithMessage)(WKWebView *, NSString *, WKFrameInfo *, void (^)(void)); 86 87 @end 88 89 @implementation TestUIDelegate 90 91 - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler 92 { 93 if (_runJavaScriptAlertPanelWithMessage) 94 _runJavaScriptAlertPanelWithMessage(webView, message, frame, completionHandler); 95 else 96 completionHandler(); 97 } 98 99 @end 100 83 101 TEST(ResourceLoadDelegate, Basic) 84 102 { … … 127 145 receivedCallback = true; 128 146 }]; 147 148 __block bool receivedAlert = false; 149 auto uiDelegate = adoptNS([TestUIDelegate new]); 150 [webView setUIDelegate:uiDelegate.get()]; 151 [uiDelegate setRunJavaScriptAlertPanelWithMessage:^(WKWebView *, NSString *, WKFrameInfo *, void (^completionHandler)(void)) { 152 receivedAlert = true; 153 completionHandler(); 154 }]; 129 155 130 156 [webView evaluateJavaScript:@"navigator.sendBeacon('/beaconTarget')" completionHandler:nil]; … … 137 163 "var asynchronous = false;" 138 164 "request.open('GET', 'xhrTarget', asynchronous);" 139 "request.send();" completionHandler:nil]; 165 "request.send();" 166 "alert('done');" completionHandler:nil]; 140 167 TestWebKitAPI::Util::run(&receivedCallback); 141 168 EXPECT_WK_STREQ("/xhrTarget", requestFromDelegate.get().URL.path); 169 TestWebKitAPI::Util::run(&receivedAlert); 142 170 } 143 171 -
trunk/Tools/TestWebKitAPI/cocoa/HTTPServer.mm
r254345 r254367 77 77 request.append(0); 78 78 79 const char* pathPrefix = "GET "; 79 const char* getPathPrefix = "GET "; 80 const char* postPathPrefix = "POST "; 80 81 const char* pathSuffix = " HTTP/1.1\r\n"; 81 82 const char* pathEnd = strstr(request.data(), pathSuffix); 82 83 ASSERT_WITH_MESSAGE(pathEnd, "HTTPServer assumes request is HTTP 1.1"); 83 ASSERT_WITH_MESSAGE(!memcmp(request.data(), pathPrefix, strlen(pathPrefix)), "HTTPServer assumes request is GET");84 84 ASSERT_WITH_MESSAGE(strstr(request.data(), "\r\n\r\n"), "HTTPServer assumes entire HTTP request is received at once"); 85 size_t pathLength = pathEnd - request.data() - strlen(pathPrefix); 86 String path(request.data() + strlen(pathPrefix), pathLength); 85 size_t pathPrefixLength = 0; 86 if (!memcmp(request.data(), getPathPrefix, strlen(getPathPrefix))) 87 pathPrefixLength = strlen(getPathPrefix); 88 else if (!memcmp(request.data(), postPathPrefix, strlen(postPathPrefix))) 89 pathPrefixLength = strlen(postPathPrefix); 90 ASSERT_WITH_MESSAGE(pathPrefixLength, "HTTPServer assumes request is GET or POST"); 91 size_t pathLength = pathEnd - request.data() - pathPrefixLength; 92 String path(request.data() + pathPrefixLength, pathLength); 87 93 ASSERT_WITH_MESSAGE(m_requestResponseMap.contains(path), "This HTTPServer does not know how to respond to a request for %s", path.utf8().data()); 88 94
Note: See TracChangeset
for help on using the changeset viewer.