ReviewOS

also looking at this

craft-native/craft

fix(ios): hand the page the answers native was already sending

#222
Merged glennmichael123 wants to merge fix/ios-unanswered-posts into main
18 files +597 -164
scripts/mobile-e2e/driver.htmlmodified+81-0
Changes to scripts/mobile-e2e/driver.html
@@ -219,6 +219,87 @@
219219 })
220220 }
221221 },
222 {
223 // #207. `craft.geolocation.watchPosition` posted no callbackId, so a
224 // page could not tell a watch that started from one refused. It
225 // answers once updates have started; fixes still arrive as events.
226 // After currentPosition, so authorization is already settled.
227 name: 'geolocation.watchPosition.resolvesTrue',
228 platforms: ['ios'],
229 run: function () {
230 return withTimeout(function () { return window.craft.geolocation.watchPosition(function () {}) }).then(function (outcome) {
231 if (outcome.state === 'timeout') return 'watchPosition never settled'
232 if (outcome.state === 'rejected') return 'watchPosition rejected: ' + outcome.error.code + ' ' + outcome.error.message
233 if (outcome.value !== true) return 'watchPosition resolved with ' + JSON.stringify(outcome.value)
234 })
235 }
236 },
237 {
238 name: 'geolocation.clearWatch.resolvesTrue',
239 platforms: ['ios'],
240 run: function () {
241 return withTimeout(function () { return window.craft.geolocation.clearWatch() }).then(function (outcome) {
242 if (outcome.state === 'timeout') return 'clearWatch never settled'
243 if (outcome.state === 'rejected') return 'clearWatch rejected: ' + outcome.error.code + ' ' + outcome.error.message
244 if (outcome.value !== true) return 'clearWatch resolved with ' + JSON.stringify(outcome.value)
245 })
246 }
247 },
248 {
249 // #207 again, and the half a callbackId alone would have broken.
250 // Haptics is on, and native used to answer an enabled haptic with
251 // nothing at all; it only ever rejected. So a page that awaited it
252 // would wait for ever on every call that worked.
253 name: 'haptic.resolvesTrue',
254 platforms: ['ios'],
255 run: function () {
256 return withTimeout(function () { return window.craft.haptic('light') }).then(function (outcome) {
257 if (outcome.state === 'timeout') return 'haptic never settled with haptics enabled'
258 if (outcome.state === 'rejected') return 'haptic rejected: ' + outcome.error.code + ' ' + outcome.error.message
259 if (outcome.value !== true) return 'haptic resolved with ' + JSON.stringify(outcome.value)
260 })
261 }
262 },
263 {
264 name: 'vibrate.resolvesTrue',
265 platforms: ['ios'],
266 run: function () {
267 return withTimeout(function () { return window.craft.vibrate([]) }).then(function (outcome) {
268 if (outcome.state === 'timeout') return 'vibrate never settled'
269 if (outcome.state === 'rejected') return 'vibrate rejected: ' + outcome.error.code + ' ' + outcome.error.message
270 if (outcome.value !== true) return 'vibrate resolved with ' + JSON.stringify(outcome.value)
271 })
272 }
273 },
274 {
275 // Speech recognition is off, and `startListening` used to drop the
276 // refusal: the page got undefined and no craftSpeechError either.
277 // Refused before any authorization prompt, so nothing waits on a
278 // microphone the simulator does not have.
279 name: 'speech.disabled.rejects',
280 platforms: ['ios'],
281 run: function () {
282 return withTimeout(function () { return window.craft.startListening() }).then(function (outcome) {
283 if (outcome.state === 'timeout') return 'startListening never settled'
284 if (outcome.state === 'resolved') return 'startListening resolved with ' + JSON.stringify(outcome.value) + ' while speech recognition is disabled'
285 if (outcome.error.code !== 'CAPABILITY_DISABLED') return 'code is ' + JSON.stringify(outcome.error.code)
286 })
287 }
288 },
289 {
290 // stopListening is not gated, so it runs with speech off, and it is
291 // the one speech call whose success path a simulator can reach
292 // without a microphone. It used to answer nothing on either side.
293 name: 'speech.stopListening.resolvesTrue',
294 platforms: ['ios'],
295 run: function () {
296 return withTimeout(function () { return window.craft.stopListening() }).then(function (outcome) {
297 if (outcome.state === 'timeout') return 'stopListening never settled'
298 if (outcome.state === 'rejected') return 'stopListening rejected: ' + outcome.error.code + ' ' + outcome.error.message
299 if (outcome.value !== true) return 'stopListening resolved with ' + JSON.stringify(outcome.value)
300 })
301 }
302 },
222303 {
223304 // Sharing is off too, and this is the call that used to answer
224305 // nothing: `craft.share(text)` posted no callbackId, so Swift's