appium-webdriveragent 4.10.6 → 4.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [4.10.8](https://github.com/appium/WebDriverAgent/compare/v4.10.7...v4.10.8) (2022-11-24)
2
+
3
+ ## [4.10.7](https://github.com/appium/WebDriverAgent/compare/v4.10.6...v4.10.7) (2022-11-24)
4
+
1
5
  ## [4.10.6](https://github.com/appium/WebDriverAgent/compare/v4.10.5...v4.10.6) (2022-11-23)
2
6
 
3
7
  ## [4.10.5](https://github.com/appium/WebDriverAgent/compare/v4.10.4...v4.10.5) (2022-11-22)
@@ -31,7 +31,6 @@
31
31
  #import "XCTestPrivateSymbols.h"
32
32
  #import "XCTRunnerDaemonSession.h"
33
33
 
34
- const static NSTimeInterval FBMinimumAppSwitchWait = 3.0;
35
34
  static NSString* const FBUnknownBundleId = @"unknown";
36
35
 
37
36
 
@@ -92,7 +91,7 @@ static NSString* const FBUnknownBundleId = @"unknown";
92
91
  if(![[XCUIDevice sharedDevice] fb_goToHomescreenWithError:error]) {
93
92
  return NO;
94
93
  }
95
- [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:MAX(duration, FBMinimumAppSwitchWait)]];
94
+ [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:MAX(duration, .0)]];
96
95
  [self fb_activate];
97
96
  return YES;
98
97
  }
@@ -48,7 +48,7 @@ static char XCUIELEMENT_CACHE_ID_KEY;
48
48
  uid = self.fb_uid;
49
49
  } else {
50
50
  id<FBXCElementSnapshot> snapshot = self.fb_cachedSnapshot ?: self.fb_takeSnapshot;
51
- uid = [FBXCElementSnapshotWrapper ensureWrapped:snapshot].wdUID;
51
+ uid = [FBXCElementSnapshotWrapper wdUIDWithSnapshot:snapshot];
52
52
  }
53
53
 
54
54
  objc_setAssociatedObject(self, &XCUIELEMENT_CACHE_ID_KEY, uid, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
@@ -34,9 +34,9 @@
34
34
 
35
35
  @implementation FBXCElementSnapshotWrapper (FBIsVisible)
36
36
 
37
- - (NSString *)fb_uniqId
37
+ + (NSString *)fb_uniqIdWithSnapshot:(id<FBXCElementSnapshot>)snapshot
38
38
  {
39
- return self.fb_uid ?: [NSString stringWithFormat:@"%p", (void *)self];
39
+ return [FBXCElementSnapshotWrapper wdUIDWithSnapshot:snapshot] ?: [NSString stringWithFormat:@"%p", (void *)snapshot];
40
40
  }
41
41
 
42
42
  - (nullable NSNumber *)fb_cachedVisibilityValue
@@ -46,14 +46,14 @@
46
46
  return nil;
47
47
  }
48
48
 
49
- NSDictionary<NSString *, NSNumber *> *result = [cache objectForKey:@(self.generation)];
49
+ NSDictionary<NSString *, NSNumber *> *result = cache[@(self.generation)];
50
50
  if (nil == result) {
51
51
  // There is no need to keep the cached data for the previous generations
52
52
  [cache removeAllObjects];
53
- [cache setObject:[NSMutableDictionary dictionary] forKey:@(self.generation)];
53
+ cache[@(self.generation)] = [NSMutableDictionary dictionary];
54
54
  return nil;
55
55
  }
56
- return [result objectForKey:self.fb_uniqId];
56
+ return result[[self.class fb_uniqIdWithSnapshot:self.snapshot]];
57
57
  }
58
58
 
59
59
  - (BOOL)fb_cacheVisibilityWithValue:(BOOL)isVisible
@@ -63,19 +63,19 @@
63
63
  if (nil == cache) {
64
64
  return isVisible;
65
65
  }
