capybara-lockstep 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bad1a61632d37c5e705b886be4cb840a62923f73887c1443060fb00c6e69aa2
4
- data.tar.gz: 9243b559659a33a00e6f803304284aa9cd47e5c2f110a11b47eb2e4e62441537
3
+ metadata.gz: dbe79968ebe67aec5235612f3699fc83fb1845205579b421c0291883ce4fffcb
4
+ data.tar.gz: 3fef926a33a2303f0d41940aec44c569c10001ae3a749325a59b502f38c8f2d6
5
5
  SHA512:
6
- metadata.gz: 9b285d685609f913c92b4b8d5556d34d7d77e2fb6d80e5fac4cda189c81a2b81445fc65a5680726c2d21b16d0bcdcb1fcb35e3a6169b2febca3244eaa555b985
7
- data.tar.gz: d598437ffb3eaf066d6cbcb747ac6c5445bed0a2c2cbc5113f42e0d947d4b71fc7bb4752ede4193cca989acafd5d126757c67d3454fbfc226014d7b42056b55f
6
+ metadata.gz: b0dc89fd6df23a4163f65ba33d537d40561abcfb7a96820b5757130088771d1e8b6432c51a8fbad6f22f54163a35f1ad417553bfe95e1c77d4a84bc1b6d55c01
7
+ data.tar.gz: ff6dda402879f2ed6de25686e144cc428e3c33d4eec05d2b705ef5cc2e3591b31244dd111799243c5b5618d7a417bf17295c8611deb72ce3ac82502f609ad07d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file.
2
2
 
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
+
6
+ # 2.2.2
7
+
8
+ - We now only wait for `<script>` elements with a JavaScript type
9
+ - We only wait for `<iframe>` elements with a `[src]` attribute
10
+ - We no longer wait for `<video>` and `<audio>` elements to load their metadata. This did not work consistently, and would sometimes cause capybara-lockstep to wait indefinitely.
11
+
12
+
5
13
  # 2.2.1
6
14
 
7
15
  - Fixed a bug that disabled most functionality for drivers with `browser: :remote`.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capybara-lockstep (2.2.1)
4
+ capybara-lockstep (2.2.2)
5
5
  activesupport (>= 4.2)
6
6
  capybara (>= 3.0)
7
7
  ruby2_keywords
@@ -71,8 +71,8 @@ GEM
71
71
  diff-lcs (>= 1.2.0, < 2.0)
72
72
  rspec-support (~> 3.13.0)
73
73
  rspec-support (3.13.1)
74
- rspec-wait (0.0.10)
75
- rspec (>= 3.0)
74
+ rspec-wait (1.0.0)
75
+ rspec (>= 3.4)
76
76
  ruby2_keywords (0.0.5)
77
77
  rubyzip (2.3.2)
78
78
  selenium-webdriver (4.1.0)
data/README.md CHANGED
@@ -72,7 +72,6 @@ When capybara-lockstep synchronizes it will:
72
72
  - wait for any pending AJAX requests to finish and their callbacks to be called.
73
73
  - wait for dynamically inserted `<script>`s to load (e.g. from [dynamic imports](https://webpack.js.org/guides/code-splitting/#dynamic-imports) or Analytics snippets).
74
74
  - wait for dynamically inserted `<img>` or `<iframe>` elements to load (ignoring [lazy-loaded](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#lazy) elements).
75
- - wait for dynamically inserted `<audio>` and `<video>` elements to load their [metadata](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadedmetadata_event)
76
75
 
77
76
  In summary, Capybara can no longer observe or interact with the page while HTTP requests are in flight.
78
77
  This covers most async work that causes flaky tests.
@@ -86,6 +85,7 @@ Async work not synchronized by capybara-lockstep includes:
86
85
  - Websocket connections
87
86
  - Service workers
88
87
  - Work scheduled via `setTimeout()` or `setInterval()`.
88
+ - `<audio>` and `<video>` elements
89
89
 
90
90
  You can configure capybara-lockstep to [wait for additional async work](#signaling-asynchronous-work).
91
91
 
@@ -177,7 +177,7 @@ window.CapybaraLockstep = (function() {
177
177
  }
178
178
 
179
179
  function isRemoteScript(element) {
180
- return element.matches('script[src]') && !hasDataSource(element)
180
+ return element.matches('script[src]') && !hasDataSource(element) && isTrackableScriptType(element.type)
181
181
  }
182
182
 
183
183
  function isTrackableImage(element) {
@@ -188,11 +188,15 @@ window.CapybaraLockstep = (function() {
188
188
  }
189
189
 
190
190
  function isTrackableIFrame(element) {
191
- return element.matches('iframe') &&
191
+ return element.matches('iframe[src]') &&
192
192
  !hasDataSource(element) &&
193
193
  element.getAttribute('loading') !== 'lazy'
194
194
  }
195
195
 
196
+ function isTrackableScriptType(type) {
197
+ return !type || type === 'text/javascript' || type === 'module' || type === 'application/javascript'
198
+ }
199
+
196
200
  function hasDataSource(element) {
197
201
  // <img> can have <img src> and <img srcset>
198
202
  // <video> can have <video src> or <video><source src>
@@ -201,22 +205,11 @@ window.CapybaraLockstep = (function() {
201
205
  !!element.querySelector('source [src*="data:"], source [srcset*="data:"]')
202
206
  }
203
207
 
204
- function isTrackableMediaElement(element) {
205
- return element.matches('audio, video') &&
206
- element.readyState === 0 && // no metadata known
207
- !hasDataSource(element) &&
208
- element.getAttribute('preload') !== 'none'
209
- }
210
-
211
208
  function trackRemoteElement(element, condition, workTag) {
212
209
  trackLoadingElement(element, condition, workTag, 'load', 'error')
213
210
 
214
211
  }
215
212
 
216
- function trackMediaElement(element, condition, workTag) {
217
- trackLoadingElement(element, condition, workTag, 'loadedmetadata', 'error')
218
- }
219
-
220
213
  function trackLoadingElement(element, condition, workTag, loadEvent, errorEvent) {
221
214
  if (!condition(element)) {
222
215
  return
@@ -266,7 +259,6 @@ window.CapybaraLockstep = (function() {
266
259
  trackRemoteElement(addedNode, isRemoteScript, 'Script')
267
260
  trackRemoteElement(addedNode, isTrackableImage, 'Image')
268
261
  trackRemoteElement(addedNode, isTrackableIFrame, 'Inline frame')
269
- trackMediaElement(addedNode, isTrackableMediaElement, 'Media element')
270
262
  }
271
263
  })
272
264
  })
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Lockstep
3
- VERSION = "2.2.1"
3
+ VERSION = "2.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-lockstep
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-19 00:00:00.000000000 Z
11
+ date: 2024-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.4.1
127
+ rubygems_version: 3.4.3
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: Synchronize Capybara commands with client-side JavaScript and AJAX requests