Bug 1594243 [wpt PR 19853] - [sms] Implement AbortController for SMSReceiver API, a=testonly

Automatic update from web-platform-tests
[sms] Implement AbortController for SMSReceiver API

This change allows developers to use the SMS Receiver API with the Abort
Controller to cancel once the API is called. This will help developers with
flows for retrying and sending a new code and they want to abort the previous
call they made to the API. If the InfoBar is up during abort, it will
leave the InfoBar open while returning an AbortError to the website. If
another request is made while the InfoBar for 1st request is still open (after
abort), upon clicking 'Verify' the SMS retrieved for the 1st request will
return to the 2nd request.

Bug: 976401
Change-Id: I132800f2954fdc370172dcd03789d3f08bcc4040
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866914
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717710}

--

wpt-commits: 82ea18f340f977bc8f42e503043f4eb054a6d2e7
wpt-pr: 19853
This commit is contained in:
Ayu Ishii 2019-11-26 11:29:07 +00:00 коммит произвёл moz-wptsync-bot
Родитель 611a3c81ae
Коммит 81f485b762
3 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -8,7 +8,7 @@ const SmsProvider = (() => {
this.mojoReceiver_ = new blink.mojom.SmsReceiverReceiver(this);
this.interceptor_ = new MojoInterfaceInterceptor(
blink.mojom.SmsReceiver.$interfaceName, "context", true)
blink.mojom.SmsReceiver.$interfaceName, "context", true);
this.interceptor_.oninterfacerequest = (e) => {
this.mojoReceiver_.$.bindHandle(e.handle);
@ -27,6 +27,8 @@ const SmsProvider = (() => {
return call();
}
abort() {}
pushReturnValuesForTesting(callName, value) {
this.returnValues_[callName] = this.returnValues_[callName] || [];
this.returnValues_[callName].push(value);

Просмотреть файл

@ -114,4 +114,21 @@ promise_test(async t => {
}
}, 'Deal with cancelled requests');
promise_test(async t => {
const controller = new AbortController();
const signal = controller.signal;
controller.abort();
await promise_rejects(t, 'AbortError', navigator.sms.receive({signal}));
}, 'Should abort request');
promise_test(async t => {
const controller = new AbortController();
const signal = controller.signal;
let error = navigator.sms.receive({signal});
controller.abort();
await promise_rejects(t, 'AbortError', error);
}, 'Should abort request even while request is in progress.');
</script>

Просмотреть файл

@ -13,7 +13,7 @@ interface SMS {
};
dictionary SMSReceiverOptions {
// TODO(b/976401): Implement abort controller.
AbortSignal signal;
};
[