66
- NSMutableDictionary<NSString *, NSNumber *> *destination = [cache objectForKey:@(self.generation)];
66
+ NSMutableDictionary<NSString *, NSNumber *> *destination = cache[@(self.generation)];
67
67
  if (nil == destination) {
68
68
  return isVisible;
69
69
  }
70
70
 
71
71
  NSNumber *visibleObj = [NSNumber numberWithBool:isVisible];
72
- [destination setObject:visibleObj forKey:self.fb_uniqId];
72
+ destination[[self.class fb_uniqIdWithSnapshot:self.snapshot]] = visibleObj;
73
73
  if (isVisible && nil != ancestors) {
74
74
  // if an element is visible then all its ancestors must be visible as well
75
75
  for (id<FBXCElementSnapshot> ancestor in ancestors) {
76
- NSString *ancestorId = [FBXCElementSnapshotWrapper ensureWrapped:ancestor].fb_uniqId;
77
- if (nil == [destination objectForKey:ancestorId]) {
78
- [destination setObject:visibleObj forKey:ancestorId];
76
+ NSString *ancestorId = [self.class fb_uniqIdWithSnapshot:ancestor];
77
+ if (nil == destination[ancestorId]) {
78
+ destination[ancestorId] = visibleObj;
79
79
  }
80
80
  }
81
81
  }
@@ -41,8 +41,9 @@ static char XCUIELEMENT_IS_RESOLVED_NATIVELY_KEY;
41
41
  XCUIElementQuery *query = [self isKindOfClass:XCUIApplication.class]
42
42
  ? self.application.fb_query
43
43
  : [self.application.fb_query descendantsMatchingType:XCUIElementTypeAny];
44
- FBXCElementSnapshotWrapper *cachedSnapshot = [FBXCElementSnapshotWrapper ensureWrapped:self.fb_cachedSnapshot];
45
- NSString *uid = nil == cachedSnapshot ? self.fb_uid : cachedSnapshot.fb_uid;
44
+ NSString *uid = nil == self.fb_cachedSnapshot
45
+ ? self.fb_uid
46
+ : [FBXCElementSnapshotWrapper wdUIDWithSnapshot:(id)self.fb_cachedSnapshot];
46
47
  if (nil == uid) {
47
48
  return self;
48
49
  }
@@ -22,6 +22,7 @@
22
22
  #import "XCUIElement+FBClassChain.h"
23
23
  #import "XCUIElement+FBFind.h"
24
24
  #import "XCUIElement+FBIsVisible.h"
25
+ #import "XCUIElement+FBUID.h"
25
26
  #import "XCUIElement+FBUtilities.h"
26
27
  #import "XCUIElement+FBWebDriverAttributes.h"
27
28
 
@@ -88,7 +89,7 @@ static id<FBResponsePayload> FBNoSuchElementErrorResponseForRequest(FBRouteReque
88
89
  && [FBXCElementSnapshotWrapper ensureWrapped:snapshot].wdVisible;
89
90
  }];
90
91
  NSArray *cells = [element fb_filterDescendantsWithSnapshots:visibleCellSnapshots
91
- selfUID:[FBXCElementSnapshotWrapper ensureWrapped:element.lastSnapshot].wdUID
92
+ selfUID:[FBXCElementSnapshotWrapper wdUIDWithSnapshot:element.lastSnapshot]
92
93
  onlyChildren:NO];
93
94
  return FBResponseWithCachedElements(cells, request.session.elementCache, FBConfiguration.shouldUseCompactResponses);
94
95
  }
@@ -31,7 +31,6 @@ static const char *QUEUE_NAME = "JPEG Screenshots Provider Queue";
31
31
 
32
32
  @property (nonatomic, readonly) dispatch_queue_t backgroundQueue;
33
33
  @property (nonatomic, readonly) NSMutableArray<GCDAsyncSocket *> *listeningClients;
34
- @property (nonatomic, readonly) mach_timebase_info_data_t timebaseInfo;
35
34
  @property (nonatomic, readonly) FBImageIOScaler *imageScaler;
36
35
  @property (nonatomic, readonly) long long mainScreenID;
37
36
 
