Changeset 225970 in webkit
- Timestamp:
- Dec 15, 2017, 5:14:36 AM (8 years ago)
- Location:
- trunk/Source/WebDriver
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebDriver/Capabilities.h
r224913 r225970 48 48 Dismiss, 49 49 Accept, 50 DismissAndNotify, 51 AcceptAndNotify, 50 52 Ignore 51 53 }; -
trunk/Source/WebDriver/ChangeLog
r225739 r225970 1 2017-12-15 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 WebDriver: add support for accept/dismiss and notify unhandled prompt behavior 4 https://bugs.webkit.org/show_bug.cgi?id=179999 5 6 Reviewed by Carlos Alberto Lopez Perez. 7 8 They work as accept and dismiss, but unexpected alert open is still reported. 9 10 18. User Prompts 11 https://w3c.github.io/webdriver/webdriver-spec.html#dfn-known-prompt-handling-approaches-table 12 13 * Capabilities.h: Add DismissAndNotify and AcceptAndNotify to UnhandledPromptBehavior enum. 14 * Session.cpp: 15 (WebDriver::Session::handleUnexpectedAlertOpen): Move default implementation to dismissAndNotifyAlert and 16 acceptAndNotifyAlert and use dismissAndNotifyAlert by default. 17 (WebDriver::Session::dismissAndNotifyAlert): 18 (WebDriver::Session::acceptAndNotifyAlert): 19 * Session.h: 20 * WebDriverService.cpp: 21 (WebDriver::deserializeUnhandledPromptBehavior): Handle accept/dismiss and notify. 22 (WebDriver::WebDriverService::newSession): Ditto. 23 1 24 2017-12-11 Carlos Garcia Campos <cgarcia@igalia.com> 2 25 -
trunk/Source/WebDriver/Session.cpp
r225739 r225970 191 191 void Session::handleUnexpectedAlertOpen(Function<void (CommandResult&&)>&& completionHandler) 192 192 { 193 if (!capabilities().unhandledPromptBehavior) { 194 reportUnexpectedAlertOpen([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable { 195 dismissAlert([this, errorResult = WTFMove(result), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable { 196 if (result.isError()) { 197 completionHandler(WTFMove(result)); 198 return; 199 } 200 completionHandler(WTFMove(errorResult)); 201 }); 202 }); 203 return; 204 } 205 206 switch (capabilities().unhandledPromptBehavior.value()) { 193 switch (capabilities().unhandledPromptBehavior.value_or(UnhandledPromptBehavior::DismissAndNotify)) { 207 194 case UnhandledPromptBehavior::Dismiss: 208 195 dismissAlert(WTFMove(completionHandler)); … … 211 198 acceptAlert(WTFMove(completionHandler)); 212 199 break; 200 case UnhandledPromptBehavior::DismissAndNotify: 201 dismissAndNotifyAlert(WTFMove(completionHandler)); 202 break; 203 case UnhandledPromptBehavior::AcceptAndNotify: 204 acceptAndNotifyAlert(WTFMove(completionHandler)); 205 break; 213 206 case UnhandledPromptBehavior::Ignore: 214 207 reportUnexpectedAlertOpen(WTFMove(completionHandler)); 215 208 break; 216 209 } 210 } 211 212 void Session::dismissAndNotifyAlert(Function<void (CommandResult&&)>&& completionHandler) 213 { 214 reportUnexpectedAlertOpen([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable { 215 dismissAlert([this, errorResult = WTFMove(result), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable { 216 if (result.isError()) { 217 completionHandler(WTFMove(result)); 218 return; 219 } 220 completionHandler(WTFMove(errorResult)); 221 }); 222 }); 223 } 224 225 void Session::acceptAndNotifyAlert(Function<void (CommandResult&&)>&& completionHandler) 226 { 227 reportUnexpectedAlertOpen([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable { 228 acceptAlert([this, errorResult = WTFMove(result), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable { 229 if (result.isError()) { 230 completionHandler(WTFMove(result)); 231 return; 232 } 233 completionHandler(WTFMove(errorResult)); 234 }); 235 }); 217 236 } 218 237 -
trunk/Source/WebDriver/Session.h
r225474 r225970 125 125 void handleUserPrompts(Function<void (CommandResult&&)>&&); 126 126 void handleUnexpectedAlertOpen(Function<void (CommandResult&&)>&&); 127 void dismissAndNotifyAlert(Function<void (CommandResult&&)>&&); 128 void acceptAndNotifyAlert(Function<void (CommandResult&&)>&&); 127 129 void reportUnexpectedAlertOpen(Function<void (CommandResult&&)>&&); 128 130 -
trunk/Source/WebDriver/WebDriverService.cpp
r225474 r225970 314 314 if (unhandledPromptBehavior == "accept") 315 315 return UnhandledPromptBehavior::Accept; 316 if (unhandledPromptBehavior == "dismiss and notify") 317 return UnhandledPromptBehavior::DismissAndNotify; 318 if (unhandledPromptBehavior == "accept and notify") 319 return UnhandledPromptBehavior::AcceptAndNotify; 316 320 if (unhandledPromptBehavior == "ignore") 317 321 return UnhandledPromptBehavior::Ignore; … … 652 656 capabilitiesObject->setString(ASCIILiteral("unhandledPromptBehavior"), "accept"); 653 657 break; 658 case UnhandledPromptBehavior::DismissAndNotify: 659 capabilitiesObject->setString(ASCIILiteral("unhandledPromptBehavior"), "dismiss and notify"); 660 break; 661 case UnhandledPromptBehavior::AcceptAndNotify: 662 capabilitiesObject->setString(ASCIILiteral("unhandledPromptBehavior"), "accept and notify"); 663 break; 654 664 case UnhandledPromptBehavior::Ignore: 655 665 capabilitiesObject->setString(ASCIILiteral("unhandledPromptBehavior"), "ignore");
Note:
See TracChangeset
for help on using the changeset viewer.