Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,5 @@ Then, you find `WebDriverAgentRunner-Runner-sim-<version>.zip` for iOS and `Web

[`WebDriverAgent` is BSD-licensed](LICENSE).

## Third Party Sources

WebDriverAgent depends on the following third-party frameworks:
- [CocoaHTTPServer](https://github.com/robbiehanson/CocoaHTTPServer)
- [RoutingHTTPServer](https://github.com/mattstevens/RoutingHTTPServer)

These projects haven't been maintained in a while. That's why the source code of these
projects has been integrated directly in the WebDriverAgent source tree.

You can find the source files and their licenses in the `WebDriverAgentLib/Vendor` directory.

Have fun!
4 changes: 2 additions & 2 deletions WebDriverAgentLib/Commands/FBScreenshotCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ + (NSArray *)routes
{
return
@[
[[FBRoute GET:@"/screenshot"].withoutSession respondWithTarget:self action:@selector(handleGetScreenshot:)],
[[FBRoute GET:@"/screenshot"] respondWithTarget:self action:@selector(handleGetScreenshot:)],
[[FBRoute GET:@"/screenshot"].withoutSession.standalone respondWithTarget:self action:@selector(handleGetScreenshot:)],
[[FBRoute GET:@"/screenshot"].standalone respondWithTarget:self action:@selector(handleGetScreenshot:)],
];
}

Expand Down
8 changes: 3 additions & 5 deletions WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ + (NSArray *)routes
[[FBRoute POST:@"/wda/apps/state"] respondWithTarget:self action:@selector(handleSessionAppState:)],
[[FBRoute GET:@"/wda/apps/list"] respondWithTarget:self action:@selector(handleGetActiveAppsList:)],
[[FBRoute GET:@""] respondWithTarget:self action:@selector(handleGetActiveSession:)],
[[FBRoute DELETE:@""] respondWithTarget:self action:@selector(handleDeleteSession:)],
[[FBRoute GET:@"/status"].withoutSession respondWithTarget:self action:@selector(handleGetStatus:)],
[[FBRoute DELETE:@""].standalone respondWithTarget:self action:@selector(handleDeleteSession:)],
[[FBRoute GET:@"/status"].withoutSession.standalone respondWithTarget:self action:@selector(handleGetStatus:)],

// Health check might modify simulator state so it should only be called in-between testing sessions
[[FBRoute GET:@"/wda/healthcheck"].withoutSession respondWithTarget:self action:@selector(handleGetHealthCheck:)],
Expand Down Expand Up @@ -89,9 +89,7 @@ + (NSArray *)routes

+ (id<FBResponsePayload>)handleCreateSession:(FBRouteRequest *)request
{
if (nil != FBSession.activeSession) {
[FBSession.activeSession kill];
}
[FBSession killActiveSessionAndWaitForTeardown];

NSDictionary<NSString *, id> *capabilities;
id<FBResponsePayload> errorResponse = [self capabilitiesFromCreateSessionRequest:request
Expand Down
26 changes: 25 additions & 1 deletion WebDriverAgentLib/Routing/FBHTTPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,41 @@ NS_ASSUME_NONNULL_BEGIN

/**
Registers a route handler for the given HTTP method and path pattern (":param" segments are
captured into the request's `params`).
captured into the request's `params`). Equivalent to -handleMethod:withPath:standalone:block:
with standalone:NO.
*/
- (void)handleMethod:(NSString *)method
withPath:(NSString *)path
block:(void (^)(RouteRequest *request, RouteResponse *response))block;

/**
Registers a route handler that, when `standalone` is YES, bypasses -routeQueue entirely so a
handler stuck on that queue can never block it. Concurrent requests to the same method+path are
coalesced into a single in-flight execution, whose response is delivered to all of them; anything
else runs on its own queue, so distinct standalone endpoints always execute in parallel with each
other and with whatever is stuck on -routeQueue.
*/
- (void)handleMethod:(NSString *)method
withPath:(NSString *)path
standalone:(BOOL)standalone
block:(void (^)(RouteRequest *request, RouteResponse *response))block;

/**
Convenience for -handleMethod:@"GET" withPath:path block:block.
*/
- (void)get:(NSString *)path withBlock:(void (^)(RouteRequest *request, RouteResponse *response))block;

/**
Immediately sends `response` to every non-standalone request currently pending for the given
"sessionID" path param - whether still queued on -routeQueue or already executing - instead of
leaving their HTTP clients waiting on a session that no longer exists. A request that has already
started executing keeps running to completion in the background regardless (GCD gives no way to
abort a block once it starts), but its eventual result is discarded rather than ever reaching a
client. `response` is written as-is to every pending client, so the caller is expected to supply
a fully-populated, protocol-correct error response (e.g. a W3C-shaped JSON body).
*/
- (void)abandonPendingRequestsForSessionID:(NSString *)sessionID withResponse:(RouteResponse *)response;

/**
Starts listening on `port`.
*/
Expand Down
Loading
Loading