Bug 1594424 [wpt PR 20125] - [WebNFC] Add permission prompt for NDEFWriter.push, a=testonly

Automatic update from web-platform-tests
[WebNFC] Add permission prompt for NDEFWriter.push

This CL makes sure NDEFWriter.push shows a permission request if user
didn't previously allow Web NFC. Follow-up CL will do something
similar for NDEFReader.

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

Bug: 520391
Change-Id: I4a1ac1edcd39d5d8a27f891a37044de8e9d0587a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895345
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: Balazs Engedy <engedy@chromium.org>
Reviewed-by: Peter Conn <peconn@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718123}

--

wpt-commits: 50fa7d656b2848dedb9821d3f84386d9b9501634
wpt-pr: 20125
This commit is contained in:
Francois Beaufort 2019-11-26 11:31:09 +00:00 коммит произвёл moz-wptsync-bot
Родитель b37213dc9f
Коммит ae9aecd303
3 изменённых файлов: 24 добавлений и 1 удалений

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

@ -677,7 +677,9 @@ MISSING-LINK: css/filter-effects/*.any.js
LAYOUTTESTS APIS: css/css-regions/interactivity/*
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/NDEFWriter_push.https.html
# Signed Exchange files have hard-coded URLs in the certUrl field
WEB-PLATFORM.TEST:signed-exchange/resources/*.sxg

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

@ -386,11 +386,18 @@ var WebNFCTest = (() => {
if (testInternal.initialized)
throw new Error('Call reset() before initialize().');
if (window.testRunner) {
// Grant nfc permissions for Chromium testrunner.
window.testRunner.setPermission('nfc', 'granted',
location.origin, location.origin);
}
if (testInternal.mockNFC == null) {
testInternal.mockNFC = new MockNFC();
}
testInternal.initialized = true;
}
// Reuses the nfc mock but resets its state between test runs.
async reset() {
if (!testInternal.initialized)

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

@ -127,6 +127,16 @@ promise_test(async t => {
}, "Test that promise is rejected with SyntaxError if NDEFMessageSource contains\
invalid records.");
promise_test(async t => {
if (window.testRunner) {
// Deny nfc permissions for Chromium testrunner.
window.testRunner.setPermission('nfc', 'denied',
location.origin, location.origin);
}
const writer = new NDEFWriter();
await promise_rejects(t, 'NotAllowedError', writer.push(test_text_data));
}, 'NDEFWriter.push should fail if user permission is not granted.');
nfc_test(async (t, mockNFC) => {
const writer = new NDEFWriter();
const controller = new AbortController();
@ -171,7 +181,6 @@ nfc_test(async (t, mockNFC) => {
const writer1 = new NDEFWriter();
const writer2 = new NDEFWriter();
const controller = new AbortController();
mockNFC.setPendingPushCompleted(false);
const p1 = writer1.push(test_text_data, { signal: controller.signal });
// Even though push request is grantable,
@ -220,6 +229,11 @@ promise_test(async () => {
await new Promise((resolve,reject) => {
const iframe = document.createElement('iframe');
iframe.srcdoc = `<script>
if (window.testRunner) {
// Grant nfc permissions for Chromium testrunner.
window.testRunner.setPermission('nfc', 'granted',
location.origin, location.origin);
}
window.onmessage = message => {
if (message.data === "Ready") {
const onSuccess = () => {