capybara-simulated 0.6.0 → 0.7.0
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.
- checksums.yaml +4 -4
- data/lib/capybara/simulated/asset_cache.rb +15 -5
- data/lib/capybara/simulated/browser.rb +679 -46
- data/lib/capybara/simulated/driver.rb +13 -1
- data/lib/capybara/simulated/js/bridge.bundle.js +15586 -13715
- data/lib/capybara/simulated/runtime_shared.rb +1 -1
- data/lib/capybara/simulated/version.rb +1 -1
- data/vendor/js/vendor.bundle.js +12 -11
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b61d25a747a9298497ccf9c66f47f62f5e76c7ee79410aa7f1823a57c536e301
|
|
4
|
+
data.tar.gz: 296588737e8879ff5a64fa95034a625d40d80d9971405f962c9cbbb6a8cb30c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3adaf35e860f19084cf71c91092617151919f8ae71926f757afefdd3636d2f399a51c08ad703ed7c6210aeb9ab7f00a1c3f30cbf558f9ed2928b0d1a068a77d9
|
|
7
|
+
data.tar.gz: e89bca3cb36f3d48adb87ab880d31c00a8d0787c59f0b40c1cbaf1ebadf36a3eef3ebfc17bd1b3641011cf397e1fc16b13593d78cd83910a00ec7c834a686ae8
|
|
@@ -66,7 +66,16 @@ module Capybara
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# RFC 9111 §3: status codes cacheable by default.
|
|
69
|
-
|
|
69
|
+
# Statuses we store. 301/308 (permanent redirects) are cacheable by default; 302/307
|
|
70
|
+
# (temporary) are cacheable too but only ever served fresh with EXPLICIT freshness — they
|
|
71
|
+
# are excluded from HEURISTIC_STATUSES below, and a 302/307 with neither explicit freshness
|
|
72
|
+
# nor a validator is dropped by `store`. Storing them lets a cached redirect be followed
|
|
73
|
+
# from the cache (request-cache only-if-cached/force-cache).
|
|
74
|
+
CACHEABLE_STATUSES = [200, 203, 204, 206, 300, 301, 302, 307, 308, 404, 405, 410, 414, 501].freeze
|
|
75
|
+
# Statuses eligible for HEURISTIC freshness (RFC 9111 §4.2.2 — "cacheable by default").
|
|
76
|
+
# 302/307 are NOT here: a temporary redirect is served fresh only with explicit freshness,
|
|
77
|
+
# never a Last-Modified-derived heuristic (which would risk serving it stale).
|
|
78
|
+
HEURISTIC_STATUSES = [200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414, 501].freeze
|
|
70
79
|
|
|
71
80
|
# `Vary` fields we can safely ignore because Simulated never sends
|
|
72
81
|
# the corresponding request header — the cached "no value" variant
|
|
@@ -103,7 +112,7 @@ module Capybara
|
|
|
103
112
|
# `private` is a per-user response a shared cache MUST NOT store
|
|
104
113
|
# (§5.2.2.7); this process-wide cache is shared across sessions.
|
|
105
114
|
return if cc[:private]
|
|
106
|
-
max_age = freshness_seconds(cc, h)
|
|
115
|
+
max_age = freshness_seconds(cc, h, heuristic: HEURISTIC_STATUSES.include?(status))
|
|
107
116
|
# Nothing useful to cache without a freshness signal or a
|
|
108
117
|
# validator to revalidate against.
|
|
109
118
|
return if max_age.nil? && h['etag'].nil? && h['last-modified'].nil?
|
|
@@ -132,7 +141,7 @@ module Capybara
|
|
|
132
141
|
h = ensure_lowercase(new_headers)
|
|
133
142
|
cc = parse_cache_control(h['cache-control'])
|
|
134
143
|
entry.stored_at = Time.now
|
|
135
|
-
entry.max_age = freshness_seconds(cc, h) || entry.max_age
|
|
144
|
+
entry.max_age = freshness_seconds(cc, h, heuristic: HEURISTIC_STATUSES.include?(entry.status)) || entry.max_age
|
|
136
145
|
# RFC 9111 §4.3.4: a 304 UPDATES stored header fields with the ones
|
|
137
146
|
# it carries; it does not delete them. A bare 304 (no Cache-Control —
|
|
138
147
|
# the common ETag / Last-Modified revalidation) must therefore PRESERVE
|
|
@@ -145,8 +154,9 @@ module Capybara
|
|
|
145
154
|
|
|
146
155
|
private
|
|
147
156
|
|
|
148
|
-
def freshness_seconds(cc, headers)
|
|
149
|
-
cc[:max_age] || expires_to_max_age(headers['expires'], headers['date'])
|
|
157
|
+
def freshness_seconds(cc, headers, heuristic: true)
|
|
158
|
+
explicit = cc[:max_age] || expires_to_max_age(headers['expires'], headers['date'])
|
|
159
|
+
explicit || (heuristic ? heuristic_freshness(headers) : nil)
|
|
150
160
|
end
|
|
151
161
|
|
|
152
162
|
# RFC 9111 §4.2.2: a response with no explicit freshness (no max-age, no
|