Bug 1598652 [wpt PR 20402] - [WebNFC] Add permission prompt for NDEFReader.scan, a=testonly

Automatic update from web-platform-tests
[WebNFC] Add permission prompt for NDEFReader.scan

This CL makes sure NDEFReader.scan shows a permission request if user
didn't previously allow Web NFC.

Screenshots: https://photos.app.goo.gl/k7wz55v9ELVTS19i8

Bug: 520391
Change-Id: I10125c8db9a4b1cdd3476939bdf650583c7f19b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930823
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Cr-Commit-Position: refs/heads/master@{#718143}

--

wpt-commits: 1cf69323c6cca0f5def1f5b0c51b897c706f2488
wpt-pr: 20402
This commit is contained in:
Francois Beaufort 2019-11-26 11:31:15 +00:00 коммит произвёл moz-wptsync-bot
Родитель ae9aecd303
Коммит 2dcb14d70a
3 изменённых файлов: 17 добавлений и 0 удалений

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

@ -679,6 +679,8 @@ LAYOUTTESTS APIS: import-maps/resources/jest-test-helper.js
LAYOUTTESTS APIS: resources/chromium/generic_sensor_mocks.js
LAYOUTTESTS APIS: resources/chromium/nfc-mock.js
LAYOUTTESTS APIS: resources/chromium/webxr-test.js
LAYOUTTESTS APIS: web-nfc/NDEFReader-document-hidden-manual.https.html
LAYOUTTESTS APIS: web-nfc/NDEFReader_scan.https.html
LAYOUTTESTS APIS: web-nfc/NDEFWriter_push.https.html
# Signed Exchange files have hard-coded URLs in the certUrl field

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

@ -14,6 +14,11 @@ promise_test(async t => {
if (document.hidden) reject();
resolve();
});
if (window.testRunner) {
// Grant nfc permissions for Chromium testrunner.
window.testRunner.setPermission('nfc', 'granted',
location.origin, location.origin);
}
await reader.scan();
await promise;
}, "Test NDEFReader.onreading is not fired when document is hidden");

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

@ -49,6 +49,16 @@ promise_test(async t => {
}, "Test that NDEFReader.scan rejects if NDEFScanOptions.id has wrong \
protocol.");
promise_test(async t => {
if (window.testRunner) {
// Deny nfc permissions for Chromium testrunner.
window.testRunner.setPermission('nfc', 'denied',
location.origin, location.origin);
}
const reader = new NDEFReader();
await promise_rejects(t, 'NotAllowedError', reader.scan());
}, "NDEFReader.scan should fail if user permission is not granted.");
nfc_test(async (t, mockNFC) => {
mockNFC.setHWStatus(NFCHWStatus.DISABLED);
const reader = new NDEFReader();