Skip to content

Commit

Permalink
Merge pull request #11 from VKCOM/malzhanov/migrate-to-esm
Browse files Browse the repository at this point in the history
Migrate to ESM
  • Loading branch information
irdkwmnsb authored Oct 11, 2024
2 parents a677de4 + 32a7d33 commit 04e5bb6
Show file tree
Hide file tree
Showing 315 changed files with 24,405 additions and 25,196 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/res/build/**
/res/app/components/stf/screen/fast-image-render/pixi.js
WebDriverAgent
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"node": true
},
"parserOptions": {
"ecmaVersion": 2020
"ecmaVersion": 2020,
"sourceType": "module"
},
"rules": {
// Possible errors
Expand Down Expand Up @@ -103,7 +104,6 @@
"key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "strict"}], // optionally set `[2, {"beforeColon": false, "afterColon": true, "mode": "strict", "align": "colon"}]`
"lines-around-comment": 2, // optionally set `[2, {"beforeBlockComment": true, "beforeLineComment": true, "allowBlockStart": true}]`
"linebreak-style": 0, // optionally set `[1, "unix"]`
"max-len": [2, 150, 2, {"ignoreComments": true, "ignoreUrls": true}], // NOTE: Our limit is 80 however ESLint does not have an ignoreStrings so lets have more buffer
"max-nested-callbacks": [1, 5],
"new-cap": 2, // optionally set `[2, {"capIsNewExceptions": ["Person"]}]`
"new-parens": 2,
Expand Down
76 changes: 76 additions & 0 deletions WebDriverAgent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,79 @@
## [8.9.2](https://github.com/appium/WebDriverAgent/compare/v8.9.1...v8.9.2) (2024-09-13)

### Miscellaneous Chores

* **deps-dev:** bump sinon from 18.0.1 to 19.0.1 ([#938](https://github.com/appium/WebDriverAgent/issues/938)) ([3ef0093](https://github.com/appium/WebDriverAgent/commit/3ef009317801dca47efe34bd048d3cab2e644ee2))

## [8.9.1](https://github.com/appium/WebDriverAgent/compare/v8.9.0...v8.9.1) (2024-08-09)

### Bug Fixes

* Update swizzling of waitForQuiescenceIncludingAnimationsIdle: API for Xcode16-beta5 ([#935](https://github.com/appium/WebDriverAgent/issues/935)) ([2ccc436](https://github.com/appium/WebDriverAgent/commit/2ccc436991ca880a1dfdec688dc8167008fe382d))

## [8.9.0](https://github.com/appium/WebDriverAgent/compare/v8.8.0...v8.9.0) (2024-08-07)

### Features

* Add idleTimeoutMs param to the openUrl call ([#933](https://github.com/appium/WebDriverAgent/issues/933)) ([5e98841](https://github.com/appium/WebDriverAgent/commit/5e98841f56eda6454d67d813b921bfcf98f1ff78))

### Bug Fixes

* Revert the logic to open the default URL in Safari via deeplink ([#932](https://github.com/appium/WebDriverAgent/issues/932)) ([7c51145](https://github.com/appium/WebDriverAgent/commit/7c5114518509c9a399845283eca7708248fb838f))

## [8.8.0](https://github.com/appium/WebDriverAgent/compare/v8.7.12...v8.8.0) (2024-08-06)

### Features

* Open the default URL in Safari upon session startup ([#929](https://github.com/appium/WebDriverAgent/issues/929)) ([97cf91d](https://github.com/appium/WebDriverAgent/commit/97cf91de34dc53e5f75f91829dc43224101c1b45))

## [8.7.12](https://github.com/appium/WebDriverAgent/compare/v8.7.11...v8.7.12) (2024-08-02)

### Miscellaneous Chores

* Replace fancy-log dependency with appium logger ([#928](https://github.com/appium/WebDriverAgent/issues/928)) ([5d2ec24](https://github.com/appium/WebDriverAgent/commit/5d2ec249488655451e2d46384e560fee7e08e840))

## [8.7.11](https://github.com/appium/WebDriverAgent/compare/v8.7.10...v8.7.11) (2024-07-29)

### Bug Fixes

* Respond to /health with a proper HTML ([#925](https://github.com/appium/WebDriverAgent/issues/925)) ([42c519f](https://github.com/appium/WebDriverAgent/commit/42c519f9df7beec81175fd38af388975d6f6b800))

## [8.7.10](https://github.com/appium/WebDriverAgent/compare/v8.7.9...v8.7.10) (2024-07-29)

### Miscellaneous Chores

* **deps-dev:** bump @types/node from 20.14.13 to 22.0.0 ([#926](https://github.com/appium/WebDriverAgent/issues/926)) ([1699023](https://github.com/appium/WebDriverAgent/commit/1699023086a243c3d86ddae4da8342c6beda3f48))

## [8.7.9](https://github.com/appium/WebDriverAgent/compare/v8.7.8...v8.7.9) (2024-07-21)

### Miscellaneous Chores

* keep error handling for the future possible usage ([#921](https://github.com/appium/WebDriverAgent/issues/921)) ([2f90739](https://github.com/appium/WebDriverAgent/commit/2f90739340d70073b48c703b36b9a313d3618972))

## [8.7.8](https://github.com/appium/WebDriverAgent/compare/v8.7.7...v8.7.8) (2024-07-18)

### Bug Fixes

* do nothing for an empty array in w3c actions ([#919](https://github.com/appium/WebDriverAgent/issues/919)) ([9e70ec1](https://github.com/appium/WebDriverAgent/commit/9e70ec1dbec1d1844278a58297a5b956ebaeb7fc))

## [8.7.7](https://github.com/appium/WebDriverAgent/compare/v8.7.6...v8.7.7) (2024-07-18)

### Bug Fixes

* Pass-through modifier keys ([#918](https://github.com/appium/WebDriverAgent/issues/918)) ([29d0e5c](https://github.com/appium/WebDriverAgent/commit/29d0e5cb2a19809e1babb06e5adaa49b43c754a5))

## [8.7.6](https://github.com/appium/WebDriverAgent/compare/v8.7.5...v8.7.6) (2024-07-02)

### Miscellaneous Chores

* Simplify xcodebuild lines monitoring ([#916](https://github.com/appium/WebDriverAgent/issues/916)) ([87678f2](https://github.com/appium/WebDriverAgent/commit/87678f260c98b3a3bc3d37017e9ef39098ccb3c4))

## [8.7.5](https://github.com/appium/WebDriverAgent/compare/v8.7.4...v8.7.5) (2024-06-26)

### Bug Fixes

* Respect wdaRemotePort capability for real devices ([#915](https://github.com/appium/WebDriverAgent/issues/915)) ([03ea143](https://github.com/appium/WebDriverAgent/commit/03ea1439a9cc5b6495be60707bc474e3ae9bdb06))

## [8.7.4](https://github.com/appium/WebDriverAgent/compare/v8.7.3...v8.7.4) (2024-06-20)

### Miscellaneous Chores
Expand Down
4 changes: 4 additions & 0 deletions WebDriverAgent/PrivateHeaders/XCTest/XCUIApplicationProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@
- (void)terminate;
- (void)waitForViewControllerViewDidDisappearWithTimeout:(double)arg1;
- (void)waitForAutomationSession;
// Before Xcode16-beta5
- (void)waitForQuiescenceIncludingAnimationsIdle:(BOOL)arg1;
// Since Xcode16-beta5
- (void)waitForQuiescenceIncludingAnimationsIdle:(BOOL)arg1 isPreEvent:(BOOL)arg2;


- (id)shortDescription;
- (id)_queue_description;
Expand Down
5 changes: 3 additions & 2 deletions WebDriverAgent/Scripts/update-wda-version.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const {plist} = require('@appium/support');
const {plist, logger} = require('@appium/support');
const path = require('node:path');
const semver = require('semver');
const log = require('fancy-log');

const log = logger.getLogger('Versioner');

/**
* @param {string} argName
Expand Down
8 changes: 4 additions & 4 deletions WebDriverAgent/WebDriverAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4200,6 +4200,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 48LP2W34XH;
INFOPLIST_FILE = WebDriverAgentTests/IntegrationApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -4216,6 +4217,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
DEVELOPMENT_TEAM = 48LP2W34XH;
INFOPLIST_FILE = WebDriverAgentTests/IntegrationApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -4270,9 +4272,8 @@
baseConfigurationReference = EEE5CABF1C80361500CBBDD9 /* IOSSettings.xcconfig */;
buildSettings = {
CLANG_STATIC_ANALYZER_MODE = deep;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = UY67AXLS69;
DEVELOPMENT_TEAM = 48LP2W34XH;
ENABLE_TESTING_SEARCH_PATHS = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = WebDriverAgentRunner/Info.plist;
Expand Down Expand Up @@ -4325,8 +4326,7 @@
baseConfigurationReference = EEE5CABF1C80361500CBBDD9 /* IOSSettings.xcconfig */;
buildSettings = {
CLANG_STATIC_ANALYZER_MODE = deep;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
DEVELOPMENT_TEAM = UY67AXLS69;
DEVELOPMENT_TEAM = 48LP2W34XH;
ENABLE_TESTING_SEARCH_PATHS = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = WebDriverAgentRunner/Info.plist;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ @implementation XCAXClient_iOS (FBSnapshotReqParams)

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-load-method"
#pragma clang diagnostic ignored "-Wcast-function-type-strict"

+ (void)load
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ @implementation XCTIssue (AMPatcher)

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-load-method"
#pragma clang diagnostic ignored "-Wcast-function-type-strict"

+ (void)load
{
SEL originalShouldInterruptTest = NSSelectorFromString(@"shouldInterruptTest");
Expand All @@ -28,6 +30,7 @@ + (void)load
if (nil == originalShouldInterruptTestMethod) return;
method_setImplementation(originalShouldInterruptTestMethod, (IMP)swizzledShouldInterruptTest);
}

#pragma clang diagnostic pop

@end
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ NS_ASSUME_NONNULL_BEGIN
/*! Defines wtether the process should perform quiescence checks. YES by default */
@property (nonatomic) NSNumber* fb_shouldWaitForQuiescence;

/**
@param waitForAnimations Set it to YES if XCTest should also wait for application animations to complete
*/
- (void)fb_waitForQuiescenceIncludingAnimationsIdle:(bool)waitForAnimations;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
#import <objc/runtime.h>

#import "FBConfiguration.h"
#import "FBExceptions.h"
#import "FBLogger.h"
#import "FBSettings.h"

static void (*original_waitForQuiescenceIncludingAnimationsIdle)(id, SEL, BOOL);
static void (*original_waitForQuiescenceIncludingAnimationsIdlePreEvent)(id, SEL, BOOL, BOOL);

static void swizzledWaitForQuiescenceIncludingAnimationsIdle(id self, SEL _cmd, BOOL includingAnimations)
{
Expand All @@ -38,17 +40,43 @@ static void swizzledWaitForQuiescenceIncludingAnimationsIdle(id self, SEL _cmd,
}
}

static void swizzledWaitForQuiescenceIncludingAnimationsIdlePreEvent(id self, SEL _cmd, BOOL includingAnimations, BOOL isPreEvent)
{
NSString *bundleId = [self bundleID];
if (![[self fb_shouldWaitForQuiescence] boolValue] || FBConfiguration.waitForIdleTimeout < DBL_EPSILON) {
[FBLogger logFmt:@"Quiescence checks are disabled for %@ application. Making it to believe it is idling",
bundleId];
return;
}

NSTimeInterval desiredTimeout = FBConfiguration.waitForIdleTimeout;
NSTimeInterval previousTimeout = _XCTApplicationStateTimeout();
_XCTSetApplicationStateTimeout(desiredTimeout);
[FBLogger logFmt:@"Waiting up to %@s until %@ is in idle state (%@ animations)",
@(desiredTimeout), bundleId, includingAnimations ? @"including" : @"excluding"];
@try {
original_waitForQuiescenceIncludingAnimationsIdlePreEvent(self, _cmd, includingAnimations, isPreEvent);
} @finally {
_XCTSetApplicationStateTimeout(previousTimeout);
}
}

@implementation XCUIApplicationProcess (FBQuiescence)

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-load-method"
#pragma clang diagnostic ignored "-Wcast-function-type-strict"

+ (void)load
{
Method waitForQuiescenceIncludingAnimationsIdleMethod = class_getInstanceMethod(self.class, @selector(waitForQuiescenceIncludingAnimationsIdle:));
Method waitForQuiescenceIncludingAnimationsIdlePreEventMethod = class_getInstanceMethod(self.class, @selector(waitForQuiescenceIncludingAnimationsIdle:isPreEvent:));
if (nil != waitForQuiescenceIncludingAnimationsIdleMethod) {
IMP swizzledImp = (IMP)swizzledWaitForQuiescenceIncludingAnimationsIdle;
original_waitForQuiescenceIncludingAnimationsIdle = (void (*)(id, SEL, BOOL)) method_setImplementation(waitForQuiescenceIncludingAnimationsIdleMethod, swizzledImp);
} else if (nil != waitForQuiescenceIncludingAnimationsIdlePreEventMethod) {
IMP swizzledImp = (IMP)swizzledWaitForQuiescenceIncludingAnimationsIdlePreEvent;
original_waitForQuiescenceIncludingAnimationsIdlePreEvent = (void (*)(id, SEL, BOOL, BOOL)) method_setImplementation(waitForQuiescenceIncludingAnimationsIdlePreEventMethod, swizzledImp);
} else {
[FBLogger log:@"Could not find method -[XCUIApplicationProcess waitForQuiescenceIncludingAnimationsIdle:]"];
}
Expand All @@ -74,4 +102,18 @@ - (void)setFb_shouldWaitForQuiescence:(NSNumber *)value
objc_setAssociatedObject(self, &XCUIAPPLICATIONPROCESS_SHOULD_WAIT_FOR_QUIESCENCE, value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (void)fb_waitForQuiescenceIncludingAnimationsIdle:(bool)waitForAnimations
{
if ([self respondsToSelector:@selector(waitForQuiescenceIncludingAnimationsIdle:)]) {
[self waitForQuiescenceIncludingAnimationsIdle:waitForAnimations];
} else if ([self respondsToSelector:@selector(waitForQuiescenceIncludingAnimationsIdle:isPreEvent:)]) {
[self waitForQuiescenceIncludingAnimationsIdle:waitForAnimations isPreEvent:NO];
} else {
@throw [NSException exceptionWithName:FBIncompatibleWdaException
reason:@"The current WebDriverAgent build is not compatible to your device OS version"
userInfo:@{}];
}
}


@end
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static void swizzled_validatePredicateWithExpressionsAllowed(id self, SEL _cmd,

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-load-method"
#pragma clang diagnostic ignored "-Wcast-function-type-strict"
+ (void)load
{
Class XCElementSnapshotCls = objc_lookUpClass("XCElementSnapshot");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#import "XCTElementSetTransformer-Protocol.h"
#import "XCTestPrivateSymbols.h"
#import "XCTRunnerDaemonSession.h"
#import "XCUIApplicationProcess+FBQuiescence.h"
#import "XCUIElement+FBCaching.h"
#import "XCUIElement+FBWebDriverAttributes.h"
#import "XCUIElementQuery.h"
Expand Down Expand Up @@ -190,7 +191,7 @@ - (void)fb_waitUntilStableWithTimeout:(NSTimeInterval)timeout
self.application.fb_shouldWaitForQuiescence = YES;
}
[[[self.application applicationImpl] currentProcess]
waitForQuiescenceIncludingAnimationsIdle:YES];
fb_waitForQuiescenceIncludingAnimationsIdle:YES];
if (previousQuiescence != self.application.fb_shouldWaitForQuiescence) {
self.application.fb_shouldWaitForQuiescence = previousQuiescence;
}
Expand Down
5 changes: 5 additions & 0 deletions WebDriverAgent/WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ + (NSArray *)routes
return FBResponseWithStatus([FBCommandStatus invalidArgumentErrorWithMessage:@"URL is required" traceback:nil]);
}
NSString* bundleId = request.arguments[@"bundleId"];
NSNumber* idleTimeoutMs = request.arguments[@"idleTimeoutMs"];
NSError *error;
if (nil == bundleId) {
if (![XCUIDevice.sharedDevice fb_openUrl:urlString error:&error]) {
Expand All @@ -75,6 +76,10 @@ + (NSArray *)routes
if (![XCUIDevice.sharedDevice fb_openUrl:urlString withApplication:bundleId error:&error]) {
return FBResponseWithUnknownError(error);
}
if (idleTimeoutMs.doubleValue > 0) {
XCUIApplication *app = [[XCUIApplication alloc] initWithBundleIdentifier:bundleId];
[app fb_waitUntilStableWithTimeout:FBMillisToSeconds(idleTimeoutMs.doubleValue)];
}
}
return FBResponseWithOK();
}
Expand Down
4 changes: 2 additions & 2 deletions WebDriverAgent/WebDriverAgentLib/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>8.7.4</string>
<string>8.9.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>8.7.4</string>
<string>8.9.2</string>
<key>NSPrincipalClass</key>
<string/>
</dict>
Expand Down
3 changes: 3 additions & 0 deletions WebDriverAgent/WebDriverAgentLib/Routing/FBExceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ extern NSString *const FBApplicationCrashedException;
/*! Exception used to notify about the application is not installed */
extern NSString *const FBApplicationMissingException;

/*! Exception used to notify about WDA incompatibility with the current platform version */
extern NSString *const FBIncompatibleWdaException;

NS_ASSUME_NONNULL_END
1 change: 1 addition & 0 deletions WebDriverAgent/WebDriverAgentLib/Routing/FBExceptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
NSString *const FBClassChainQueryParseException = @"FBClassChainQueryParseException";
NSString *const FBApplicationCrashedException = @"FBApplicationCrashedException";
NSString *const FBApplicationMissingException = @"FBApplicationMissingException";
NSString *const FBIncompatibleWdaException = @"FBIncompatibleWdaException";
3 changes: 3 additions & 0 deletions WebDriverAgent/WebDriverAgentLib/Routing/FBRoute.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ @implementation FBRoute_TargetAction
- (void)mountRequest:(FBRouteRequest *)request intoResponse:(RouteResponse *)response
{
[self decorateRequest:request];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-function-type-strict"
id<FBResponsePayload> (*requestMsgSend)(id, SEL, FBRouteRequest *) = ((id<FBResponsePayload>(*)(id, SEL, FBRouteRequest *))objc_msgSend);
#pragma clang diagnostic pop
id<FBResponsePayload> payload = requestMsgSend(self.target, self.action, request);
[payload dispatchWithResponse:response];
}
Expand Down
3 changes: 3 additions & 0 deletions WebDriverAgent/WebDriverAgentLib/Routing/FBSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

NS_ASSUME_NONNULL_BEGIN

/** Bundle identifier of Mobile Safari browser */
extern NSString* const FB_SAFARI_BUNDLE_ID;

/**
Class that represents testing session
*/
Expand Down
2 changes: 2 additions & 0 deletions WebDriverAgent/WebDriverAgentLib/Routing/FBSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
NSString *const FBDefaultApplicationAuto = @"auto";

NSString *const FB_SAFARI_BUNDLE_ID = @"com.apple.mobilesafari";

@interface FBSession ()
@property (nullable, nonatomic) XCUIApplication *testedApplication;
@property (nonatomic) BOOL isTestedApplicationExpectedToRun;
Expand Down
2 changes: 1 addition & 1 deletion WebDriverAgent/WebDriverAgentLib/Routing/FBWebServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ - (void)handleException:(NSException *)exception forResponse:(RouteResponse *)re
- (void)registerServerKeyRouteHandlers
{
[self.server get:@"/health" withBlock:^(RouteRequest *request, RouteResponse *response) {
[response respondWithString:@"I-AM-ALIVE"];
[response respondWithString:@"<!DOCTYPE html><html><title>Health Check</title><body><p>I-AM-ALIVE</p></body></html>"];
}];

NSString *calibrationPage = @"<html>"
Expand Down
Loading

0 comments on commit 04e5bb6

Please sign in to comment.