@@ -46,7 +45,6 @@ static const char *QUEUE_NAME = "JPEG Screenshots Provider Queue";
46
45
  _listeningClients = [NSMutableArray array];
47
46
  dispatch_queue_attr_t queueAttributes = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_UTILITY, 0);
48
47
  _backgroundQueue = dispatch_queue_create(QUEUE_NAME, queueAttributes);
49
- mach_timebase_info(&_timebaseInfo);
50
48
  dispatch_async(_backgroundQueue, ^{
51
49
  [self streamScreenshot];
52
50
  });
@@ -58,8 +56,8 @@ static const char *QUEUE_NAME = "JPEG Screenshots Provider Queue";
58
56
 
59
57
  - (void)scheduleNextScreenshotWithInterval:(uint64_t)timerInterval timeStarted:(uint64_t)timeStarted
60
58
  {
61
- uint64_t timeElapsed = mach_absolute_time() - timeStarted;
62
- int64_t nextTickDelta = timerInterval - timeElapsed * self.timebaseInfo.numer / self.timebaseInfo.denom;
59
+ uint64_t timeElapsed = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) - timeStarted;
60
+ int64_t nextTickDelta = timerInterval - timeElapsed;
63
61
  if (nextTickDelta > 0) {
64
62
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, nextTickDelta), self.backgroundQueue, ^{
65
63
  [self streamScreenshot];
@@ -81,7 +79,7 @@ static const char *QUEUE_NAME = "JPEG Screenshots Provider Queue";
81
79
 
82
80
  NSUInteger framerate = FBConfiguration.mjpegServerFramerate;
83
81
  uint64_t timerInterval = (uint64_t)(1.0 / ((0 == framerate || framerate > MAX_FPS) ? MAX_FPS : framerate) * NSEC_PER_SEC);
84
- uint64_t timeStarted = mach_absolute_time();
82
+ uint64_t timeStarted = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
85
83
  @synchronized (self.listeningClients) {
86
84
  if (0 == self.listeningClients.count) {
87
85
  [self scheduleNextScreenshotWithInterval:timerInterval timeStarted:timeStarted];
@@ -94,7 +94,7 @@
94
94
  pasteboardContent = result;
95
95
  didFinishGetPasteboard = YES;
96
96
  });
97
- uint64_t timeStarted = mach_absolute_time();
97
+ uint64_t timeStarted = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
98
98
  while (!didFinishGetPasteboard) {
99
99
  [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:ALERT_CHECK_INTERVAL_SEC]];
100
100
  if (didFinishGetPasteboard) {
@@ -106,7 +106,7 @@
106
106
  FBAlert *alert = [FBAlert alertWithElement:alertElement];
107
107
  [alert acceptWithError:nil];
108
108
  }
109
- uint64_t timeElapsed = mach_absolute_time() - timeStarted;
109
+ uint64_t timeElapsed = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) - timeStarted;
110
110
  if (timeElapsed / NSEC_PER_SEC > timeout) {
111
111
  NSString *description = [NSString stringWithFormat:@"Cannot handle pasteboard alert within %@s timeout", @(timeout)];
112
112
  if (error) {
Binary file
@@ -46,10 +46,10 @@
46
46
  - (void)testDeactivateApplication
47
47
  {
48
48
  NSError *error;
49
- uint64_t timeStarted = mach_absolute_time();
49
+ uint64_t timeStarted = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
50
50
  NSTimeInterval backgroundDuration = 5.0;
51
51
  XCTAssertTrue([self.testedApplication fb_deactivateWithDuration:backgroundDuration error:&error]);
52
- NSTimeInterval timeElapsed = (mach_absolute_time() - timeStarted) / NSEC_PER_SEC;
52
+ NSTimeInterval timeElapsed = (clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) - timeStarted) / NSEC_PER_SEC;
53
53
  XCTAssertNil(error);
54
54
  XCTAssertEqualWithAccuracy(timeElapsed, backgroundDuration, 3.0);
55
55
  XCTAssertTrue(self.testedApplication.buttons[@"Alerts"].exists);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "4.10.6",
3
+ "version": "4.10.8",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {